From: <ro...@us...> - 2006-07-06 02:52:22
|
Revision: 16437 Author: roast Date: 2006-07-05 19:52:10 -0700 (Wed, 05 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16437&view=rev Log Message: ----------- xml|html|txt_logger_read uses GIOChannels Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-06 02:40:39 UTC (rev 16436) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-06 02:52:10 UTC (rev 16437) @@ -1193,16 +1193,29 @@ { char *read; GaimLogCommonLoggerData *data = log->logger_data; + int filedes = 0; + GIOChannel *channel; + *flags = GAIM_LOG_READ_NO_NEWLINE; + if (!data || !data->path) return g_strdup(_("<font color=\"red\"><b>Unable to find log path!</b></font>")); - if (g_file_get_contents(data->path, &read, NULL, NULL)) { - gboolean bad_formatting; - char *processed; - bad_formatting = gaim_ufl_to_xhtml(read, &processed); + if ((filedes = open(data->path, O_RDONLY))) { + channel = g_io_channel_unix_new(filedes); + + if (g_io_channel_read_to_end(channel, &read, NULL, NULL) != G_IO_STATUS_ERROR) { + gboolean bad_formatting; + char *processed; + + bad_formatting = gaim_ufl_to_xhtml(read, &processed); + + g_io_channel_shutdown(channel, FALSE, NULL); + close(filedes); + return processed; + } - return processed; + close(filedes); } return g_strdup_printf(_("<font color=\"red\"><b>Could not read file: %s</b></font>"), data->path); @@ -1379,19 +1392,30 @@ { char *read; GaimLogCommonLoggerData *data = log->logger_data; + int filedes = 0; + GIOChannel *channel; + *flags = GAIM_LOG_READ_NO_NEWLINE; if (!data || !data->path) return g_strdup(_("<font color=\"red\"><b>Unable to find log path!</b></font>")); - if (g_file_get_contents(data->path, &read, NULL, NULL)) { - char *minus_header = strchr(read, '\n'); - if (!minus_header) - return read; + if ((filedes = open(data->path, O_RDONLY))) { + channel = g_io_channel_unix_new(filedes); - minus_header = g_strdup(minus_header + 1); - g_free(read); + if (g_io_channel_read_to_end(channel, &read, NULL, NULL) != G_IO_STATUS_ERROR) { + char *minus_header = strchr(read, '\n'); - return minus_header; + if (!minus_header) + return read; + + minus_header = g_strdup(minus_header + 1); + g_free(read); + + g_io_channel_shutdown(channel, FALSE, NULL); + close(filedes); + return minus_header; + } + close(filedes); } return g_strdup_printf(_("<font color=\"red\"><b>Could not read file: %s</b></font>"), data->path); } @@ -1539,21 +1563,34 @@ { char *read, *minus_header, *minus_header2; GaimLogCommonLoggerData *data = log->logger_data; + int filedes = 0; + GIOChannel *channel; + *flags = 0; + if (!data || !data->path) return g_strdup(_("<font color=\"red\"><b>Unable to find log path!</b></font>")); - if (g_file_get_contents(data->path, &read, NULL, NULL)) { - minus_header = strchr(read, '\n'); - if (!minus_header) - minus_header = g_strdup(read); - else - minus_header = g_strdup(minus_header + 1); - g_free(read); - minus_header2 = g_markup_escape_text(minus_header, -1); - g_free(minus_header); - read = gaim_markup_linkify(minus_header2); - g_free(minus_header2); - return read; + + if ((filedes = open(data->path, O_RDONLY))) { + channel = g_io_channel_unix_new(filedes); + + if (g_io_channel_read_to_end(channel, &read, NULL, NULL) != G_IO_STATUS_ERROR) { + minus_header = strchr(read, '\n'); + if (!minus_header) + minus_header = g_strdup(read); + else + minus_header = g_strdup(minus_header + 1); + g_free(read); + minus_header2 = g_markup_escape_text(minus_header, -1); + g_free(minus_header); + read = gaim_markup_linkify(minus_header2); + g_free(minus_header2); + + g_io_channel_shutdown(channel, FALSE, NULL); + close(filedes); + return read; + } + close(filedes); } return g_strdup_printf(_("<font color=\"red\"><b>Could not read file: %s</b></font>"), data->path); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |