From 3a50fb41b5f51828b5a90243b7170d70e93292dd Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sun, 24 Sep 2000 20:01:20 +0000 Subject: Updated to handle FIFO streams. 2000-09-24 Jeffrey Stedfast * e-msg-composer.c (get_signature): Updated to handle FIFO streams. svn path=/trunk/; revision=5563 --- composer/ChangeLog | 5 +++++ composer/e-msg-composer.c | 49 +++++++++++++++++------------------------------ 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/composer/ChangeLog b/composer/ChangeLog index a95af0ebf8..4198280f79 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,8 @@ +2000-09-24 Jeffrey Stedfast + + * e-msg-composer.c (get_signature): Updated to handle FIFO + streams. + 2000-09-19 Dan Winship * e-msg-composer.c (e_msg_composer_construct): Don't g_error out diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 799a4a3180..2e86bf85ed 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -313,50 +313,37 @@ build_message (EMsgComposer *composer) static char * get_signature (const char *sigfile) { - char *rawsig; - static char *htmlsig = NULL; - static time_t sigmodtime = -1; - struct stat st; - int fd; - + GString *rawsig; + char buf[1024]; + char *htmlsig = NULL; + int fd, n; + if (!sigfile || !*sigfile) { return NULL; } - - if (stat (sigfile, &st) == -1) { - char *msg; - - msg = g_strdup_printf ("Could not open signature file %s:\n%s", - sigfile, g_strerror (errno)); - gnome_error_dialog (msg); - g_free (msg); - - return NULL; - } - - if (st.st_mtime == sigmodtime) - return htmlsig; - - rawsig = g_malloc (st.st_size + 1); + fd = open (sigfile, O_RDONLY); if (fd == -1) { char *msg; - + msg = g_strdup_printf ("Could not open signature file %s:\n%s", sigfile, g_strerror (errno)); gnome_error_dialog (msg); g_free (msg); - + return NULL; } - - read (fd, rawsig, st.st_size); - rawsig[st.st_size] = '\0'; + + rawsig = g_string_new (""); + while ((n = read (fd, buf, 1023)) > 0) { + buf[n] = '\0'; + g_string_append (rawsig, buf); + } close (fd); - - htmlsig = e_text_to_html (rawsig, 0); - sigmodtime = st.st_mtime; - + + htmlsig = e_text_to_html (rawsig->str, 0); + g_string_free (rawsig, TRUE); + return htmlsig; } -- cgit v1.2.3