From 995bc9ca6ebf6880d7e7e6f3d1baa2941758fc47 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 7 May 2016 11:09:44 +0200 Subject: all: Rename 'scm' directory to 'src'. * scm/mcron/config.scm.in: Rename to ... * src/mcron/config.scm.in: ... this. * scm/mcron/crontab.scm: Rename to ... * src/mcron/crontab.scm: ... this. * scm/mcron/environment.scm: Rename to ... * src/mcron/environment.scm: ... this. * scm/mcron/job-specifier.scm: Rename to ... * src/mcron/job-specifier.scm: ... this. * scm/mcron/main.scm: Rename to ... * src/mcron/main.scm: ... this. * scm/mcron/mcron-core.scm: Rename to ... * src/mcron/mcron-core.scm: ... this. * scm/mcron/redirect.scm: Rename to ... * src/mcron/redirect.scm: ... this. * scm/mcron/vixie-specification.scm: Rename to ... * src/mcron/vixie-specification.scm: ... this. * scm/mcron/vixie-time.scm: Rename to ... * src/mcron/vixie-time.scm: ... this. * mcron.c: Rename to ... * src/mcron.c: ... this. * Makefile.am: Adapt to them. * build-aux/pre-inst-env.in: Likewise. * configure.ac (AC_CONFIG_FILES): Likewise. (AC_CONFIG_HEADER): Set to 'src/config.h'. * .gitignore: Update. --- src/mcron/redirect.scm | 190 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 src/mcron/redirect.scm (limited to 'src/mcron/redirect.scm') diff --git a/src/mcron/redirect.scm b/src/mcron/redirect.scm new file mode 100644 index 0000000..af763cb --- /dev/null +++ b/src/mcron/redirect.scm @@ -0,0 +1,190 @@ +;; Copyright (C) 2003 Dale Mellor +;; +;; This file is part of GNU mcron. +;; +;; GNU mcron is free software: you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free +;; Software Foundation, either version 3 of the License, or (at your option) +;; any later version. +;; +;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +;; more details. +;; +;; You should have received a copy of the GNU General Public License along +;; with GNU mcron. If not, see . + + + +;; This module provides the (with-mail-out action . user) procedure. This +;; procedure runs the action in a child process, allowing the user control over +;; the input and output (including standard error). The input is governed (only +;; in the case of a string action) by the placing of percentage signs in the +;; string; the first delimits the true action from the standard input, and +;; subsequent ones denote newlines to be placed into the input. The output (if +;; there actually is any) is controlled by the MAILTO environment variable. If +;; this is not defined, output is e-mailed to the user passed as argument, if +;; any, or else the owner of the action; if defined but empty then any output is +;; sunk to /dev/null; otherwise output is e-mailed to the address held in the +;; MAILTO variable. + +(define-module (mcron redirect) + #:export (with-mail-out) + #:use-module (ice-9 regex) + #:use-module ((mcron config) :select (config-sendmail)) + #:use-module (mcron vixie-time)) + + + +;; An action string consists of a sequence of characters forming a command +;; executable by the shell, possibly followed by an non-escaped percentage +;; sign. The text after the percentage sign is to be fed to the command's +;; standard input, with further unescaped percents being substituted with +;; newlines. The escape character can itself be escaped. +;; +;; This regexp separates the two halves of the string, and indeed determines if +;; the second part is present. + +(define action-string-regexp (make-regexp "((\\\\%|[^%])*)%(.*)$")) + + + +;; This regexp identifies an escaped percentage sign. + +(define e-percent (make-regexp "\\\\%")) + + +;; Function to execute some action (this may be a shell command, lamdba function +;; or list of scheme procedures) in a forked process, with the input coming from +;; the string, and output (including the error output) being sent to a pipe +;; opened on a mail transport. + +(use-modules (ice-9 popen)) + +(define (with-mail-out action . user) + + ;; Determine the name of the user who is to recieve the mail, looking for a + ;; name in the optional user argument, then in the MAILTO environment + ;; variable, and finally in the LOGNAME environment variable. (The case + ;; MAILTO="" is dealt with specially below.) + + (let* ((mailto (getenv "MAILTO")) + (user (cond (mailto mailto) + ((not (null? user)) (car user)) + (else (getenv "LOGNAME")))) + (parent->child (pipe)) + (child->parent (pipe)) + (child-pid (primitive-fork))) + + + ;; The child process. Close redundant ends of pipes, remap the standard + ;; streams, and run the action, taking care to chop off the input part of an + ;; action string. + + (if (eqv? child-pid 0) + (begin + (close (cdr parent->child)) + (close (car child->parent)) + + (dup2 (port->fdes (car parent->child)) 0) + (close (car parent->child)) + (dup2 (port->fdes (cdr child->parent)) 1) + (close (cdr child->parent)) + (dup2 1 2) + + (cond ((string? action) + (let ((match (regexp-exec action-string-regexp action))) + (system (if match + (let ((action (match:substring match 1))) + (do ((match (regexp-exec e-percent action) + (regexp-exec e-percent action))) + ((not match)) + (set! action (string-append + (match:prefix match) + "%" + (match:suffix match)))) + action) + action)))) + + ((procedure? action) (action)) + ((list? action) (primitive-eval action))) + + (primitive-exit 0))) + + + ;; The parent process. Get rid of redundant pipe ends. + + (close (car parent->child)) + (close (cdr child->parent)) + + + ;; Put stuff to child from after '%' in command line, replacing + ;; other %'s with newlines. Ugly or what? + + (if (string? action) + (let ((port (cdr parent->child)) + (match (regexp-exec action-string-regexp action))) + (if (and match + (match:substring match 3)) + (with-input-from-string (match:substring match 3) + (lambda () + (let loop () + (let ((next-char (read-char))) + (if (not (eof-object? next-char)) + (cond + ((char=? next-char #\%) + (newline port) + (loop)) + ((char=? next-char #\\) + (let ((escape (read-char))) + (if (eof-object? escape) + (display #\\ port) + (if (char=? escape #\%) + (begin + (display #\% port) + (loop)) + (begin + (display #\\ port) + (display escape port) + (loop)))))) + (else + (display next-char port) + (loop))))))))))) + + + ;; So the child process doesn't hang on to its input expecting more stuff. + + (close (cdr parent->child)) + + + ;; That's got streaming into the child's input out of the way, now we stream + ;; the child's output to a mail sink, but only if there is something there + ;; in the first place. + + (if (eof-object? (peek-char (car child->parent))) + + (read-char (car child->parent)) + + (begin + (set-current-output-port (if (and (string? mailto) + (string=? mailto "")) + (open-output-file "/dev/null") + (open-output-pipe + (string-append config-sendmail + " " + user)))) + (set-current-input-port (car child->parent)) + (display "To: ") (display user) (newline) + (display "From: mcron") (newline) + (display (string-append "Subject: " user "@" (gethostname))) + (newline) + (newline) + + (do ((next-char (read-char) (read-char))) + ((eof-object? next-char)) + (display next-char)))) + + (close (car child->parent)) + + (waitpid child-pid))) -- cgit v1.2.3 From 2cdd544a56e4b340f1744cfe2ab6439aa815045c Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Mon, 18 Jul 2016 17:25:27 +0200 Subject: maint: Reformat copyright notices and copying permission statements. --- Makefile.am | 13 ++++---- configure.ac | 41 ++++++++++++------------- src/mcron/base.scm | 39 ++++++++++++------------ src/mcron/config.scm.in | 40 +++++++++++------------- src/mcron/environment.scm | 64 +++++++++++++++++++-------------------- src/mcron/job-specifier.scm | 50 +++++++++++++++--------------- src/mcron/main.scm | 35 ++++++++++----------- src/mcron/redirect.scm | 63 ++++++++++++++++++++------------------ src/mcron/vixie-specification.scm | 51 ++++++++++++++++--------------- src/mcron/vixie-time.scm | 33 ++++++++++---------- src/wrapper.c | 4 +-- 11 files changed, 218 insertions(+), 215 deletions(-) (limited to 'src/mcron/redirect.scm') diff --git a/Makefile.am b/Makefile.am index 61f1c7b..52a8499 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,20 +1,21 @@ ## Process this file with automake to produce Makefile.in. - -# Copyright (C) 2003 Dale Mellor -# Copyright (C) 2015, 2016 Mathieu Lirzin +# Copyright © 2003 Dale Mellor +# Copyright © 2015, 2016 Mathieu Lirzin +# +# This file is part of GNU Mcron. # -# This program is free software: you can redistribute it and/or modify +# GNU Mcron is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, +# GNU Mcron is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with GNU Mcron. If not, see . bin_PROGRAMS = mcron crontab sbin_PROGRAMS = cron diff --git a/configure.ac b/configure.ac index 5b2fcf6..97c900b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,25 +1,22 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - - -# Copyright (C) 2003, 2005, 2012, 2014 Dale Mellor -# Copyright (C) 2015, 2016 Mathieu Lirzin -# -# This file is part of GNU mcron. -# -# GNU mcron is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) -# any later version. -# -# GNU mcron is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with GNU mcron. If not, see . - +## Process this file with autoconf to produce a configure script. +# Copyright © 2003, 2005, 2012, 2014 Dale Mellor +# +# Copyright © 2015, 2016 Mathieu Lirzin +# +# This file is part of GNU Mcron. +# +# GNU Mcron is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU Mcron is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Mcron. If not, see . AC_PREREQ(2.61) AC_INIT([GNU Mcron], [1.0.8], [bug-mcron@gnu.org]) diff --git a/src/mcron/base.scm b/src/mcron/base.scm index b779c8a..b607c05 100644 --- a/src/mcron/base.scm +++ b/src/mcron/base.scm @@ -1,23 +1,22 @@ -;; Copyright (C) 2016 Ludovic Courtès -;; Copyright (C) 2015, 2016 Mathieu Lirzin -;; Copyright (C) 2003 Dale Mellor -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . - - +;;;; base.scm -- core procedures +;;; Copyright © 2003 Dale Mellor +;;; Copyright © 2015, 2016 Mathieu Lirzin +;;; Copyright © 2016 Ludovic Courtès +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . (define-module (mcron base) #:use-module (ice-9 match) diff --git a/src/mcron/config.scm.in b/src/mcron/config.scm.in index db2bc32..2b0bc7f 100644 --- a/src/mcron/config.scm.in +++ b/src/mcron/config.scm.in @@ -1,25 +1,21 @@ -;; -*-scheme-*- - -;; Copyright (C) 2015 Mathieu Lirzin -;; Copyright (C) 2003 Dale Mellor -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . - - -;; Some constants set by the configuration process. +;;;; config.scm -- variables defined at configure time +;;; Copyright © 2003 Dale Mellor +;;; Copyright © 2015, 2016 Mathieu Lirzin +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . (define-module (mcron config)) diff --git a/src/mcron/environment.scm b/src/mcron/environment.scm index b563d55..f6b9637 100644 --- a/src/mcron/environment.scm +++ b/src/mcron/environment.scm @@ -1,35 +1,35 @@ -;; Copyright (C) 2015, 2016 Mathieu Lirzin -;; Copyright (C) 2003 Dale Mellor -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . - - - -;; This file defines the variable current-environment-mods, and the procedures -;; append-environment-mods (which is available to user configuration files), -;; clear-environment-mods and modify-environment. The idea is that the -;; current-environment-mods is a list of pairs of environment names and values, -;; and represents the cumulated environment settings in a configuration -;; file. When a job definition is seen in a configuration file, the -;; current-environment-mods are copied into the internal job description, and -;; when the job actually runs these environment modifications are applied to -;; the UNIX environment in which the job runs. - - - +;;;; environment.scm -- interact with the job process environment +;;; Copyright © 2003 Dale Mellor +;;; Copyright © 2015, 2016 Mathieu Lirzin +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . + +;;;; Commentary: +;;; +;;; Define the variable current-environment-mods, and the procedures +;;; append-environment-mods (which is available to user configuration files), +;;; clear-environment-mods and modify-environment. The idea is that the +;;; current-environment-mods is a list of pairs of environment names and +;;; values, and represents the cumulated environment settings in a +;;; configuration file. When a job definition is seen in a configuration file, +;;; the current-environment-mods are copied into the internal job description, +;;; and when the job actually runs these environment modifications are applied +;;; to the UNIX environment in which the job runs. +;;; +;;;; Code: (define-module (mcron environment) #:export (modify-environment diff --git a/src/mcron/job-specifier.scm b/src/mcron/job-specifier.scm index 5d60484..d4c05bd 100644 --- a/src/mcron/job-specifier.scm +++ b/src/mcron/job-specifier.scm @@ -1,28 +1,30 @@ -;; Copyright (C) 2003 Dale Mellor -;; Copyright (C) 2016 Mathieu Lirzin -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . - - +;;;; job-specifier.scm -- public interface for defining jobs +;;; Copyright © 2003 Dale Mellor +;;; Copyright © 2016 Mathieu Lirzin +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . -;; This module defines all the functions that can be used by scheme mcron -;; configuration files, namely the procedures for working out next times, the -;; job procedure for registering new jobs (actually a wrapper around the -;; base add-job function), and the procedure for declaring environment -;; modifications. +;;;; Commentary: +;;; +;;; Define all the functions that can be used by scheme Mcron configuration +;;; files, namely the procedures for working out next times, the job procedure +;;; for registering new jobs (actually a wrapper around the base add-job +;;; function), and the procedure for declaring environment modifications. +;;; +;;;; Code: (define-module (mcron job-specifier) #:use-module (ice-9 match) diff --git a/src/mcron/main.scm b/src/mcron/main.scm index 1faa1ae..74b49e5 100644 --- a/src/mcron/main.scm +++ b/src/mcron/main.scm @@ -1,20 +1,21 @@ -;; Copyright (C) 2015, 2016 Mathieu Lirzin -;; Copyright (C) 2003, 2012 Dale Mellor -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . +;;; main.scm -- helper procedures +;;; Copyright © 2003, 2012 Dale Mellor +;;; Copyright © 2015, 2016 Mathieu Lirzin +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . (define-module (mcron main) #:use-module (ice-9 getopt-long) diff --git a/src/mcron/redirect.scm b/src/mcron/redirect.scm index af763cb..7474c4a 100644 --- a/src/mcron/redirect.scm +++ b/src/mcron/redirect.scm @@ -1,33 +1,36 @@ -;; Copyright (C) 2003 Dale Mellor -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . - - - -;; This module provides the (with-mail-out action . user) procedure. This -;; procedure runs the action in a child process, allowing the user control over -;; the input and output (including standard error). The input is governed (only -;; in the case of a string action) by the placing of percentage signs in the -;; string; the first delimits the true action from the standard input, and -;; subsequent ones denote newlines to be placed into the input. The output (if -;; there actually is any) is controlled by the MAILTO environment variable. If -;; this is not defined, output is e-mailed to the user passed as argument, if -;; any, or else the owner of the action; if defined but empty then any output is -;; sunk to /dev/null; otherwise output is e-mailed to the address held in the -;; MAILTO variable. +;;;; redirect.scm -- modify job outputs +;;; Copyright © 2003 Dale Mellor +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . + +;;;; Commentary: +;;; +;;; Provide the (with-mail-out action . user) procedure. This procedure runs +;;; the action in a child process, allowing the user control over the input +;;; and output (including standard error). The input is governed (only in the +;;; case of a string action) by the placing of percentage signs in the string; +;;; the first delimits the true action from the standard input, and subsequent +;;; ones denote newlines to be placed into the input. The output (if there +;;; actually is any) is controlled by the MAILTO environment variable. If +;;; this is not defined, output is e-mailed to the user passed as argument, if +;;; any, or else the owner of the action; if defined but empty then any output +;;; is sunk to /dev/null; otherwise output is e-mailed to the address held in +;;; the MAILTO variable. +;;; +;;;; Code: (define-module (mcron redirect) #:export (with-mail-out) diff --git a/src/mcron/vixie-specification.scm b/src/mcron/vixie-specification.scm index f055383..4356db7 100644 --- a/src/mcron/vixie-specification.scm +++ b/src/mcron/vixie-specification.scm @@ -1,27 +1,30 @@ -;; Copyright (C) 2003 Dale Mellor -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . - - - -;; This file provides methods for reading a complete Vixie-style configuration -;; file, either from a real file or an already opened port. It also exposes the -;; method for parsing the time-specification part of a Vixie string, so that -;; these can be used to form the next-time-function of a job in a Guile -;; configuration file. +;;;; vixie-specification.scm -- read Vixie-sytle configuration file +;;; Copyright © 2003 Dale Mellor +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . + +;;;; Commentary: +;;; +;;; Methods for reading a complete Vixie-style configuration file, either from +;;; a real file or an already opened port. It also exposes the method for +;;; parsing the time-specification part of a Vixie string, so that these can +;;; be used to form the next-time-function of a job in a Guile configuration +;;; file. +;;; +;;;; Code: (define-module (mcron vixie-specification) #:export (parse-user-vixie-line diff --git a/src/mcron/vixie-time.scm b/src/mcron/vixie-time.scm index a91fa89..f734600 100644 --- a/src/mcron/vixie-time.scm +++ b/src/mcron/vixie-time.scm @@ -1,19 +1,20 @@ -;; Copyright (C) 2003 Dale Mellor -;; -;; This file is part of GNU mcron. -;; -;; GNU mcron is free software: you can redistribute it and/or modify it under -;; the terms of the GNU General Public License as published by the Free -;; Software Foundation, either version 3 of the License, or (at your option) -;; any later version. -;; -;; GNU mcron is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -;; more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with GNU mcron. If not, see . +;;;; vixie-time.scm -- parse Vixie-style times +;;; Copyright © 2003 Dale Mellor +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . (define-module (mcron vixie-time) #:use-module (ice-9 regex) diff --git a/src/wrapper.c b/src/wrapper.c index a5b46db..bb7932e 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -1,6 +1,6 @@ /* wrapper.c -- C code booting Guile - Copyright (C) 2003, 2014 Dale Mellor - Copyright (C) 2015, 2016 Mathieu Lirzin + Copyright © 2003, 2014 Dale Mellor + Copyright © 2015, 2016 Mathieu Lirzin This file is part of GNU Mcron. -- cgit v1.2.3 From 4d518fd3f114a397fe6a3380513409293a721ab8 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sun, 24 Jul 2016 01:05:29 +0200 Subject: all: Gather module imports. * src/mcron/base.scm: Gather module imports. * src/mcron/redirect.scm: Likewise. * src/mcron/vixie-specification.scm: Likewise. * src/mcron/vixie-time.scm: Likewise. --- src/mcron/base.scm | 28 ++++++++++++---------------- src/mcron/redirect.scm | 11 ++++------- src/mcron/vixie-specification.scm | 22 ++++++++++------------ src/mcron/vixie-time.scm | 2 -- 4 files changed, 26 insertions(+), 37 deletions(-) (limited to 'src/mcron/redirect.scm') diff --git a/src/mcron/base.scm b/src/mcron/base.scm index b607c05..a133f66 100644 --- a/src/mcron/base.scm +++ b/src/mcron/base.scm @@ -21,23 +21,19 @@ (define-module (mcron base) #:use-module (ice-9 match) #:use-module (mcron environment) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-2) #:use-module (srfi srfi-9) - #:export (add-job - remove-user-jobs - get-schedule - run-job-loop - ;; These three are deprecated and not documented. - use-system-job-list - use-user-job-list - clear-system-jobs) - #:re-export (clear-environment-mods - append-environment-mods)) - - -(use-modules (srfi srfi-1) ;; For remove. - (srfi srfi-2)) ;; For and-let*. - - + #:export (add-job + remove-user-jobs + get-schedule + run-job-loop + ;; Deprecated and undocumented procedures. + use-system-job-list + use-user-job-list + clear-system-jobs) + #:re-export (clear-environment-mods + append-environment-mods)) ;; The list of all jobs known to the system. Each element of the list is ;; diff --git a/src/mcron/redirect.scm b/src/mcron/redirect.scm index 7474c4a..6711407 100644 --- a/src/mcron/redirect.scm +++ b/src/mcron/redirect.scm @@ -33,12 +33,11 @@ ;;;; Code: (define-module (mcron redirect) - #:export (with-mail-out) + #:use-module (ice-9 popen) #:use-module (ice-9 regex) - #:use-module ((mcron config) :select (config-sendmail)) - #:use-module (mcron vixie-time)) - - + #:use-module (mcron config) + #:use-module (mcron vixie-time) + #:export (with-mail-out)) ;; An action string consists of a sequence of characters forming a command ;; executable by the shell, possibly followed by an non-escaped percentage @@ -63,8 +62,6 @@ ;; the string, and output (including the error output) being sent to a pipe ;; opened on a mail transport. -(use-modules (ice-9 popen)) - (define (with-mail-out action . user) ;; Determine the name of the user who is to recieve the mail, looking for a diff --git a/src/mcron/vixie-specification.scm b/src/mcron/vixie-specification.scm index 4356db7..e040fe0 100644 --- a/src/mcron/vixie-specification.scm +++ b/src/mcron/vixie-specification.scm @@ -27,22 +27,20 @@ ;;;; Code: (define-module (mcron vixie-specification) + #:use-module (ice-9 regex) + #:use-module (ice-9 rdelim) + #:use-module (mcron base) + #:use-module (mcron config) + #:use-module (mcron job-specifier) + #:use-module (mcron redirect) + #:use-module (mcron vixie-time) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-2) #:export (parse-user-vixie-line parse-system-vixie-line read-vixie-port read-vixie-file - check-system-crontab) - #:use-module ((mcron config) :select (config-socket-file)) - #:use-module (mcron base) - #:use-module (mcron job-specifier) - #:use-module (mcron redirect) - #:use-module (mcron vixie-time)) - - -(use-modules (ice-9 regex) (ice-9 rdelim) - (srfi srfi-1) (srfi srfi-2) (srfi srfi-13) (srfi srfi-14)) - - + check-system-crontab)) ;; A line in a Vixie-style crontab file which gives a command specification ;; carries two pieces of information: a time specification consisting of five diff --git a/src/mcron/vixie-time.scm b/src/mcron/vixie-time.scm index f734600..c4d6bd9 100644 --- a/src/mcron/vixie-time.scm +++ b/src/mcron/vixie-time.scm @@ -20,8 +20,6 @@ #:use-module (ice-9 regex) #:use-module (mcron job-specifier) #:use-module (srfi srfi-1) - #:use-module (srfi srfi-13) - #:use-module (srfi srfi-14) #:export (parse-vixie-time)) ;; In Vixie-style time specifications three-letter symbols are allowed to stand -- cgit v1.2.3