;; ;; mailman2.scm ;; ;; Mailman management interface - Mailman version 2.x support ;; ;; ISC License ;; ;; Copyright 2023 Brmlab, z.s. ;; Dominik Pantůček ;; ;; Permission to use, copy, modify, and/or distribute this software ;; for any purpose with or without fee is hereby granted, provided ;; that the above copyright notice and this permission notice appear ;; in all copies. ;; ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL ;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED ;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE ;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR ;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS ;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, ;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;; (declare (unit mailman2)) (module mailman2 ( list-mailman2-lists list-mailman2-list-members add-email-to-mailman2-list remove-email-from-mailman2-list ) (import scheme (chicken base) (chicken pathname) (chicken string) (chicken sort) (chicken format) srfi-1 util-bst-lset util-io mailman-common configuration) ;; Returns full path to given mailman binary (define (mailman-bin bin) (make-pathname (*mailman2-bin*) bin)) ;; Mailman-specific process output lines capture (define (get-mailman-output-lines bin . args) (apply get-process-output-lines (mailman-bin bin) args)) ;; Sends all lines to the process (define (mailman-send/recv bin args . lines) (apply process-send/recv (mailman-bin bin) args lines)) ;; Returns the list of available lists (define (list-mailman2-lists) (get-mailman-output-lines "list_lists" "-b")) ;; Returns the list of members of given list (define (list-mailman2-list-members lst) (sort (get-mailman-output-lines "list_members" lst) string-ci