[gmime] Fixed uudecode to work on Windows



commit f499dbff8d6c65a3779639184d63d3da7c687b33
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sun Jan 31 22:08:30 2010 -0500

    Fixed uudecode to work on Windows
    
    2010-01-31  Jeffrey Stedfast  <fejj novell com>
    
    	* src/uudecode.c (uudecode): Just use fopen() to open fout
    	instead of using open() and then fdopen(). Fixes the code to
    	work properly on Windows.

 ChangeLog      |    4 ++++
 src/uudecode.c |   16 +++-------------
 2 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b949ec8..1c5f7d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-01-31  Jeffrey Stedfast  <fejj novell com>
 
+	* src/uudecode.c (uudecode): Just use fopen() to open fout instead
+	of using open() and then fdopen(). Fixes the code to work properly
+	on Windows.
+
 	* gmime/gmime-encodings.h (GMIME_UUENCODE_LEN): Fixed to prevent
 	possible buffer overflows.
 
diff --git a/src/uudecode.c b/src/uudecode.c
index 3fd7b4d..3b0b21c 100644
--- a/src/uudecode.c
+++ b/src/uudecode.c
@@ -90,7 +90,7 @@ static int
 uudecode (const char *progname, int argc, char **argv)
 {
 	gboolean midline = FALSE, base64 = FALSE;
-	int fd, opt, longindex = 0, state = 0;
+	int opt, longindex = 0, state = 0;
 	register const char *p;
 	char inbuf[4096], *q;
 	GString *str = NULL;
@@ -130,7 +130,7 @@ uudecode (const char *progname, int argc, char **argv)
 	infile = optind < argc ? argv[optind] : DEFAULT_FILENAME;
 	
 	do {
-		if ((fin = uufopen (infile, "r", O_RDONLY, 0)) == NULL) {
+		if ((fin = uufopen (infile, "rt", O_RDONLY, 0)) == NULL) {
 			fprintf (stderr, "%s: %s: %s\n", progname,
 				 infile, g_strerror (errno));
 			return -1;
@@ -196,7 +196,7 @@ uudecode (const char *progname, int argc, char **argv)
 		if (!outfile || outfile != optarg)
 			outfile = g_strchomp (str->str);
 		
-		if ((fd = open (outfile, O_CREAT | O_TRUNC | O_WRONLY, mode)) == -1) {
+		if (!(fout = fopen (outfile, "wb"))) {
 			fprintf (stderr, "%s: %s: %s\n", progname,
 				 outfile, g_strerror (errno));
 			g_string_free (str, TRUE);
@@ -205,16 +205,6 @@ uudecode (const char *progname, int argc, char **argv)
 			return -1;
 		}
 		
-		if (!(fout = fdopen (fd, "wb"))) {
-			fprintf (stderr, "%s: %s: %s\n", progname,
-				 outfile, g_strerror (errno));
-			g_string_free (str, TRUE);
-			fclose (fin);
-			close (fd);
-			
-			return -1;
-		}
-		
 		while ((fgets (inbuf, sizeof (inbuf), fin))) {
 			if (!midline) {
 				if (base64) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]