changeset 18:f54f95a4c53e

changed to use log_error() all over
author mortenp
date Thu, 22 Apr 2004 23:15:53 +1000
parents b045203f558b
children bad8b9b378a0
files src/incindexfile.c src/listcontrol.c src/mlmmj-process.c src/mlmmj-recieve.c src/mlmmj-subscribe.c src/mlmmj-unsubscribe.c src/send_help.c src/strip_file_to_fd.c
diffstat 8 files changed, 34 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/incindexfile.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/incindexfile.c	Thu Apr 22 23:15:53 2004 +1000
@@ -19,6 +19,8 @@
 #include "incindexfile.h"
 #include "itoa.h"
 
+#include "log_error.c"
+
 #define INTBUF_SIZE 32
 
 int incindexfile(const char *listdir, int incflag)
@@ -39,14 +41,14 @@
 	fd = open(indexfilename, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
 
 	if(fd == -1) {
-		perror("Error opening index file:");
+		log_error("Error opening index file");
 		exit(EXIT_FAILURE);
 	}
 
 	lock = myexcllock(fd);
 	
 	if(lock) {
-		perror("Error locking index file:");
+		log_error("Error locking index file");
 		close(fd);
 		exit(EXIT_FAILURE);
 	}
--- a/src/listcontrol.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/listcontrol.c	Thu Apr 22 23:15:53 2004 +1000
@@ -61,8 +61,7 @@
 					"-L", listdir,
 					"-a", fromemails.emaillist[0],
 					"-C", 0);
-			fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-subscribe failed: ", __FILE__, __LINE__);
-			perror(NULL);
+			log_error("execlp() of "BINDIR"mlmmj-subscribe failed");
 			exit(EXIT_FAILURE);
 		} else /* Not a valid From: address, so we silently ignore */
 			exit(EXIT_SUCCESS);
@@ -78,12 +77,13 @@
 			if(strncasecmp(tmpstr, fromemails.emaillist[0],
 						strlen(tmpstr)) == 0) {
 				unlink(conffilename);
-				execlp(BINDIR"mlmmj-subscribe", "mlmmj-subscribe",
+				execlp(BINDIR"mlmmj-subscribe",
+						"mlmmj-subscribe",
 						"-L", listdir,
 						"-a", tmpstr,
 						"-c", 0);
-				fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-subscribe failed: ", __FILE__, __LINE__);
-				perror(NULL);
+				log_error("execlp() of "BINDIR"mlmmj-subscribe"
+					" failed");
 				exit(EXIT_FAILURE);
 			} else {
 				/* Not proper confirm */
@@ -98,9 +98,8 @@
 					"-L", listdir,
 					"-a", fromemails.emaillist[0],
 					"-C", 0);
-			fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-unsubscribe "
-					"failed: ", __FILE__, __LINE__);
-			perror(NULL);
+			log_error("execlp() of "BINDIR"mlmmj-unsubscribe"
+				" failed");
 			exit(EXIT_FAILURE);
 		} else /* Not a valid From: address, so we silently ignore */
 			exit(EXIT_SUCCESS);
@@ -116,14 +115,13 @@
 			if(strncasecmp(tmpstr, fromemails.emaillist[0],
 						strlen(tmpstr)) == 0) {
 				unlink(conffilename);
-				execlp(BINDIR"mlmmj-unsubscribe", "mlmmj-unsubscribe",
+				execlp(BINDIR"mlmmj-unsubscribe",
+						"mlmmj-unsubscribe",
 						"-L", listdir,
 						"-a", tmpstr,
 						"-c", 0);
-				fprintf(stderr, "%s:%d execlp() of "
-						BINDIR"mlmmj-unsubscribe failed: ",
-						__FILE__, __LINE__);
-				perror(NULL);
+				log_error("execlp() of "
+					BINDIR"mlmmj-unsubscribe failed");
 				exit(EXIT_FAILURE);
 			} else {
 				exit(EXIT_SUCCESS);
--- a/src/mlmmj-process.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/mlmmj-process.c	Thu Apr 22 23:15:53 2004 +1000
@@ -24,6 +24,8 @@
 #include "strgen.h"
 #include "do_all_the_voodo_here.h"
 
+#include "log_error.c"
+
 static void print_help(const char *prg)
 {
 	        printf("Usage: %s [-P] -L /path/to/chat-list\n"
@@ -84,15 +86,13 @@
 	
 	if(fd == -1) {
 		free(donemailname);
-		fprintf(stderr, "%s:%d could not get fd in %s: ",
-                                __FILE__, __LINE__, donemailname);
+		log_error("could not create mail file in queue directory");
 		exit(EXIT_FAILURE);
 	}
 
 	if((donemailfile = fdopen(fd, "w")) == NULL) {
 		free(donemailname);
-		fprintf(stderr, "%s:%d could not fdopen",
-				__FILE__, __LINE__);
+		log_error("could not fdopen() output mail file");
 		exit(EXIT_FAILURE);
 	}
 
@@ -100,8 +100,7 @@
 
 	if((rawmailfile = fopen(mailfile, "r")) == NULL) {
 		free(donemailname);
-		fprintf(stderr, "%s:%d could not open %s: ",
-                                __FILE__, __LINE__, mailfile);
+		log_error("could not fopen() input mail file");
 		exit(EXIT_FAILURE);
 	}
 
@@ -157,8 +156,7 @@
 	execlp(BINDIR"mlmmj-send", "mlmmj-send",
 				"-L", listdir,
 				"-m", donemailname, 0);
-	fprintf(stderr, "%s:%d execlp() of mlmmj-send failed: ",
-			__FILE__, __LINE__);
-	perror(NULL);
+	log_error("execlp() of mlmmj-send failed");
+
 	return EXIT_FAILURE;
 }
--- a/src/mlmmj-recieve.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/mlmmj-recieve.c	Thu Apr 22 23:15:53 2004 +1000
@@ -20,6 +20,8 @@
 #include "mygetline.h"
 #include "strgen.h"
 
+#include "log_error.c"
+
 extern char *optarg;
 
 static void print_help(const char *prg)
@@ -68,8 +70,7 @@
 	}
 
 	if(fd < 0) {
-		fprintf(stderr, "%s:%d could not get fd in %s: ",
-				__FILE__, __LINE__, infilename);
+		log_error("could not create mail file in incoming directory");
 		free(infilename);
 		exit(EXIT_FAILURE);
 	}
@@ -89,13 +90,10 @@
 		exit(EXIT_SUCCESS);
 	}
 
-	execlp("mlmmj-process", "mlmmj-process",
+	execlp(BINDIR"mlmmj-process", "mlmmj-process",
 				"-L", listdir,
 				"-m", infilename, 0);
-
-	fprintf(stderr, "%s:%d execlp() of mlmmj-process failed: ",
-			__FILE__, __LINE__);
-	perror(NULL);
+	log_error("execlp() of "BINDIR"mlmmj-process failed");
 
 	return EXIT_FAILURE;
 }
--- a/src/mlmmj-subscribe.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/mlmmj-subscribe.c	Thu Apr 22 23:15:53 2004 +1000
@@ -111,8 +111,7 @@
 				"-T", subaddr,
 				"-F", fromaddr,
 				"-m", queuefilename, 0);
-	fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-send failed: ", __FILE__, __LINE__);
-	perror(NULL);
+	log_error("execlp() of "BINDIR"mlmmj-send");
 	exit(EXIT_FAILURE);
 }
 
@@ -228,8 +227,7 @@
 				"-F", fromaddr,
 				"-R", confirmaddr,
 				"-m", queuefilename, 0);
-	fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-send failed: ", __FILE__, __LINE__);
-	perror(NULL);
+	log_error("execlp() of "BINDIR"mlmmj-send failed");
 	exit(EXIT_FAILURE);
 }
 
--- a/src/mlmmj-unsubscribe.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/mlmmj-unsubscribe.c	Thu Apr 22 23:15:53 2004 +1000
@@ -112,8 +112,7 @@
 				"-T", subaddr,
 				"-F", fromaddr,
 				"-m", queuefilename, 0);
-	fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-send failed: ", __FILE__, __LINE__);
-	perror(NULL);
+	log_error("execlp() of "BINDIR"mlmmj-send failed");
 	exit(EXIT_FAILURE);
 }
 
@@ -229,8 +228,7 @@
 				"-F", fromaddr,
 				"-R", confirmaddr,
 				"-m", queuefilename, 0);
-	fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-send failed: ", __FILE__, __LINE__);
-	perror(NULL);
+	log_error("execlp() of "BINDIR"mlmmj-send failed");
 	exit(EXIT_FAILURE);
 }
 
--- a/src/send_help.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/send_help.c	Thu Apr 22 23:15:53 2004 +1000
@@ -115,7 +115,6 @@
 				"-T", emailaddr,
 				"-F", fromaddr,
 				"-m", queuefilename, 0);
-	fprintf(stderr, "%s:%d execlp() of "BINDIR"mlmmj-send failed: ", __FILE__, __LINE__);
-	perror(NULL);
+	log_error("execlp() of "BINDIR"mlmmj-send failed");
 	exit(EXIT_FAILURE);
 }
--- a/src/strip_file_to_fd.c	Thu Apr 22 23:00:27 2004 +1000
+++ b/src/strip_file_to_fd.c	Thu Apr 22 23:15:53 2004 +1000
@@ -15,6 +15,7 @@
 #include "mlmmj.h"
 #include "wrappers.h"
 
+#include "log_error.c"
 
 char *strip_headers(char *buf, const char **headers)
 {
@@ -84,7 +85,7 @@
 			if(buf[0]) {
 				bytes_written = writen(out_fd, buf, strlen(buf));
 				if(bytes_written == -1) {
-					perror(":error writing to fd");
+					log_error("error writing to fd");
 					exit(EXIT_FAILURE);
 				}
 			}