]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Add $text T$ substitution
authorBen Schmidt <none@none>
Thu, 29 Dec 2011 13:13:54 +0000 (00:13 +1100)
committerBen Schmidt <none@none>
Thu, 29 Dec 2011 13:13:54 +0000 (00:13 +1100)
ChangeLog
include/ctrlvalue.h
src/ctrlvalue.c
src/prepstdreply.c

index b848001901ee40726a51991890bd27336b9dcf61..7a702c82090c0f2c89bfed70a5af818d0d5ee6cf 100644 (file)
--- 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
index 52391cbfac899f2f8efd0c1bebdc32d6526be986..b88b8a82eaddbd939b0dbfb0eb154c9dd9a91d4f 100644 (file)
@@ -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 */
index 6a2a5672d5f361581c3ab004bb31c3e5836715c8..8616f63bbd8e6cc53b3abdfbd2bdec15b6dc5240 100644 (file)
@@ -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);
+}
+
index da1d69a1a21d281638056c06609ce5c167ac0465..8821b6d6047c9681b4d507d89d0b8b569ed140ab 100644 (file)
@@ -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]);