| 1 |
(in-package #:cl-user) |
| 2 |
|
| 3 |
(defmacro define-function (name &body body) |
| 4 |
`(defun ,name (&aux |
| 5 |
(argc (si:argc)) |
| 6 |
(argv (ext:command-args))) |
| 7 |
(declare (ignorable argc argv)) |
| 8 |
,@body)) |
| 9 |
|
| 10 |
(define-function arg-test |
| 11 |
(if (= argc *args-number*) |
| 12 |
(quit 0) |
| 13 |
(quit 1))) |
| 14 |
|
| 15 |
(define-function print-test |
| 16 |
(terpri *standard-output*) |
| 17 |
(princ "Hello stdout" *standard-output*) |
| 18 |
(finish-output *standard-output*) |
| 19 |
(terpri *error-output*) |
| 20 |
(princ "Hello stderr" *error-output*) |
| 21 |
(finish-output *error-output*)) |
| 22 |
|
| 23 |
(define-function io/err |
| 24 |
(princ "Welcome to ITP(NR) - Intelligent Test Program (not really)!") |
| 25 |
(print argc *error-output*) |
| 26 |
|
| 27 |
(princ "Type your SEXP: ") |
| 28 |
(let ((result (read *standard-input* nil :eof))) |
| 29 |
(princ result *error-output*) |
| 30 |
(cond ((eq result :eof) |
| 31 |
(princ "No? Shame...") |
| 32 |
(quit 1)) |
| 33 |
(:otherwise |
| 34 |
"Thank you. Your wish has been heard loud and clear." |
| 35 |
(quit 0))))) |
| 36 |
|
| 37 |
(define-function terminate |
| 38 |
;; timeout is for case of zombies, this process should be killed |
| 39 |
;; from the outside. |
| 40 |
(sleep 10) |
| 41 |
(quit 0)) |
| 42 |
|
| 43 |
(define-function heartbeat |
| 44 |
(do () (nil) |
| 45 |
(print "heartbit") |
| 46 |
(sleep 1) |
| 47 |
(print "boombaya") |
| 48 |
(sleep 1))) |