Guile infrastructure for defining jobs in a manifest.scm config file
authorTom Balzer <niebie@localhost.localdomain>
Sun, 24 Jun 2018 10:40:57 +0000 (05:40 -0500)
committerTom Balzer <niebie@localhost.localdomain>
Sun, 24 Jun 2018 10:40:57 +0000 (05:40 -0500)
guile/job.scm [new file with mode: 0644]
guile/tomd.scm [new file with mode: 0644]
src/common/guile_helpers.c [new file with mode: 0644]
src/tomd/init.c [new file with mode: 0644]
src/tomd/manifest.c [new file with mode: 0644]

diff --git a/guile/job.scm b/guile/job.scm
new file mode 100644 (file)
index 0000000..edbb4b0
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+(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 <job>
+  (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 (file)
index 0000000..e3948e2
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+(define-module (tomd)
+  ;; #:use-modules (thing)
+  )
diff --git a/src/common/guile_helpers.c b/src/common/guile_helpers.c
new file mode 100644 (file)
index 0000000..35bfd30
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>. */
+
+void load
diff --git a/src/tomd/init.c b/src/tomd/init.c
new file mode 100644 (file)
index 0000000..9e12975
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>. */
+
+#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 (file)
index 0000000..2c6c2f0
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>. */
+
+
+
+static void load_manifest(const char const *manifest_path)
+{
+  
+}