]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
open_text*: convert to struct mlmmj_list
authorBaptiste Daroussin <bapt@FreeBSD.org>
Tue, 2 Nov 2021 13:59:24 +0000 (14:59 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 3 Nov 2021 13:10:28 +0000 (14:10 +0100)
include/prepstdreply.h
src/listcontrol.c
src/mlmmj-bounce.c
src/mlmmj-process.c
src/mlmmj-sub.c
src/mlmmj-unsub.c
src/prepstdreply.c
src/send_digest.c
src/send_list.c

index 458a7d734f8215db09df414ee22ea1cb1b302d16..b01a764c994fbfbcb91b5e33adc9c6d7b538d90f 100644 (file)
@@ -54,8 +54,8 @@ void finish_file_lines(file_lines_state *s);
 
 char *substitute(const char *line, struct mlmmj_list *list, text *txt);
 
-text *open_text_file(const char *listdir, const char *filename);
-text *open_text(const char *listdir, const char *purpose, const char *action,
+text *open_text_file(struct mlmmj_list *list, const char *filename);
+text *open_text(struct mlmmj_list *list, const char *purpose, const char *action,
                   const char *reason, const char *type, const char *compat);
 void register_unformatted(text *txt, const char *token, const char *subst);
 void register_originalmail(text *txt, const char *mailname);
index 987e989bdb21bfe93ad910cbb6bec314d5259a15..f5db37686d832fda9933ddbc47f98f8e6a53614b 100644 (file)
@@ -221,7 +221,7 @@ int listcontrol(struct email_container *fromemails, struct mlmmj_list *list,
                        errno = 0;
                        log_error(LOG_ARGS, "A subscribe-digest request was"
                                " denied");
-                       txt = open_text(list->dir, "deny", "sub", "disabled",
+                       txt = open_text(list, "deny", "sub", "disabled",
                                        "digest", "sub-deny-digest");
                        MY_ASSERT(txt);
                        register_unformatted(txt, "subaddr",
@@ -269,7 +269,7 @@ int listcontrol(struct email_container *fromemails, struct mlmmj_list *list,
                        errno = 0;
                        log_error(LOG_ARGS, "A subscribe-nomail request was"
                                " denied");
-                       txt = open_text(list->dir, "deny", "sub", "disabled",
+                       txt = open_text(list, "deny", "sub", "disabled",
                                        "nomail", "sub-deny-nomail");
                        MY_ASSERT(txt);
                        register_unformatted(txt, "subaddr",
@@ -317,7 +317,7 @@ int listcontrol(struct email_container *fromemails, struct mlmmj_list *list,
                        errno = 0;
                        log_error(LOG_ARGS, "A subscribe-both request was"
                                " denied");
-                       txt = open_text(list->dir, "deny", "sub", "disabled",
+                       txt = open_text(list, "deny", "sub", "disabled",
                                        "both", "sub-deny-digest");
                        MY_ASSERT(txt);
                        register_unformatted(txt, "subaddr",
@@ -797,7 +797,7 @@ permit:
                }
                log_oper(list->dir, OPLOGFNAME, "%s requested help",
                                fromemails->emaillist[0]);
-               txt = open_text(list->dir, "help", NULL, NULL, NULL, "listhelp");
+               txt = open_text(list, "help", NULL, NULL, NULL, "listhelp");
                MY_ASSERT(txt);
                queuefilename = prepstdreply(txt, list,
                                "$listowner$", fromemails->emaillist[0], NULL);
@@ -819,7 +819,7 @@ permit:
                }
                log_oper(list->dir, OPLOGFNAME, "%s requested faq",
                                fromemails->emaillist[0]);
-               txt = open_text(list->dir, "faq", NULL, NULL, NULL, "listfaq");
+               txt = open_text(list, "faq", NULL, NULL, NULL, "listfaq");
                MY_ASSERT(txt);
                queuefilename = prepstdreply(txt, list,
                                "$listowner$", fromemails->emaillist[0], NULL);
index f33cbd9c6bf11a537187550109f73e13449fe930..92a2f9f4eae1113321dd0ce8e017de076bed900d 100644 (file)
@@ -70,7 +70,7 @@ static void do_probe(struct mlmmj_list *list, const char *mlmmjsend, const char
        }
        *a = '@';
 
-       txt = open_text(list->dir, "probe", NULL, NULL, NULL, "bounce-probe");
+       txt = open_text(list, "probe", NULL, NULL, NULL, "bounce-probe");
        MY_ASSERT(txt);
        register_unformatted(txt, "bouncenumbers", "%bouncenumbers%"); /* DEPRECATED */
        fls = init_truncated_file_lines(addr, 0, ':');
index 2946cebf111d59229002c0fe5c90cb56c7b11a88..59f43b86f95bcff2217d0067511a95d8b5abaff3 100644 (file)
@@ -158,7 +158,7 @@ static void newmoderated(struct mlmmj_list *list, const char *mailfilename,
        from = concatstr(4, list->name, list->delim, "owner@", list->fqdn);
        to = concatstr(3, list->name, "-moderators@", list->fqdn); /* FIXME JFA: Should this be converted? Why, why not? */
 
-       txt = open_text(list->dir, "moderate", "post",
+       txt = open_text(list, "moderate", "post",
                        modreason_strs[modreason], NULL, "moderation");
        MY_ASSERT(txt);
        register_unformatted(txt, "subject", subject);
@@ -215,7 +215,7 @@ static void newmoderated(struct mlmmj_list *list, const char *mailfilename,
 
        /* send mail to poster that the list is moderated */
 
-       txt = open_text(list->dir, "wait", "post",
+       txt = open_text(list, "wait", "post",
                        modreason_strs[modreason], NULL, "moderation-poster");
        MY_ASSERT(txt);
        register_unformatted(txt, "subject", subject);
@@ -445,7 +445,7 @@ send_denymail(struct mlmmj_list *list, const char *mlmmjsend,
        text *txt;
 
        fromaddr = concatstr(4, list->name, list->delim, "bounces-help@", list->fqdn);
-       txt = open_text(list->dir, "deny", "post", cause, NULL, subcause);
+       txt = open_text(list, "deny", "post", cause, NULL, subcause);
        MY_ASSERT(txt);
        register_unformatted(txt, "subject", subject);
        register_unformatted(txt, "posteraddr", posteraddr);
index d23e690e2668125d4ce6a3d194e3911e34c1aee1..4f48a19d41f65d43acd53f2450871823f2e00c10 100644 (file)
@@ -143,7 +143,7 @@ static void moderate_sub(struct mlmmj_list *list, const char *subaddr,
        mls = init_memory_lines(moderators);
        myfree(moderators);
 
-       txt = open_text(list->dir,
+       txt = open_text(list,
                        "gatekeep", "sub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        "submod-moderator");
@@ -198,7 +198,7 @@ static void moderate_sub(struct mlmmj_list *list, const char *subaddr,
        myasprintf(&from, "%s%sbounces-help@%s", list->name, list->delim,
            list->fqdn);
 
-       txt = open_text(list->dir,
+       txt = open_text(list,
                        "wait", "sub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        "submod-requester");
@@ -307,7 +307,7 @@ static void confirm_sub(struct mlmmj_list *list, const char *subaddr,
                        break;
        }
 
-       txt = open_text(list->dir, "finish", "sub",
+       txt = open_text(list, "finish", "sub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        listtext);
        myfree(listtext);
@@ -356,7 +356,7 @@ static void notify_sub(struct mlmmj_list *list, const char *subaddr,
                        break;
        }
 
-       txt = open_text(list->dir, "notify", "sub",
+       txt = open_text(list, "notify", "sub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        listtext);
        myfree(listtext);
@@ -447,7 +447,7 @@ static void generate_subconfirm(struct mlmmj_list *list, const char *subaddr,
        myfree(randomstr);
        myfree(tmpstr);
 
-       txt = open_text(list->dir, "confirm", "sub",
+       txt = open_text(list, "confirm", "sub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        listtext);
        myfree(listtext);
@@ -501,7 +501,7 @@ static void generate_subscribed(struct mlmmj_list *list, const char *subaddr,
        myasprintf(&fromaddr, "%s%sbounces-help@%s", list->name, list->delim,
            list->fqdn);
 
-       txt = open_text(list->dir,
+       txt = open_text(list,
                        "deny", "sub", "subbed", subtype_strs[typesub],
                        "sub-subscribed");
        MY_ASSERT(txt);
index 3fee1737714a25ba78a53a51649b8eac2bdd8f68..ce0a18b0c2ba0eb955a24e71343c63ed4808ba23 100644 (file)
@@ -69,7 +69,7 @@ static void confirm_unsub(struct mlmmj_list *list, const char *subaddr,
                        break;
        }
 
-       txt = open_text(list->dir, "finish", "unsub",
+       txt = open_text(list, "finish", "unsub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        listtext);
        myfree(listtext);
@@ -115,7 +115,7 @@ static void notify_unsub(struct mlmmj_list *list, const char *subaddr,
                        break;
        }
        
-       txt = open_text(list->dir, "notify", "unsub",
+       txt = open_text(list, "notify", "unsub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        listtext);
        myfree(listtext);
@@ -201,7 +201,7 @@ static void generate_unsubconfirm(struct mlmmj_list *list, const char *subaddr,
        myfree(randomstr);
        myfree(tmpstr);
 
-       txt = open_text(list->dir, "confirm", "unsub",
+       txt = open_text(list, "confirm", "unsub",
                        subreason_strs[reasonsub], subtype_strs[typesub],
                        listtext);
        myfree(listtext);
@@ -295,7 +295,7 @@ static void generate_notsubscribed(struct mlmmj_list *list, const char *subaddr,
 
        myasprintf(&fromaddr, "%s%sbounes-help@%s", list->name, list->delim, list->fqdn);
 
-       txt = open_text(list->dir,
+       txt = open_text(list,
                        "deny", "unsub", "unsubbed", subtype_strs[typesub],
                        "unsub-notsubscribed");
        MY_ASSERT(txt);
index 436df648481011be0a0619619bdf6c07b5d83ce4..4639814dd1e83c6ea28cd7653dcccc0cd6304abd 100644 (file)
@@ -453,7 +453,7 @@ char *substitute(const char *line, struct mlmmj_list *list, text *txt)
 }
 
 
-text *open_text_file(const char *listdir, const char *filename)
+text *open_text_file(struct mlmmj_list *list, const char *filename)
 {
        char *tmp;
        text *txt;
@@ -485,8 +485,8 @@ text *open_text_file(const char *listdir, const char *filename)
        txt->cond = NULL;
        txt->skip = NULL;
 
-       tmp = concatstr(3, listdir, "/text/", filename);
-       txt->src->fd = open(tmp, O_RDONLY);
+       myasprintf(&tmp, "text/%s", filename);
+       txt->src->fd = openat(list->fd, tmp, O_RDONLY);
        myfree(tmp);
        if (txt->src->fd >= 0) return txt;
 
@@ -504,7 +504,7 @@ text *open_text_file(const char *listdir, const char *filename)
 }
 
 
-text *open_text(const char *listdir, const char *purpose, const char *action,
+text *open_text(struct mlmmj_list *list, const char *purpose, const char *action,
                   const char *reason, const char *type, const char *compat)
 {
        size_t filenamelen, len;
@@ -514,23 +514,23 @@ text *open_text(const char *listdir, const char *purpose, const char *action,
        filename = concatstr(7,purpose,"-",action,"-",reason,"-",type);
        filenamelen = strlen(filename);
        do {
-               if ((txt = open_text_file(listdir, filename)) != NULL) break;
+               if ((txt = open_text_file(list, filename)) != NULL) break;
                len = type ? strlen(type) : 0;
                filename[filenamelen-len-1] = '\0';
-               if ((txt = open_text_file(listdir, filename)) != NULL) break;
+               if ((txt = open_text_file(list, filename)) != NULL) break;
                filename[filenamelen-len-1] = '-';
                filenamelen -= len + 1;
                len = reason ? strlen(reason) : 0;
                filename[filenamelen-len-1] = '\0';
-               if ((txt = open_text_file(listdir, filename)) != NULL) break;
+               if ((txt = open_text_file(list, filename)) != NULL) break;
                filename[filenamelen-len-1] = '-';
                filenamelen -= len + 1;
                len = action ? strlen(action) : 0;
                filename[filenamelen-len-1] = '\0';
-               if ((txt = open_text_file(listdir, filename)) != NULL) break;
+               if ((txt = open_text_file(list, filename)) != NULL) break;
                filename[filenamelen-len-1] = '-';
                filenamelen -= len + 1;
-               if ((txt = open_text_file(listdir, compat)) != NULL) {
+               if ((txt = open_text_file(list, compat)) != NULL) {
                        myfree(filename);
                        filename = mystrdup(compat);
                        break;
index abdf895665966389a9190d9d4c405b0794b38a90..9a32b23cb702b26413368065a60222b84b816940 100644 (file)
@@ -277,7 +277,7 @@ int send_digest(struct mlmmj_list *list, int firstindex, int lastindex,
 
        boundary = random_str();
 
-       txt = open_text_file(list->dir, "digest");
+       txt = open_text_file(list, "digest");
        if (txt == NULL) {
                log_error(LOG_ARGS, "Could not open listtext 'digest'");
                goto fallback_subject;
index 75bf183607b8de6c777b56f0f833bf81b60ec946..13b21de964b6d2cd106471a3ea25003183e83a47 100644 (file)
@@ -170,7 +170,7 @@ void send_list(struct mlmmj_list *list, const char *emailaddr,
        myfree(digestdir);
        myfree(nomaildir);
 
-       txt = open_text(list->dir, "list", NULL, NULL, subtype_strs[SUB_ALL],
+       txt = open_text(list, "list", NULL, NULL, subtype_strs[SUB_ALL],
                        "listsubs");
        MY_ASSERT(txt);
        register_formatted(txt, "listsubs",