# HG changeset patch # User mortenp # Date 1245150319 -36000 # Node ID d7d67d5fa2634368a7e05900a02d5111eb89a30f # Parent ba413c74c9ab3c2e05000573c736c0dd4740d8dc Added support for digest and nomail to +list (Christoph Wilke) diff -r ba413c74c9ab -r d7d67d5fa263 ChangeLog --- a/ChangeLog Sat Apr 11 18:27:36 2009 +1000 +++ b/ChangeLog Tue Jun 16 21:05:19 2009 +1000 @@ -1,3 +1,4 @@ + o Added support for digest and nomail to +list (Christoph Wilke) o Caseinsensitive string compare for owner addr when +list is invoked. Spotted by Pavel Kolar. o Added contrib/web/php-moderation (Thomas Goirand) diff -r ba413c74c9ab -r d7d67d5fa263 src/send_list.c --- a/src/send_list.c Sat Apr 11 18:27:36 2009 +1000 +++ b/src/send_list.c Tue Jun 16 21:05:19 2009 +1000 @@ -42,20 +42,58 @@ #include "prepstdreply.h" #include "memory.h" + + +static void print_subs(int cur_fd, char *dirname) +{ + char *fileiter; + DIR *dirp; + struct dirent *dp; + int subfd; + + dirp = opendir(dirname); + if(dirp == NULL) { + fprintf(stderr, "Could not opendir(%s);\n", dirname); + exit(EXIT_FAILURE); + } + while((dp = readdir(dirp)) != NULL) { + if((strcmp(dp->d_name, "..") == 0) || + (strcmp(dp->d_name, ".") == 0)) + continue; + + fileiter = concatstr(2, dirname, dp->d_name); + subfd = open(fileiter, O_RDONLY); + if(subfd < 0) { + log_error(LOG_ARGS, "Could not open %s for reading", + fileiter); + myfree(fileiter); + continue; + } + if(dumpfd2fd(subfd, cur_fd) < 0) { + log_error(LOG_ARGS, "Error dumping subfile content" + " of %s to sub list mail", + fileiter); + } + + close(subfd); + myfree(fileiter); + } + closedir(dirp); +} + + + void send_list(const char *listdir, const char *emailaddr, const char *mlmmjsend) { char *queuefilename, *listaddr, *listdelim, *listname, *listfqdn; - char *fromaddr, *subdir, *fileiter; - DIR *dirp; - struct dirent *dp; - int fd, subfd; + char *fromaddr, *subdir, *nomaildir, *digestdir; + int fd; listaddr = getlistaddr(listdir); listdelim = getlistdelim(listdir); listname = genlistname(listaddr); listfqdn = genlistfqdn(listaddr); - subdir = concatstr(2, listdir, "/subscribers.d/"); fromaddr = concatstr(4, listname, listdelim, "bounces-help@", listfqdn); myfree(listdelim); @@ -78,36 +116,18 @@ exit(EXIT_FAILURE); } - dirp = opendir(subdir); - if(dirp == NULL) { - fprintf(stderr, "Could not opendir(%s);\n", subdir); - exit(EXIT_FAILURE); - } - while((dp = readdir(dirp)) != NULL) { - if((strcmp(dp->d_name, "..") == 0) || - (strcmp(dp->d_name, ".") == 0)) - continue; + subdir = concatstr(2, listdir, "/subscribers.d/"); + nomaildir = concatstr(2, listdir, "/nomailsubs.d/"); + digestdir = concatstr(2, listdir, "/digesters.d/"); - fileiter = concatstr(2, subdir, dp->d_name); - subfd = open(fileiter, O_RDONLY); - if(subfd < 0) { - log_error(LOG_ARGS, "Could not open %s for reading", - fileiter); - myfree(fileiter); - continue; - } - if(dumpfd2fd(subfd, fd) < 0) - log_error(LOG_ARGS, "Error dumping subfile content " - "to sub list mail"); - - close(subfd); - myfree(fileiter); - } - + print_subs(fd, subdir); + writen(fd, "\n-- \n", 5); + print_subs(fd, nomaildir); + writen(fd, "\n-- \n", 5); + print_subs(fd, digestdir); writen(fd, "\n-- \nend of output\n", 19); close(fd); - closedir(dirp); myfree(listaddr); myfree(listname);