39 lines
945 B
Common Lisp
39 lines
945 B
Common Lisp
;;; util.lisp
|
|
|
|
(in-package :seanut)
|
|
|
|
(declaim (inline seanut-version))
|
|
|
|
(defun maybe-parse-integer (str)
|
|
(or (parse-integer str :junk-allowed t) -1))
|
|
|
|
(defun string-to-keyword (str)
|
|
(intern (string-upcase str) :keyword))
|
|
|
|
(defun validate-media-type (type)
|
|
(car (member type *valid-media-types* :test #'string=)))
|
|
|
|
(defun seanut-version ()
|
|
"gets the system version"
|
|
#.(asdf:component-version (asdf:find-system :seanut)))
|
|
|
|
(defun md5-string (str)
|
|
"returns the MD5 hash of STR"
|
|
(format nil "~{~X~}"
|
|
(coerce (digest-sequence 'ironclad:md5
|
|
(string-to-octets str))
|
|
'list)))
|
|
|
|
(defmacro quit-with-message (code message &rest args)
|
|
`(progn
|
|
(format t (str:concat ,message "~&") ,@args)
|
|
(uiop:quit ,code)))
|
|
|
|
(defmacro handle-user-abort (form &rest extra-cases)
|
|
`(handler-case
|
|
(with-user-abort ,form)
|
|
(user-abort () (uiop:quit 0))
|
|
,@extra-cases))
|
|
|
|
|