changeset 172:8abdd3534b9f

Another FILE* bites the dust
author mmj
date Fri, 04 Jun 2004 20:46:33 +1000
parents f4051eb9504a
children c91c37f083a6
files src/mlmmj-maintd.c
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/mlmmj-maintd.c	Fri Jun 04 20:41:57 2004 +1000
+++ b/src/mlmmj-maintd.c	Fri Jun 04 20:46:33 2004 +1000
@@ -14,6 +14,7 @@
 #include <sys/stat.h>
 #include <dirent.h>
 #include <time.h>
+#include <fcntl.h>
 
 #include "mlmmj-maintd.h"
 #include "mlmmj.h"
@@ -115,10 +116,9 @@
 	char *mailname, *fromname, *toname, *reptoname, *from, *to, *repto;
 	char *discardedname = NULL, *ch;
 	char *dirname = concatstr(2, listdir, "/queue/");
-	FILE *ffrom, *fto, *f;
 	pid_t pid;
 	struct stat st;
-	int discarded = 0;
+	int fromfd, tofd, fd, discarded = 0;
 
 	if(chdir(dirname) < 0) {
 		log_error(LOG_ARGS, "Could not chdir(%s)", dirname);
@@ -186,10 +186,10 @@
 		
 		reptoname = concatstr(2, mailname, ".reply-to");
 
-		ffrom = fopen(fromname, "r");
-		fto = fopen(toname, "r");
+		fromfd = open(fromname, O_RDONLY);
+		tofd = open(toname, O_RDONLY);
 
-		if(ffrom == NULL || fto == NULL) {
+		if(fromfd < 0 || tofd < 0) {
 			if(discarded) {
 				unlink(fromname);
 				unlink(toname);
@@ -199,29 +199,29 @@
 			free(fromname);
 			free(toname);
 			free(reptoname);
-			if(ffrom)
-				fclose(ffrom);
+			if(fromfd >= 0)
+				close(fromfd);
 			continue;
 		}
 
-		from = myfgetline(ffrom);
+		from = mygetline(fromfd);
 		chomp(from);
-		fclose(ffrom);
+		close(fromfd);
 		unlink(fromname);
 		free(fromname);
-		to = myfgetline(fto);
+		to = mygetline(tofd);
 		chomp(to);
-		fclose(fto);
+		close(tofd);
 		unlink(toname);
 		free(toname);
-		f = fopen(reptoname, "r");
-		if(f == NULL) {
+		fd = open(reptoname, O_RDONLY);
+		if(fd < 0) {
 			free(reptoname);
 			repto = NULL;
 		} else {
-			repto = myfgetline(f);
+			repto = mygetline(fd);
 			chomp(repto);
-			fclose(f);
+			close(fd);
 			unlink(reptoname);
 			free(reptoname);
 		}