From 4f839c094c0db0093405f23f73806a062cad302b Mon Sep 17 00:00:00 2001 From: Tom Balzer Date: Sun, 24 Jun 2018 05:40:57 -0500 Subject: [PATCH] Guile infrastructure for defining jobs in a manifest.scm config file --- guile/job.scm | 67 ++++++++++++++++++++++++++++++++++++++ guile/tomd.scm | 20 ++++++++++++ src/common/guile_helpers.c | 18 ++++++++++ src/tomd/init.c | 25 ++++++++++++++ src/tomd/manifest.c | 23 +++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 guile/job.scm create mode 100644 guile/tomd.scm create mode 100644 src/common/guile_helpers.c create mode 100644 src/tomd/init.c create mode 100644 src/tomd/manifest.c diff --git a/guile/job.scm b/guile/job.scm new file mode 100644 index 0000000..edbb4b0 --- /dev/null +++ b/guile/job.scm @@ -0,0 +1,67 @@ +;; Copyright (C) 2018 Thomas Balzer + +;; This file is part of tomd. + +;; tomd 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. + +;; tomd 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 tomd. If not, see . + +(define-module (tomd job) + #:use-module (srfi srfi-9) + #:export (create-job make-job + job-command-line + job-args + job-start-trigger + job-end-trigger)) + +;;; records +(define-record-type + (make-job command-line args start-trigger end-trigger) + job? + (command-line job-command-line) + (args job-args) + (start-trigger job-start-trigger) + (end-trigger job-end-trigger)) + +;;; functions +(define (get-keyword-value args keyword default) + (let ((keyword-value (memq keyword args))) + (if (and keyword-value (>= (length keyword-value) 2)) + (cadr keyword-value) + default))) + +(define (create-job . rest) + (let ((command-line (get-keyword-value rest #:command-line #f)) + (args (get-keyword-value rest #:args (list))) + (start-trigger (get-keyword-value rest #:start-trigger 'login)) + (end-trigger (get-keyword-value rest #:end-trigger #f))) + ;; do thing with keyword-ed variables + (display "settings:") (newline) + (format (current-output-port) + "command-line:~a" command-line) + (newline) + (format (current-output-port) + "args:~a" args) + (newline) + (format (current-output-port) + "start-trigger:~a" start-trigger) + (newline) + (format (current-output-port) + "end-trigger:~a" end-trigger) + (newline) + + ;; create a new object that represents the args given. + (make-job command-line + args + start-trigger + end-trigger) + )) diff --git a/guile/tomd.scm b/guile/tomd.scm new file mode 100644 index 0000000..e3948e2 --- /dev/null +++ b/guile/tomd.scm @@ -0,0 +1,20 @@ +;; Copyright (C) 2018 Thomas Balzer + +;; This file is part of tomd. + +;; tomd 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. + +;; tomd 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 tomd. If not, see . + +(define-module (tomd) + ;; #:use-modules (thing) + ) diff --git a/src/common/guile_helpers.c b/src/common/guile_helpers.c new file mode 100644 index 0000000..35bfd30 --- /dev/null +++ b/src/common/guile_helpers.c @@ -0,0 +1,18 @@ +/* Copyright (C) 2018 Thomas Balzer */ + +/* This file is part of tomd. */ + +/* tomd 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. */ + +/* tomd 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 tomd. If not, see . */ + +void load diff --git a/src/tomd/init.c b/src/tomd/init.c new file mode 100644 index 0000000..9e12975 --- /dev/null +++ b/src/tomd/init.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2018 Thomas Balzer */ + +/* This file is part of tomd. */ + +/* tomd 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. */ + +/* tomd 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 tomd. If not, see . */ + +#define DEFAULT_INIT_DIR "~/.config/tomd/init + +static void run_init(void) +{ + /* load all recognized files in the init directory */ + /* check for a manifest (defines run order) */ + /* loop through the manifest */ +} diff --git a/src/tomd/manifest.c b/src/tomd/manifest.c new file mode 100644 index 0000000..2c6c2f0 --- /dev/null +++ b/src/tomd/manifest.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2018 Thomas Balzer */ + +/* This file is part of tomd. */ + +/* tomd 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. */ + +/* tomd 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 tomd. If not, see . */ + + + +static void load_manifest(const char const *manifest_path) +{ + +} -- 2.20.1