#include "send_help.h"
#include "xstring.h"
+static char *subtypes[7] = {
+ "SUB_NORMAL",
+ "SUB_DIGEST",
+ "SUB_NOMAIL",
+ NULL,
+ NULL,
+ "SUB_BOTH",
+ NULL,
+};
+
static void moderate_sub(struct ml *ml, const char *subaddr,
const char *mlmmjsend, enum subtype typesub,
enum subreason reasonsub)
pid_t childpid, pid;
xstring *str = NULL;
- /* generate the file in moderation/ */
- switch(typesub) {
- default:
- case SUB_NORMAL:
- type = "SUB_NORMAL";
- break;
- case SUB_DIGEST:
- type = "SUB_DIGEST";
- break;
- case SUB_NOMAIL:
- type = "SUB_NOMAIL";
- break;
- case SUB_BOTH:
- type = "SUB_BOTH";
- break;
- }
-
+ type = subtypes[typesub];
+
for (;;) {
cookie = random_str();
xasprintf(&modfilename, "moderation/subscribe%s", cookie);
chomp(readaddr);
*addrptr = readaddr;
- if(strncmp(readtype, "SUB_NORMAL", 10) == 0) {
- *subtypeptr = SUB_NORMAL;
- goto freedone;
- }
-
- if(strncmp(readtype, "SUB_DIGEST", 10) == 0) {
- *subtypeptr = SUB_DIGEST;
- goto freedone;
- }
-
- if(strncmp(readtype, "SUB_NOMAIL", 10) == 0) {
- *subtypeptr = SUB_NOMAIL;
- goto freedone;
- }
-
- if(strncmp(readtype, "SUB_BOTH", 8) == 0) {
- *subtypeptr = SUB_BOTH;
- goto freedone;
+ for (size_t i = 0; i < NELEM(subtypes); i++) {
+ if (subtypes[i] == NULL)
+ continue;
+ if (strcmp(subtypes[i], readtype) == 0) {
+ *subtypeptr = i;
+ goto freedone;
+ }
}
log_error(LOG_ARGS, "Type %s not valid in %s", readtype,
}
if(modstr) {
- getaddrandtype(listdir, modstr, &address, &typesub);
+ getaddrandtype(ml.dir, modstr, &address, &typesub);
reasonsub = SUB_PERMIT;
}
atf_check -s exit:1 test -f mail-3.txt
atf_check -o match:"^ml/moderation/subscribe.*" find ml/moderation/ -type f
atf_check -o inline:"john@doe.org\nSUB_NORMAL\n" cat ml/moderation/subscribe*
+ file=$(ls ml/moderation/subscribe*)
+ atf_check ${mlmmjsub} -L ml -m ${file##*subscribe} -c
+ atf_check -o inline:"john@doe.org\n" cat ml/subscribers.d/j
+ atf_check -s exit:1 test -f $file
}
add_normal_then_nomail_body()