changeset 140:a79d22b050e6

mlmmj-maintd work (still in progress)
author mmj
date Wed, 02 Jun 2004 08:12:46 +1000
parents fb077a8016de
children 8ae0a10588e4
files src/Makefile.am src/mlmmj-maintd.c
diffstat 2 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile.am	Wed Jun 02 08:03:06 2004 +1000
+++ b/src/Makefile.am	Wed Jun 02 08:12:46 2004 +1000
@@ -41,4 +41,4 @@
 		       subscriberfuncs.c strgen.c random-int.c writen.c
 
 mlmmj_maintd_SOURCES = mlmmj-maintd.c print-version.c log_error.c mygetline.c \
-		       strgen.c random-int.c
+		       strgen.c random-int.c chomp.c
--- a/src/mlmmj-maintd.c	Wed Jun 02 08:03:06 2004 +1000
+++ b/src/mlmmj-maintd.c	Wed Jun 02 08:12:46 2004 +1000
@@ -18,6 +18,7 @@
 #include "mlmmj-maintd.h"
 #include "mlmmj.h"
 #include "strgen.h"
+#include "chomp.h"
 #include "log_error.h"
 #include "mygetline.h"
 
@@ -115,10 +116,8 @@
 	char *discardedname = NULL;
 	char *dirname = concatstr(2, listdir, "/queue/");
 	FILE *ffrom, *fto, *f;
-	size_t len;
 	pid_t pid;
 	struct stat st;
-	time_t t;
 	int discarded = 0;
 
 	if(chdir(dirname) < 0) {
@@ -133,7 +132,7 @@
 	}
 
 	while((dp = readdir(queuedir)) != NULL) {
-		if(strchr(dp->d_name, "."))
+		if(strchr(dp->d_name, '.'))
 			continue;
 		if(stat(dp->d_name, &st) < 0) {
 			log_error(LOG_ARGS, "Could not stat(%s)",dp->d_name);
@@ -158,6 +157,7 @@
 				log_error(LOG_ARGS, "Could not stat(%s)",
 						dp->d_name);
 		}
+		}
 
 		toname = concatstr(2, mailname, ".reciptto");
 		if(!discarded && stat(toname, &st) < 0) {
@@ -168,6 +168,9 @@
 				discarded = discardmail(mailname,
 							discardedname,
 							3600);
+			} else {
+				log_error(LOG_ARGS, "Could not stat(%s)",
+						dp->d_name);
 			}
 		}
 		
@@ -192,10 +195,12 @@
 		}
 
 		from = myfgetline(ffrom);
+		chomp(from);
 		fclose(ffrom);
 		unlink(fromname);
 		free(fromname);
 		to = myfgetline(fto);
+		chomp(to);
 		fclose(fto);
 		unlink(toname);
 		free(toname);
@@ -205,6 +210,7 @@
 			repto = NULL;
 		} else {
 			repto = myfgetline(f);
+			chomp(repto);
 			fclose(f);
 			unlink(reptoname);
 			free(reptoname);
@@ -213,7 +219,10 @@
 		pid = fork();
 
 		if(pid == 0) {
-			if(repto)
+			if(repto) {
+				printf("%s -l %s -m %s -F %s -T %s -R %s -a\n",
+						mlmmjsend, "1", mailname, from,
+						to, repto);
 				execlp(mlmmjsend, mlmmjsend,
 						"-l", "1",
 						"-m", mailname,
@@ -221,7 +230,9 @@
 						"-T", to,
 						"-R", repto,
 						"-a", 0);
-			else
+			} else {
+				printf("%s -l %s -m %s -F %s -T %s -a\n",
+						mlmmjsend, "1", mailname, from, to);
 				execlp(mlmmjsend, mlmmjsend,
 						"-l", "1",
 						"-m", mailname,
@@ -229,6 +240,8 @@
 						"-T", to,
 						"-a", 0);
 		}
+		}
+	}
 
 	return 0;
 }