From: Ben Schmidt Date: Thu, 29 Dec 2011 13:13:54 +0000 (+1100) Subject: Add $text T$ substitution X-Git-Tag: RELEASE_1_2_18a1~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76c5238f231b7aafd8a9fa1afca5c0fbed5cabb3;p=thirdparty%2Fmlmmj.git Add $text T$ substitution --- diff --git a/ChangeLog b/ChangeLog index b8480019..7a702c82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + o Add $text T$ substitution o Add $$ substitution o Allow list texts to include real UTF-8 characters, as documented o Fix bug where the normal listtext would be sent when unsubscribing from the @@ -17,7 +18,7 @@ o Better techniques for locating support files in php-admin -- existing installations will need to have their conf/config.php altered to set the variable $confdir - o Add $controlN$ substitution + o Add $control C$ substitution o Fix theoretically possible memory corruption by chomp() o Remove .sh from mlmmj-make-ml.sh; symlink original name o Correct spelling of 'receive' and 'voodoo' throughout the code and diff --git a/include/ctrlvalue.h b/include/ctrlvalue.h index 52391cbf..b88b8a82 100644 --- a/include/ctrlvalue.h +++ b/include/ctrlvalue.h @@ -26,5 +26,6 @@ char *ctrlvalue(const char *listdir, const char *ctrlstr); char *ctrlcontent(const char *listdir, const char *ctrlstr); +char *textcontent(const char *listdir, const char *ctrlstr); #endif /* CTRLVALUE_H */ diff --git a/src/ctrlvalue.c b/src/ctrlvalue.c index 6a2a5672..8616f63b 100644 --- a/src/ctrlvalue.c +++ b/src/ctrlvalue.c @@ -34,7 +34,8 @@ #include "chomp.h" #include "memory.h" -static char *ctrlval(const char *listdir, const char *ctrlstr, int oneline) +static char *ctrlval(const char *listdir, const char *subdir, + const char *ctrlstr, int oneline) { char *filename, *value = NULL; int ctrlfd, i; @@ -42,7 +43,7 @@ static char *ctrlval(const char *listdir, const char *ctrlstr, int oneline) if(listdir == NULL) return NULL; - filename = concatstr(3, listdir, "/control/", ctrlstr); + filename = concatstr(5, listdir, "/", subdir, "/", ctrlstr); ctrlfd = open(filename, O_RDONLY); myfree(filename); @@ -71,10 +72,16 @@ static char *ctrlval(const char *listdir, const char *ctrlstr, int oneline) char *ctrlvalue(const char *listdir, const char *ctrlstr) { - return ctrlval(listdir, ctrlstr, 1); + return ctrlval(listdir, "control", ctrlstr, 1); } char *ctrlcontent(const char *listdir, const char *ctrlstr) { - return ctrlval(listdir, ctrlstr, 0); + return ctrlval(listdir, "control", ctrlstr, 0); } + +char *textcontent(const char *listdir, const char *ctrlstr) +{ + return ctrlval(listdir, "text", ctrlstr, 0); +} + diff --git a/src/prepstdreply.c b/src/prepstdreply.c index da1d69a1..8821b6d6 100644 --- a/src/prepstdreply.c +++ b/src/prepstdreply.c @@ -180,8 +180,28 @@ char *substitute_one(const char *line, const char *listaddr, if (value == NULL) value = mystrdup(""); goto concatandreturn; - } - if(data) { + } else if(strncmp(token, "text ", 5) == 0) { + value = token + 5; + if(*value == '\0') { + value = mystrdup(""); + goto concatandreturn; + } + for(; *value != '\0'; value++) { + if(*value >= '0' && *value <= '9') continue; + if(*value >= 'A' && *value <= 'Z') continue; + if(*value >= 'a' && *value <= 'z') continue; + break; + } + if(*value != '\0') { + value = mystrdup(token + 5); + goto concatandreturn; + } + value = token + 5; + value = textcontent(listdir, value); + if (value == NULL) + value = mystrdup(""); + goto concatandreturn; + } else if(data) { for(i = 0; i < datacount; i++) { if(strcmp(token, data[i*2]) == 0) { value = mystrdup(data[(i*2)+1]);