diff src/sm-archive.cpp @ 19:b24369330483 stable-1-0-7

Fedora 9 compile and const correctness.
author Carl Byington <carl@five-ten-sg.com>
date Thu, 12 Jun 2008 18:17:33 -0700
parents 8ebecad6530f
children 09564d4acd9e
line wrap: on
line diff
--- a/src/sm-archive.cpp	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/sm-archive.cpp	Thu Jun 12 18:17:33 2008 -0700
@@ -87,12 +87,12 @@
 void mlfiPriv::reset(bool final) {
 	targets.clear();
 	for (string_set::iterator i=removal.begin(); i!=removal.end(); i++) {
-		char *remove = (*i);
-		free(remove);
+		const char *remove = (*i);
+		free((void*)remove);
 	}
 	removal.clear();
-	if (mailaddr) free(mailaddr);
-	if (queueid)  free(queueid);
+	if (mailaddr) free((void*)mailaddr);
+	if (queueid)  free((void*)queueid);
 	if (!final) {
 		mailaddr = NULL;
 		queueid  = NULL;
@@ -105,7 +105,7 @@
 ////////////////////////////////////////////////
 // syslog a message
 //
-void my_syslog(mlfiPriv *priv, char *text) {
+void my_syslog(mlfiPriv *priv, const char *text) {
 	char buf[maxlen];
 	if (priv) {
 		snprintf(buf, sizeof(buf), "%s: %s", priv->queueid, text);
@@ -125,7 +125,7 @@
 	}
 }
 
-void my_syslog(char *text) {
+void my_syslog(const char *text) {
 	my_syslog(NULL, text);
 }
 
@@ -136,8 +136,8 @@
 // as the mail client sent it. We dup the string and convert
 // the duplicate to lower case.
 //
-char *to_lower_string(char *email);
-char *to_lower_string(char *email) {
+const char *to_lower_string(const char *email);
+const char *to_lower_string(const char *email) {
 	int n = strlen(email)-2;
 	if (n < 1) return strdup(email);
 	char *key = strdup(email+1);
@@ -167,8 +167,8 @@
 	return SMFIS_CONTINUE;
 }
 
-void add_target(mlfiPriv &priv, char *target);
-void add_target(mlfiPriv &priv, char *target)
+void add_target(mlfiPriv &priv, const char *target);
+void add_target(mlfiPriv &priv, const char *target)
 {
 	if (target) {
 		string_set::iterator i = priv.targets.find(target);
@@ -176,8 +176,8 @@
 	}
 }
 
-void add_remove(mlfiPriv &priv, char *remove);
-void add_remove(mlfiPriv &priv, char *remove)
+void add_remove(mlfiPriv &priv, const char *remove);
+void add_remove(mlfiPriv &priv, const char *remove)
 {
 	if (remove) {
 		string_set::iterator i = priv.removal.find(remove);
@@ -189,18 +189,18 @@
 {
 	mlfiPriv &priv = *MLFIPRIV;
 	CONFIG &dc = *priv.pc;
-	if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, "i"));
-	char *rcptaddr	= to_lower_string(rcpt[0]);
+	if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, (char*)"i"));
+	const char *rcptaddr	= to_lower_string(rcpt[0]);
 	if (debug_syslog > 1) {
 		char msg[maxlen];
 		snprintf(msg, sizeof(msg), "from <%s> to <%s>", priv.mailaddr, rcptaddr);
 		my_syslog(&priv, msg);
 	}
-	char *target = dc.find_to(rcptaddr);
+	const char *target = dc.find_to(rcptaddr);
 	add_target(priv, target);
 	bool remove  = dc.find_remove(rcptaddr);
 	if (remove) add_remove(priv, strdup(rcptaddr));
-	free(rcptaddr);
+	free((void*)rcptaddr);
 	return SMFIS_CONTINUE;
 }
 
@@ -208,11 +208,11 @@
 {
 	mlfiPriv &priv = *MLFIPRIV;
 	CONFIG &dc = *priv.pc;
-	char *target = dc.find_from(priv.mailaddr);
+	const char *target = dc.find_from(priv.mailaddr);
 	add_target(priv, target);
 	for (string_set::iterator i=priv.targets.begin(); i!=priv.targets.end(); i++) {
 		target = (*i);
-		smfi_addrcpt(ctx, target);
+		smfi_addrcpt(ctx, (char*)target);
 		if (debug_syslog > 1) {
 			char msg[maxlen];
 			snprintf(msg, sizeof(msg), "adding recipient <%s>", target);
@@ -220,8 +220,8 @@
 		}
 	}
 	for (string_set::iterator i=priv.removal.begin(); i!=priv.removal.end(); i++) {
-		char *remove = (*i);
-		smfi_delrcpt(ctx, remove);
+		const char *remove = (*i);
+		smfi_delrcpt(ctx, (char*)remove);
 		if (debug_syslog > 1) {
 			char msg[maxlen];
 			snprintf(msg, sizeof(msg), "removing recipient <%s>", remove);
@@ -251,7 +251,7 @@
 
 struct smfiDesc smfilter =
 {
-	"SM-ARCHIVE",       // filter name
+	(char*)"SM-ARCHIVE",// filter name
 	SMFI_VERSION,		// version code -- do not change
 	SMFIF_ADDRCPT | \
 	SMFIF_DELRCPT,		// flags
@@ -306,7 +306,7 @@
 		struct stat st;
 		bool reload = false;
 		for (string_set::iterator i=dc.config_files.begin(); i!=dc.config_files.end(); i++) {
-			char *fn = *i;
+			const char *fn = *i;
 			if (stat(fn, &st))			 reload = true; // file disappeared
 			else if (st.st_mtime > then) reload = true; // file modified
 			if (reload) break;
@@ -335,8 +335,8 @@
 }
 
 
-void usage(char *prog);
-void usage(char *prog)
+void usage(const char *prog);
+void usage(const char *prog)
 {
 	fprintf(stderr, "Usage: %s  [-d [level]] [-c] -p sm-sock-addr [-t timeout]\n", prog);
 	fprintf(stderr, "where sm-sock-addr is for the connection to sendmail\n");
@@ -349,8 +349,8 @@
 
 
 
-void setup_socket(char *sock);
-void setup_socket(char *sock) {
+void setup_socket(const char *sock);
+void setup_socket(const char *sock) {
 	unlink(sock);
 	//	sockaddr_un addr;
 	//	memset(&addr, '\0', sizeof addr);