id
int64 0
45.1k
| file_name
stringlengths 4
68
| file_path
stringlengths 14
193
| content
stringlengths 32
9.62M
| size
int64 32
9.62M
| language
stringclasses 1
value | extension
stringclasses 6
values | total_lines
int64 1
136k
| avg_line_length
float64 3
903k
| max_line_length
int64 3
4.51M
| alphanum_fraction
float64 0
1
| repo_name
stringclasses 779
values | repo_stars
int64 0
882
| repo_forks
int64 0
108
| repo_open_issues
int64 0
90
| repo_license
stringclasses 8
values | repo_extraction_date
stringclasses 146
values | sha
stringlengths 64
64
| __index_level_0__
int64 0
45.1k
| exdup_ids_cmlisp_stkv2
sequencelengths 1
47
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
16,457 | cl-pjsip.asd | varjagg_cl-pjsip/cl-pjsip.asd | ;;;; cl-pjsip.asd
(asdf:defsystem #:cl-pjsip
:description "Common Lisp wrapper for PJSIP library"
:author "Eugene Zaikonnikov <[email protected]>"
:license "GPL v2"
:version "0.4"
:depends-on (#:cffi #:cffi-libffi)
:serial t
:components ((:file "package")
(:file "cl-pjsip")
(:file "media-ports")
(:file "cl-pjsua")))
| 366 | Common Lisp | .asd | 12 | 25.583333 | 54 | 0.625 | varjagg/cl-pjsip | 4 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | ae73fd7ce2269f86ced6eedea79ced97871bd42d9d6671c69efb5a653d997959 | 16,457 | [
-1
] |
16,458 | cl-pjsip-ua.asd | varjagg_cl-pjsip/cl-pjsip-ua.asd | ;;;; cl-pjsip-ua.asd
(asdf:defsystem #:cl-pjsip-ua
:description "A simple SIP UA using CL-PJSIP library"
:author "Eugene Zaikonnikov <[email protected]>"
:license "GPL v2"
:depends-on (#:cl-pjsip)
:serial t
:components ((:file "cl-pjsip-ua")))
| 259 | Common Lisp | .asd | 8 | 29.625 | 55 | 0.694779 | varjagg/cl-pjsip | 4 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 6cb2a1e7fd0318f88631480e12ac4e48bd86dfe9e727b778891147a43b7ab864 | 16,458 | [
-1
] |
16,459 | cl-pjsua-demo.asd | varjagg_cl-pjsip/cl-pjsua-demo.asd | ;;;; cl-pjsua-demo.asd
(asdf:defsystem #:cl-pjsua-demo
:description "A simple PJSUA based demo using CL-PJSIP library"
:author "Eugene Zaikonnikov <[email protected]>"
:license "GPL v2"
:version "0.1"
:depends-on (#:cl-pjsip)
:serial t
:components ((:file "cl-pjsua-demo")))
| 292 | Common Lisp | .asd | 9 | 29.666667 | 65 | 0.701068 | varjagg/cl-pjsip | 4 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | f1a296bfa0e3df368750b084671a881a178c45c2f6bd6e6fd15057efcb8485bf | 16,459 | [
-1
] |
16,484 | jsd-st-json.lisp | RDProjekt_cl-json-ld/src/jsd-st-json.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-json-ld-jsd)
(defgeneric convert-to-jsd (value))
(defmethod convert-to-jsd ((value st-json:jso))
(let ((res (make-string-hashtable)))
(st-json:mapjso #'(lambda (k v)
(setf (gethash k res) (convert-to-jsd v)))
value)
res))
(defmethod convert-to-jsd ((value cons))
(mapcar #'(lambda (item)
(convert-to-jsd item))
value))
(defmethod convert-to-jsd ((value t))
value)
(defun jsd-read (source)
(convert-to-jsd (st-json:read-json source)))
(defun jsd-make (&rest args)
(convert-to-jsd (apply #'st-json:jso args)))
(defmethod write-json-element ((element hash-table) stream)
(write-json-element (st-json::make-jso :alist (hash-table-alist element)) stream))
(defun jsd-to-string (element)
"Write a value's JSON representation to a string."
(st-json:write-json-to-string element))
(defconstant +jsd-null+ :null)
(defconstant +jsd-true+ :true)
(defconstant +jsd-false+ :false)
(defun jsd-bool-p (value)
(typep value 'st-json:json-bool)) | 1,871 | Common Lisp | .lisp | 46 | 37.630435 | 84 | 0.687603 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 3701837671cd19b8a8a7761ecdd9e1985ca93511249348475c7c3320ad398437 | 16,484 | [
-1
] |
16,485 | package.lisp | RDProjekt_cl-json-ld/src/package.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(defpackage :cl-json-ld-sha1
(:use cl)
(:export
:make-sha1-digester
:sha1-hash-strings
:digester-add-string
:digester-hexdigest))
(defpackage :cl-json-ld-utils
(:use :cl :alexandria :split-sequence)
(:export
:starts-with-p
:ends-with-p
:objs-equal-p
:deepcopy
:sorted-maphash
:camel-case->symbol
:make-string-hashtable
:normpath))
(defpackage :cl-json-ld-jsd
(:use :cl :cl-json-ld-utils :alexandria)
(:export
:jsd-json
:jsd-read
:jsd-make
:jsd-get
:is-object
:is-empty-object
:jsd-map
:jsd-sorted-map
:jsd-copied-map
:jsd-to-string
:jsd-count
:jsd-when-get
:jsd-getdefault
:jsd-setdefault
:jsd-haskey
:jsd-remove
:jsd-bool-p
:+jsd-null+
:+jsd-true+
:+jsd-false+
:multi-jsd-get
:jsd-sorted-keys))
(defpackage :cl-json-ld
(:use :cl :puri :cl-ppcre :cl-json-ld-utils :cl-json-ld-jsd :cl-json-ld-sha1)
(:export
:from-rdf
:to-rdf
:expand
:compact
:flatten
:normalize
:frame
:json-ld-error
:json-ld-error-code
:get-document-loader
:set-document-loader
:json-ld-processor
:processor-from-rdf
:register-rdf-parser
:processor-register-rdf-parser
:jsd-read
:jsd-to-string
:jsd-make))
| 2,084 | Common Lisp | .lisp | 82 | 22.256098 | 79 | 0.683525 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 1f033afb0c5fb75acd24f429b32e7b71dafce2d95ba910cce761bfe38bdc30c9 | 16,485 | [
-1
] |
16,486 | package-tests.lisp | RDProjekt_cl-json-ld/src/package-tests.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(defpackage :cl-json-ld-tests
(:use
:cl
:cl-json-ld-jsd
:cl-json-ld
:cl-json-ld-utils
:cl-fad
:fiveam)
(:export
:run-unit-tests)) | 989 | Common Lisp | .lisp | 28 | 33.392857 | 73 | 0.691988 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 5df031c03811132fbd39847ab358b6b4fa053c551bc7c0dc87fee18aa098fde2 | 16,486 | [
-1
] |
16,487 | flatten.lisp | RDProjekt_cl-json-ld/src/flatten.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-json-ld)
(defun flatten (input ctx &optional (options nil))
"Perform JSON-LD flattening.
Converted from pyld's flatten function."
(plist-setdefault options :base (if (stringp input) input ""))
(plist-setdefault options :document-loader *default-document-loader*)
;; Expand input
(let* ((expanded (handler-bind
((error #'(lambda (cause)
(error 'json-ld-error
:message "Could not expand input before flattening."
:cause cause))))
(expand input options)))
;; Do flattening
(flattened (internal-flatten expanded)))
(unless ctx
(return-from flatten flattened))
;; Compact result (force @graph option to true, skip expansion)
(setf (getf options :graph) t
(getf options :skip-expansion) t)
(handler-case
(compact flattened ctx options)
(error (cause)
(error 'json-ld-error
:message "Could not compact flattened output."
:cause cause)))))
(defun internal-flatten (input)
"Perform JSON-LD flattening.
Converted from pyld's JsonLdProcessor._flatten method."
;; Produce a map of all subjects and name each bnode
(let ((namer (make-namer))
(graphs (jsd-make +default-graph-name+ (jsd-make))))
(create-node-map input graphs +default-graph-name+ namer)
;; Add all non-default graphs to default graph
(let ((default-graph (jsd-get +default-graph-name+ graphs)))
(flet ((process-graph (graph-name node-map)
(when (equal graph-name +default-graph-name+)
(return-from process-graph))
(let ((graph-subject (jsd-setdefault default-graph graph-name
(jsd-make +id-key+ graph-name
+graph-key+ '()))))
(setf (jsd-get +graph-key+ graph-subject)
(append (jsd-getdefault +graph-key+ graph-subject '())
(collect-graph-nodes node-map))))))
(jsd-map #'process-graph graphs))
;; Produce flattened output
(collect-graph-nodes default-graph))))
(defun collect-graph-nodes (graph)
"Return nodes from graph that are not subject references."
(let ((result '()))
(jsd-sorted-map #'(lambda (key value)
(declare (ignore key))
(unless (is-subject-reference value)
(push value result))) graph)
(nreverse result))) | 3,497 | Common Lisp | .lisp | 73 | 37.671233 | 88 | 0.60355 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 60ace1a1bfd297a27dbd731b2456ad92f9a80fc0013a652101c7752e52a3a3a6 | 16,487 | [
-1
] |
16,488 | sha1.lisp | RDProjekt_cl-json-ld/src/sha1.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-json-ld-sha1)
;;; OpenSSL library calls.
(defparameter *use-open-ssl* nil)
#+allegro
(progn
(let ((ssl-lib-filename
#+os-windows "libeay32.dll"
#+(or os-unix unix) "/lib/i386-linux-gnu/libssl.so.1.0.0"
#-(or os-windows os-unix unix) nil))
(when ssl-lib-filename
(handler-case
(progn
(load ssl-lib-filename :foreign t)
(setf *use-open-ssl* t))
(error ()
(format t "Could not load SSL library from: ~a - using ironclad instead." ssl-lib-filename))))))
(defparameter *evp-sha1* nil)
(if *use-open-ssl*
#+allegro (progn
(ff:def-foreign-call
(evp-md-ctx-create "EVP_MD_CTX_create")
(:void)
:returning :foreign-address)
(ff:def-foreign-call
(evp-sha1 "EVP_sha1") (:void) :returning (:int))
(ff:def-foreign-call
(evp-digest-init "EVP_DigestInit")
((ctx :foreign-address) (type :int)))
(ff:def-foreign-call
(evp-digest-update "EVP_DigestUpdate")
((ctx :foreign-address) (d (* :char) (simple-array (unsigned-byte 8) (*))) (len :int))
:strings-convert nil)
(ff:def-foreign-call
(evp-digest-final "EVP_DigestFinal_ex")
((ctx :foreign-address) (md (* :char) (simple-array (unsigned-byte 8) (*)))
(s :int (simple-array '(signed-byte 32) (1))))
:strings-convert nil)
(ff:def-foreign-call
(evp-md-ctx-destroy "EVP_MD_CTX_destroy")
((ctx :foreign-address)))
;;; Internal class for keeping digest context.
(setf *evp-sha1* (evp-sha1))
(defclass sha1-digester ()
((ctx)))
(defmethod initialize-instance :after ((digester sha1-digester) &key)
(with-slots (ctx) digester
(setf ctx (evp-md-ctx-create))
(evp-digest-init ctx *evp-sha1*)))
;;; public API
(defun make-sha1-digester ()
(make-instance 'sha1-digester))
(defun sha1-hash-strings (strings)
"Hash a list of strings and return a string representation of the hash."
(let ((digester (make-sha1-digester)))
(loop for string in strings do
(digester-add-string digester string))
(digester-hexdigest digester)))
(defun digester-add-string (digester string)
"Update digester with a given string."
(let ((octets (flexi-streams:string-to-octets string)))
(evp-digest-update (slot-value digester 'ctx) octets (length octets))))
(defun digester-hexdigest (digester)
"Return a string representation of the digester's hash. Modifies digester!"
(with-slots (ctx) digester
(let ((buffer (make-array 64 :element-type '(unsigned-byte 8)))
(s (make-array 1 :element-type '(signed-byte 32) :initial-element 64)))
(evp-digest-final ctx buffer s)
(prog1
(crypto:byte-array-to-hex-string (subseq buffer 0 (elt s 0)))
(evp-md-ctx-destroy ctx))))))
#-allegro (error "OpenSSL libraries implemented only for Allegro.")
;; else (not *use-open-ssl*)
(progn
(defun make-sha1-digester ()
(crypto:make-digest :sha1))
(defun sha1-hash-strings (strings)
"Hash a list of strings and return a string representation of the hash."
(let ((digester (crypto:make-digest :sha1)))
(loop for string in strings do
(digester-add-string digester string))
(digester-hexdigest digester)))
(defun digester-add-string (digester string)
"Update digester with a given string."
(crypto:update-digest digester (flexi-streams:string-to-octets string)))
(defun digester-hexdigest (digester)
"Return a string representation of the digester's hash. Modifies digester!"
(crypto:byte-array-to-hex-string (crypto:produce-digest digester)))))
| 4,664 | Common Lisp | .lisp | 105 | 37.72381 | 106 | 0.649111 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | bf3133efae5c75d774166ee1bdfc36579f4d0f7d9d315ff219b97d56960d8644 | 16,488 | [
-1
] |
16,489 | jsd-hashmap.lisp | RDProjekt_cl-json-ld/src/jsd-hashmap.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
;;;; abstractions for manipulating json objects
(in-package :cl-json-ld-jsd)
(defun is-object (value)
"Return T iff given value is an Object."
(typep value 'hash-table))
(defun is-empty-object (value)
"Return T iff given value is an empty Object."
(and (is-object value)
(eq 0 (hash-table-count value))))
;;;; deepcopy
(defmethod cl-json-ld-utils:deepcopy ((element hash-table))
(let ((res (make-string-hashtable)))
(maphash #'(lambda (k v) (setf (gethash k res) (deepcopy v))) element)
res))
;;;; objs-equal-p
(defun cdr-assoc (key list &rest rest)
(let ((kv (apply #'assoc key list rest)))
(if kv (cdr kv) nil)))
(defmethod objs-equal-p ((tab1 hash-table) (tab2 hash-table))
(if (eql (hash-table-count tab1) (hash-table-count tab2))
(progn
(loop for key being the hash-keys of tab1 using (hash-value val1) do
(cl-json-ld-utils::propagate-negative-result val1 (gethash key tab2) objs-equal-p))
(return-from objs-equal-p t))
(cl-json-ld-utils::lazy-message-eq nil "Different object lengths ~s != ~s" tab1 tab2)))
(defun jsd-get (key jsd)
"Fetch a value from a JS object. Returns a second value like
gethash."
(gethash key jsd))
(defun (setf jsd-get) (val key jsd)
"Store a value in a JS object."
(setf (gethash key jsd) val))
(defun jsd-count (jsd)
"Return the number of items (unique keys) in the JSD."
(hash-table-count jsd))
(defun jsd-map (func jsd)
"Iterate over the key/value pairs in a JS object."
(maphash func jsd))
(defun jsd-sorted-map (func jsd &key (test #'string<))
"Iterate over the key/value pairs in JSD, in order of sorted keys."
(sorted-maphash func jsd :test test))
(defun jsd-copied-map (func jsd)
"Iterate over key/value pairs in JSD, copying the JSD beforehand,
so that the code in func can manipulate the map."
(let ((items (hash-table-alist jsd)))
(loop for (key . value) in items do
(funcall func key value))))
;;;;
;;;; JSON HELPER FUNCTIONS
;;;;
(defun jsd-haskey (key jsd)
(multiple-value-bind (x present-p) (jsd-get key jsd)
(declare (ignore x))
present-p))
(defun multi-jsd-get (jsd &rest keys)
"Return a value, descending into keys. If there is no key on the way, return nil."
(loop for key in keys do
(setf jsd (jsd-get key jsd))
(unless jsd
(return-from multi-jsd-get nil)))
jsd)
(defmacro jsd-when-get (key jsd (value) &body body)
"Execute body only if key exists in jsd, with value bound to value."
(let ((present-p (gensym)))
`(multiple-value-bind (,value ,present-p) (jsd-get ,key ,jsd)
(when ,present-p
,@body))))
(defmacro jsd-getdefault (key jsd default)
"Return the value under given key in a JSD.
If the key is not present in the JSD, evaluate default and return it,
WITHOUT adding it to the JSD."
(let ((key-name (gensym)) (table-name (gensym)) (value (gensym)) (present (gensym)))
`(let ((,key-name ,key) (,table-name ,jsd))
(multiple-value-bind (,value ,present) (jsd-get ,key-name ,table-name)
(if ,present
,value
,default)))))
(defmacro jsd-setdefault (jsd key value-form)
"Return the value under given key in a JSD.
If the key is not present in the JSD, evaluate value-form,
add it to the JSD and return it."
(let ((table-name (gensym)) (key-name (gensym)) (value (gensym)) (present (gensym)))
`(let ((,table-name ,jsd) (,key-name ,key))
(multiple-value-bind (,value ,present) (jsd-get ,key-name ,table-name)
(declare (ignore ,value))
(unless ,present (setf (jsd-get ,key-name ,table-name) ,value-form))
(jsd-get ,key-name ,table-name)))))
(defun jsd-remove (key jsd)
"Remove given key from jsd."
(remhash key jsd))
(defun jsd-sorted-keys (jsd)
"Return a sorted list of keys in a given JSD."
(let ((keys (hash-table-keys jsd)))
(setf keys (sort keys #'string<))
keys))
| 4,754 | Common Lisp | .lisp | 113 | 38.389381 | 97 | 0.674897 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | fb2b6f5effefa1ed409d855fc81167c6f94a565f660dd7aa6510bf9fc4f1289c | 16,489 | [
-1
] |
16,490 | compact.lisp | RDProjekt_cl-json-ld/src/compact.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-json-ld)
(defun compact (input ctx &optional (options nil))
"Perform JSON-LD compaction.
Return multiple values: compacted JSON-LD and the active context.
Converted from pyld's compact function."
(unless ctx
(error 'json-ld-error
:message "The compaction context must not be nil."
:code "invalid local context"))
(when (eq input +jsd-null+)
;; Nothing to compact.
(return-from compact (values nil nil)))
;; Set default options.
(plist-setdefault options :base (if (stringp input) input ""))
(plist-setdefault options :compact-arrays T)
(plist-setdefault options :document-loader *default-document-loader*)
(let* ((expanded (if (getf options :skip-expansion)
input
(expand input options))) ; Expand input.
; Process context:
(active-ctx (process-context (get-initial-context options) ctx options))
; Do compaction:
(compacted (internal-compact active-ctx nil expanded options))
(compacted (simplify-compacted compacted options))
; Build output context:
(ctx (build-output-context ctx))
; Remove empty contexts and remove array if only one element:
(ctx (clean-context ctx)))
; Add context and/or @graph:
(setf compacted (add-context-or-graph compacted active-ctx ctx))
(values compacted active-ctx)))
(defun simplify-compacted (compacted options)
"Simplify the result of compaction according to given options."
(cond
((and (getf options :compact-arrays) (not (getf options :graph)) (listp compacted))
(let ((length (length compacted)))
(cond
((= length 1)
;; Simplify to a single item:
(setf compacted (first compacted)))
((= length 0)
;; Simplify to an empty object:
(setf compacted (jsd-make))))))
;; Always use an array if graph options is on:
((getf options :graph)
(setf compacted (to-list compacted))))
compacted)
(defun build-output-context (ctx)
"Create an output context from the given context."
;; Follow context key:
(when (and (is-object ctx) (jsd-get +context-key+ ctx))
(setf ctx (jsd-get +context-key+ ctx)))
;; Build output context:
(to-list (deepcopy ctx)))
(defun clean-context (ctx)
"Remove empty context and remove array if only one element.
Assumes ctx is a list."
;; Remove empty contexts:
(setf ctx (remove-if #'(lambda (v) (and (is-object v) (= (jsd-count v) 0))) ctx))
;; Remove array if only one context:
(when (= (length ctx) 1)
(setf ctx (first ctx)))
ctx)
(defun add-context-or-graph (compacted active-ctx ctx)
"Add context and/or @graph to compacted output."
(when (listp compacted)
;; Convert compacted to a JSO with @graph key:
(let ((kwgraph (compact-iri active-ctx +graph-key+))
(graph compacted))
(setf compacted (jsd-make))
(setf (jsd-get kwgraph compacted) graph)))
(when (or (not (listp ctx)) (> (length ctx) 0))
;; If the context is not empty, add it to compacted:
(setf (jsd-get +context-key+ compacted) ctx))
compacted)
(defun internal-compact (active-ctx active-property element options)
"Recursively compact an element using the given active context.
All values must be in expanded form before this method is called.
Converted from pyld's JsonLdProcessor._compact method."
(when (listp element)
;; Recursively compact array.
(let*
((compacted-elems
(map 'list #'(lambda (e) (internal-compact active-ctx active-property e options)) element))
(rval (remove nil compacted-elems)))
(when (and (getf options :compact-arrays)
(= (length rval) 1)
(null (get-context-value active-ctx active-property +container-key+)))
(setf rval (first rval)))
(return-from internal-compact rval)))
(when (is-object element)
;; Recursively compact object.
(when (or (is-value element) (is-subject-reference element))
;; Do value compaction on @values and subject references.
(return-from internal-compact (compact-value active-ctx active-property element)))
(let ((inside-reverse (equal active-property +reverse-key+))
(rval (jsd-make)))
;; Recursively process element keys in order:
(jsd-sorted-map
#'(lambda (expanded-property expanded-value)
(compact-item rval active-property expanded-property expanded-value active-ctx inside-reverse options)) element)
(return-from internal-compact rval)))
;; Only primitives remain which are already compact:
element)
(defun compact-item (rval active-property expanded-property expanded-value active-ctx inside-reverse options)
"Compact a single property-value pair of a JSO."
(cond
((or (equal expanded-property +id-key+) (equal expanded-property +type-key+))
(compact-id-or-type-item rval expanded-property expanded-value active-ctx))
((equal expanded-property +reverse-key+)
(compact-reverse-item rval expanded-property expanded-value active-ctx options))
((equal expanded-property +index-key+)
(compact-index-item rval active-property expanded-property expanded-value active-ctx))
(t
;; Expanded value must be a list due to expansion algorithm.
(compact-list rval expanded-property expanded-value active-ctx inside-reverse options))))
(defun compact-id-or-type-item (rval expanded-property expanded-value active-ctx)
"Compact an @id or @type."
(let*
((compacted-value
(if (stringp expanded-value)
;; Compact single @id
(compact-iri active-ctx expanded-value :vocab (equal expanded-property +type-key+))
;; Expanded value must be a @type array:
(map 'list #'(lambda (ev) (compact-iri active-ctx ev :vocab t)) expanded-value)))
;; Use keyword alias and add value:
(alias (compact-iri active-ctx expanded-property)))
(node-add-value rval alias compacted-value :property-is-array (empty-list-p compacted-value))))
(defun empty-list-p (value)
"Return T iff value is an empty list (nil)."
(and (listp value) (endp value)))
(defun compact-reverse-item (rval expanded-property expanded-value active-ctx options)
"Compact a @reverse."
;; Recursively compact expanded value.
(let ((compacted-value (internal-compact active-ctx +reverse-key+ expanded-value options)))
;; Handle double-reversed properties:
(jsd-copied-map
#'(lambda (compacted-property value)
(let ((mapping (jsd-get compacted-property (jsd-get "mappings" active-ctx))))
(when (and mapping (jsd-get "reverse" mapping))
(let* ((container (get-context-value active-ctx compacted-property +container-key+))
(use-array (or (equal container +set-key+) (not (getf options :compact-arrays)))))
(node-add-value rval compacted-property value :property-is-array use-array))
(jsd-remove compacted-property compacted-value))))
compacted-value)
(when (plusp (jsd-count compacted-value))
;; Use keyword alias and add value
(node-add-value rval (compact-iri active-ctx expanded-property) compacted-value))))
(defun compact-index-item (rval active-property expanded-property expanded-value active-ctx)
"Compact an @index."
;; Drop @index if inside and @index container:
(when (equal (get-context-value active-ctx active-property +container-key+) +index-key+)
(return-from compact-index-item))
;; Use keyword alias and add value
(node-add-value rval (compact-iri active-ctx expanded-property) expanded-value))
(defun compact-list (rval expanded-property expanded-value active-ctx inside-reverse options)
"Compact a list."
;; Preserve empty lists:
(when (endp expanded-value)
(let ((item-active-property (compact-iri active-ctx expanded-property :value expanded-value
:vocab t :reverse inside-reverse)))
(node-add-value rval item-active-property '() :property-is-array t)))
;; Recursively process list values:
(loop for expanded-item in expanded-value do
(compact-list-item rval expanded-property expanded-item active-ctx inside-reverse options)))
(defun compact-list-item (rval expanded-property expanded-item active-ctx inside-reverse options)
"Compact a list item."
;; Compact property and get container type:
(let*
((item-active-property (compact-iri active-ctx expanded-property :value expanded-item
:vocab t :reverse inside-reverse))
(container (get-context-value active-ctx item-active-property +container-key+))
;; Get @list value if appropriate
(is-list (is-list expanded-item))
(list (if is-list (jsd-get +list-key+ expanded-item) nil))
;; Recursively compact expanded item
(compacted-item (internal-compact active-ctx item-active-property
(if is-list list expanded-item) options)))
;; Handle @list
(when is-list
(setf compacted-item (compact-list-item-list rval compacted-item expanded-item
container active-ctx item-active-property)))
(if (or (equal container +language-key+) (equal container +index-key+))
;; Handle language and index maps.
;; Get or create the map object
(let ((map-object (jsd-setdefault rval item-active-property (jsd-make))))
;; If container is a language map, simplify compacted value to a simple string:
(when (and (equal container +language-key+) (is-value compacted-item))
(setf compacted-item (jsd-get +value-key+ compacted-item)))
;; Add compact value to map object using key from expanded value
;; based on the container type:
(node-add-value map-object (jsd-get container expanded-item) compacted-item))
;; else use an array if compact-arrays flag is false,
;; @container is @set or @list, value is an empty list, or key is @graph
(let ((is-array
(or (not (getf options :compact-arrays))
(equal container +set-key+)
(equal container +list-key+)
(empty-list-p compacted-item)
(equal expanded-property +list-key+)
(equal expanded-property +graph-key+))))
;; Add compact value:
(node-add-value rval item-active-property compacted-item :property-is-array is-array)))))
(defun compact-list-item-list (rval compacted-item expanded-item container active-ctx item-active-property)
"Compact a @list item."
;; Ensure @list is a list:
(setf compacted-item (to-list compacted-item))
(cond
((not (equal container +list-key+))
;; Wrap using @list alias:
(let ((wrapper (jsd-make)))
(setf (jsd-get (compact-iri active-ctx +list-key+) wrapper) compacted-item)
(setf compacted-item wrapper))
;; Include @index from expanded @list, if any:
(when (jsd-get +index-key+ expanded-item)
(setf (jsd-get (compact-iri active-ctx +index-key+) compacted-item)
(jsd-get +index-key+ expanded-item))))
((jsd-get item-active-property rval)
(error 'json-ld-error
:message "JSON-LD compact error; property has a @list @container rule but there is more than a single
@list that matches the compacted term in the document. Compaction might mix unwanted items into the list."
:code "compaction to list of lists")))
compacted-item)
(defun compact-value (active-ctx active-property value)
"Perform value compaction on an object with @value or @id as the only property.
Converted from pyld's JsonLdProcessor._compact_value method."
(if (is-value value)
(compact-value-value active-ctx active-property value)
;; Value is a subject reference:
(compact-value-id active-ctx active-property value)))
(defun compact-value-value (active-ctx active-property value)
"Compact @value."
(let*
((type (get-context-value active-ctx active-property +type-key+))
(language (get-context-value active-ctx active-property +language-key+))
(container (get-context-value active-ctx active-property +container-key+))
;; Whether or not the value has and @index that must be preserved:
(preserve-index (and (jsd-get +index-key+ value) (not (equal container +index-key+)))))
(unless preserve-index
;; If there's no index to preserve
;; and matching @type or @language specified in context, compact:
(when (or (equal (jsd-get +type-key+ value) type)
(equal (jsd-get +language-key+ value) language))
(return-from compact-value-value (jsd-get +value-key+ value))))
;; Return just the value of @value if all are true:
;; 1. @value is the only key or @index isn't being preserved
;; 2. There is no default language or @value is not a string
;; or the key has a mapping with a null @language.
(let*
((key-count (jsd-count value))
(is-value-only-key (or (= key-count 1)
(and (= key-count 2) (jsd-get +index-key+ value) (not preserve-index))))
(has-default-language (jsd-get +language-key+ active-ctx))
(is-value-string (stringp (jsd-get +value-key+ value)))
(has-null-mapping (and (jsd-get active-property (jsd-get "mappings" active-ctx))
(eq (jsd-get +language-key+
(jsd-get active-property (jsd-get "mappings" active-ctx))) +jsd-null+))))
(when (and is-value-only-key
(or (not has-default-language)
(not is-value-string)
has-null-mapping))
(return-from compact-value-value (jsd-get +value-key+ value))))
(let ((rval (jsd-make)))
(when preserve-index
;; Preserve @index:
(setf (jsd-get (compact-iri active-ctx +index-key+) rval) (jsd-get +index-key+ value)))
(cond
((jsd-get +type-key+ value)
;; Compact @type IRI:
(setf (jsd-get (compact-iri active-ctx +type-key+) rval)
(compact-iri active-ctx (jsd-get +type-key+ value) :vocab t)))
((jsd-get +language-key+ value)
;; Alias @language:
(setf (jsd-get (compact-iri active-ctx +language-key+) rval)
(jsd-get +language-key+ value))))
;; Alias @value:
(setf (jsd-get (compact-iri active-ctx +value-key+) rval)
(jsd-get +value-key+ value))
rval)))
(defun compact-value-id (active-ctx active-property value)
"Compact @id."
(let*
((expanded-property (expand-iri active-ctx active-property :vocab t))
(type (get-context-value active-ctx active-property +type-key+))
(compacted (compact-iri active-ctx (jsd-get +id-key+ value) :vocab (equal type +vocab-key+))))
;; Compact to scalar
(if (or (equal type +id-key+)
(equal type +vocab-key+)
(equal expanded-property +graph-key+))
compacted
(let ((rval (jsd-make)))
(setf (jsd-get (compact-iri active-ctx +id-key+) rval) compacted)
rval))))
(defun compact-iri (active-ctx iri &key value vocab reverse)
"Compact an IRI or keyword into a term or CURIE if it can be.
If the IRI has ana ssociated value it may be passed.
Converted from pyld's JsonLdProcessor._compact_iri method."
;; Can't compact :null:
(when (eq iri +jsd-null+)
(return-from compact-iri iri))
;; Term is a keyword, force vocab to True
(when (is-keyword iri)
(setf vocab t))
(when (and vocab (jsd-haskey iri (get-inverse-context active-ctx)))
(let ((term (get-term-from-inverse-context active-ctx iri value reverse)))
(when term
(return-from compact-iri term))))
;; No term match, use @vocab if available:
(when vocab
(jsd-when-get +vocab-key+ active-ctx (vocab-value)
(when (and (starts-with-p iri vocab-value) (not (equal iri vocab-value)))
;; Use suffix as relative iri if it is not a term in the active context
(let ((suffix (subseq iri (length vocab-value))))
(when (not (jsd-haskey suffix (jsd-get "mappings" active-ctx)))
(return-from compact-iri suffix))))))
;; No term or @vocab match, check for possible CURIEs
(let ((candidate (find-curie-candidate active-ctx iri value)))
(when candidate
(return-from compact-iri candidate)))
;; Compact IRI relative to base
(unless vocab
(return-from compact-iri (remove-base (jsd-get +base-key+ active-ctx) iri)))
;; Return IRI as is
iri)
(defun find-curie-candidate (active-ctx iri value)
(let ((candidate nil))
(flet ((process-mapping (term definition)
(when (find #\: term)
(return-from process-mapping))
;; Skip entries with @ids that are not partial matches
(when (or (not definition)
(eq definition +jsd-null+)
(equal (jsd-get +id-key+ definition) iri)
(not (starts-with-p iri (jsd-get +id-key+ definition))))
(return-from process-mapping))
;; a CURIE is usable if:
;; 1. it has no mapping, OR
;; 2. value is None, which means we're not compacting an @value, AND
;; the mapping matches the IRI.
(let* ((curie (concatenate 'string term ":" (subseq iri (length (jsd-get +id-key+ definition)))))
(is-usable-curie (or (not (jsd-haskey curie (jsd-get "mappings" active-ctx)))
(and (null value)
(equal (multi-jsd-get active-ctx "mappings" curie +id-key+) iri)))))
(when (and is-usable-curie
(or (null candidate)
(shorter-or-least curie candidate)))
(setf candidate curie)))))
(jsd-map #'process-mapping (jsd-get "mappings" active-ctx)))
candidate))
(defun remove-base (base iri)
"Remove a base IRI from the given absolute IRI.
Converted from pyld's remove_base function."
(let* ((base (parse-uri base))
(rel (parse-uri iri))
(enough (enough-uri rel base))
(removed (render-uri enough nil)))
(when (and (null (uri-path base)) (starts-with-p removed "/"))
(setf removed (subseq removed 1)))
removed))
(defun uri-netloc (uri)
"Return netloc (host:port) for an URI."
(let ((host (uri-host uri))
(port (uri-port uri)))
(if port
(format nil "~a:~a" host port)
host)))
(defun get-inverse-context (active-ctx)
"Generate an inverse context for use in the compaction algorithm,
if not already generated for the given active context.
Converted from pyld's JsonLdProcessor._get_inverse_context method."
(let ((inversed (jsd-get "inverse" active-ctx)))
(when inversed
(return-from get-inverse-context inversed)))
(let ((inverse (jsd-make))
(default-language (jsd-getdefault +language-key+ active-ctx +none-key+)))
(setf (jsd-get "inverse" active-ctx) inverse)
(flet ((create-selection (term mapping)
(when (eq mapping +jsd-null+)
(return-from create-selection))
;; Add term selection where it applies
(let ((container (jsd-getdefault +container-key+ mapping +none-key+))
(iris (to-list (jsd-get +id-key+ mapping))))
(loop for iri in iris do
(let* ((container-map (jsd-setdefault inverse iri (jsd-make)))
(entry (jsd-setdefault container-map container (make-inverse-entry))))
(cond
((jsd-get "reverse" mapping)
;; Term is preferred for values using @reverse
(jsd-setdefault (jsd-get +type-key+ entry) +reverse-key+ term))
((jsd-haskey +type-key+ mapping)
;; Term is preferred for values using specific type
(jsd-setdefault (jsd-get +type-key+ entry) (jsd-get +type-key+ mapping) term))
((jsd-haskey +language-key+ mapping)
;; Term is preferred for values using specific language
(let ((language (jsd-get +language-key+ mapping)))
(when (eq language +jsd-null+)
(setf language +null-key+))
(jsd-setdefault (jsd-get +language-key+ entry) language term)))
(t
;; Term is preferred for values w/default language or not typ and no language.
;; Add an entry for the default language:
(jsd-setdefault (jsd-get +language-key+ entry) default-language term)
;; Add entries for no type and no language:
(jsd-setdefault (jsd-get +type-key+ entry) +none-key+ term)
(jsd-setdefault (jsd-get +language-key+ entry) +none-key+ term))))))))
;; Create term selections for each mapping in the context,
;; ordered by shortest and then lexicographically least.
(jsd-sorted-map #'create-selection (jsd-get "mappings" active-ctx) :test #'shorter-or-least))
inverse))
(defun shorter-or-least (a b)
"Return T iff string a is either shorter or lexicographically earlier than b."
(let ((a-len (length a))
(b-len (length b)))
(if (= a-len b-len)
(string< a b)
(< a-len b-len))))
(defun make-inverse-entry ()
"Create an entry for an inversed context."
(jsd-make +language-key+ (jsd-make) +type-key+ (jsd-make)))
(defun get-term-from-inverse-context (active-ctx iri value reverse)
"Use inverse context to pick a term if iri is relative to vocab."
(let ((default-language (jsd-getdefault +language-key+ active-ctx +none-key+))
(containers '())
(type-or-language +language-key+)
(type-or-language-value +null-key+))
;; Prefer @index if available in value
(when (and (is-object value) (jsd-haskey +index-key+ value))
(push +index-key+ containers))
(cond
(reverse
(setf type-or-language +type-key+)
(setf type-or-language-value +reverse-key+)
(push +set-key+ containers))
((is-list value)
;; Choose most specific term that works for all elements in @list.
(unless (jsd-haskey +index-key+ value)
;; Only select @list containers if @index is NOT in value.
(push +list-key+ containers))
(let* ((list (jsd-get +list-key+ value))
(common-language (if (endp list) default-language nil))
(common-type nil))
(loop for item in list do
(multiple-value-bind (item-language item-type) (get-item-language-and-type item)
(cond
((null common-language)
(setf common-language item-language))
((and (not (equal item-language common-language)) (is-value item))
(setf common-language +none-key+)))
(cond
((null common-type)
(setf common-type item-type))
((not (equal item-type common-type))
(setf common-type +none-key+)))
(when (and (equal common-language +none-key+) (equal common-type +none-key+))
;; There are different languages and types in the list,
;; so choose the most generic term, no need to keep iterating.
(return))))
(setf common-language (or common-language +none-key+))
(setf common-type (or common-type +none-key+))
(if (equal common-type +none-key+)
(setf type-or-language-value common-language)
(progn
(setf type-or-language +type-key+)
(setf type-or-language-value common-type)))))
(t
;; Non-@list
(if (is-value value)
(cond
((and (jsd-haskey +language-key+ value) (not (jsd-haskey +index-key+ value)))
(push +language-key+ containers)
(setf type-or-language-value (jsd-get +language-key+ value)))
((jsd-haskey +type-key+ value)
(setf type-or-language +type-key+)
(setf type-or-language-value (jsd-get +type-key+ value))))
;; else
(progn
(setf type-or-language +type-key+)
(setf type-or-language-value +id-key+)))
(push +set-key+ containers)))
;; Do term selection
(push +none-key+ containers)
(setf containers (reverse containers))
(select-term active-ctx iri value containers type-or-language type-or-language-value)))
(defun get-item-language-and-type (item)
(let ((language +none-key+)
(type +none-key+))
(if (is-value item)
(cond
((jsd-haskey +language-key+ item)
(setf language (jsd-get +language-key+ item)))
((jsd-haskey +type-key+ item)
(setf type (jsd-get +type-key+ item)))
(t ; plain literal
(setf language +null-key+)))
;; else
(setf type +id-key+))
(values language type)))
(defun select-term (active-ctx iri value containers type-or-language type-or-language-value)
"Pick the preferred compaction term from the inverse context entry.
Converted from pyld's JsonLdProcessor._select_term method."
(setf type-or-language-value (or type-or-language-value +null-key+))
(let ((prefs '())) ; Preferred options for the value of @type or language.
(if (and (or (equal type-or-language-value +id-key+) (equal type-or-language-value +reverse-key+))
(is-subject-reference value))
;; Determine prefs for @id based on whether value compacts to term.
(progn
;; Prefer @reverse first:
(when (equal type-or-language-value +reverse-key+)
(push +reverse-key+ prefs))
;; Try to compact value to a term:
(let* ((term (compact-iri active-ctx (jsd-get +id-key+ value) :vocab t))
(mapping (jsd-get term (jsd-get "mappings" active-ctx))))
(if (and term
mapping
(equal (jsd-get +id-key+ mapping) (jsd-get +id-key+ value)))
(progn
(push +vocab-key+ prefs)
(push +id-key+ prefs))
;;else
(progn
(push +id-key+ prefs)
(push +vocab-key+ prefs)))))
;; else
(push type-or-language-value prefs))
(push +none-key+ prefs)
(setf prefs (reverse prefs))
(let ((container-map (multi-jsd-get active-ctx "inverse" iri)))
(loop for container in containers
when (jsd-haskey container container-map) do
(let ((type-or-language-value-map (multi-jsd-get container-map container type-or-language)))
(loop for pref in prefs
when (jsd-haskey pref type-or-language-value-map) do
(return-from select-term (jsd-get pref type-or-language-value-map)))))))
;; not found:
nil)
| 28,326 | Common Lisp | .lisp | 553 | 41.688969 | 123 | 0.63468 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 717eff87274433dc1b221b61438ff46c729b9d25f2fc08cf1d0636ba1f6c6fbb | 16,490 | [
-1
] |
16,491 | jsd-alist.lisp | RDProjekt_cl-json-ld/src/jsd-alist.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
;;;; abstractions for manipulating json objects
(in-package :cl-json-ld-jsd)
;;;; implementation using st-json internally
(defclass jsd-json ()
((alist
:initarg :alist)))
(defgeneric convert-to-jsd (value))
(defmethod convert-to-jsd ((value jso))
(let ((res nil))
(mapjso #'(lambda (k v)
(setf res (acons k (convert-to-jsd v) res)))
value)
(make-instance 'jsd-json :alist res)))
(defmethod convert-to-jsd ((value cons))
(mapcar #'(lambda (item)
(convert-to-jsd item))
value))
(defmethod convert-to-jsd ((value t))
value)
(defun jsd-read (source)
(convert-to-jsd (read-json source)))
(defun jsd-make (&rest args)
(convert-to-jsd (apply #'jso args)))
(defun is-object (value)
"Return T iff given value is an Object."
(typep value 'jsd-json))
(defun is-empty-object (value)
"Return T iff given value is an empty Object."
(and (is-object value)
(with-slots (alist) value
(eq 0 (length alist)))))
;;;; to string
(defmethod write-json-element ((element jsd-json) stream)
(with-slots (alist) element
(write-json-element (st-json::make-jso :alist alist) stream)))
(defun jsd-to-string (element)
"Write a value's JSON representation to a string."
(write-json-to-string element))
;;;; deepcopy
(defmethod cl-json-ld-utils:st-json-deepcopy ((element jsd-json))
(with-slots (alist) element
(make-instance 'jsd-json :alist (loop for (key . val) in alist
collect (cons (copy-seq key) (cl-json-ld-utils:st-json-deepcopy val))))))
;;;; objs-equal-p
(defun cdr-assoc (key list &rest rest)
(let ((kv (apply #'assoc key list rest)))
(if kv (cdr kv) nil)))
(defmethod objs-equal-p ((obj1 jsd-json) (obj2 jsd-json))
(with-slots ((list1 alist)) obj1
(with-slots ((list2 alist)) obj2
(if (eql (length list1) (length list2))
(progn
(loop
for (key . val1) in list1
do
(let* ((val2 (cdr-assoc key list2 :test #'string=)))
(cl-json-ld-utils::propagate-negative-result val1 val2 objs-equal-p)))
(return-from objs-equal-p t))
(cl-json-ld-utils::lazy-message-eq nil "Different object lengths ~s != ~s" obj1 obj2)))))
(defun jsd-get (key jsd)
"Fetch a value from a JS object. Returns a second value like
gethash."
(with-slots (alist) jsd
(let ((pair (assoc key alist :test #'string=)))
(values (cdr pair) (and pair t)))))
(defun (setf jsd-get) (val key jsd)
"Store a value in a JS object."
(with-slots (alist) jsd
(let ((pair (assoc key alist :test #'string=)))
(if pair
(setf (cdr pair) val)
(prog1 val (push (cons key val) alist))))))
(defun jsd-count (jsd)
"Return the number of items (unique keys) in the JSD."
(with-slots (alist) jsd
(length alist)))
(defun jsd-map (func jsd)
"Iterate over the key/value pairs in a JS object."
(with-slots (alist) jsd
(loop :for (key . val) :in alist
:do (funcall func key val))))
(defun jsd-sorted-map (func jsd &key (test #'string<))
"Iterate over the key/value pairs in JSD, in order of sorted keys."
(with-slots (alist) jsd
(let ((items (copy-list alist)))
(setf items (sort items #'(lambda (left right) (funcall test (car left) (car right)))))
(loop for (key . value) in items do
(funcall func key value)))))
(defun jsd-copied-map (func jsd)
"Iterate over key/value pairs in JSD, copying the JSD beforehand,
so that the code in func can manipulate the map."
(with-slots (alist) jsd
(let ((items (copy-list alist)))
(loop for (key . value) in items do
(funcall func key value)))))
(defun jsd-is-bool-p (value)
(typep value 'json-bool))
(defconstant +jsd-true+ :true)
(defconstant +jsd-false+ :false)
;;;;
;;;; JSON HELPER FUNCTIONS
;;;;
(defun jsd-haskey (key jsd)
(multiple-value-bind (x present-p) (jsd-get key jsd)
(declare (ignore x))
present-p))
(defun multi-jsd-get (jsd &rest keys)
"Return a value, descending into keys. If there is no key on the way, return nil."
(loop for key in keys do
(setf jsd (jsd-get key jsd))
(unless jsd
(return-from multi-jsd-get nil)))
jsd)
(defmacro jsd-when-get (key jsd (value) &body body)
"Execute body only if key exists in jsd, with value bound to value."
(let ((present-p (gensym)))
`(multiple-value-bind (,value ,present-p) (jsd-get ,key ,jsd)
(when ,present-p
,@body))))
(defmacro jsd-getdefault (key jsd default)
"Return the value under given key in a JSD.
If the key is not present in the JSD, evaluate default and return it,
WITHOUT adding it to the JSD."
(let ((key-name (gensym)) (table-name (gensym)) (value (gensym)) (present (gensym)))
`(let ((,key-name ,key) (,table-name ,jsd))
(multiple-value-bind (,value ,present) (jsd-get ,key-name ,table-name)
(if ,present
,value
,default)))))
(defmacro jsd-setdefault (jsd key value-form)
"Return the value under given key in a JSD.
If the key is not present in the JSD, evaluate value-form,
add it to the JSD and return it."
(let ((table-name (gensym)) (key-name (gensym)) (value (gensym)) (present (gensym)))
`(let ((,table-name ,jsd) (,key-name ,key))
(multiple-value-bind (,value ,present) (jsd-get ,key-name ,table-name)
(declare (ignore ,value))
(unless ,present (setf (jsd-get ,key-name ,table-name) ,value-form))
(jsd-get ,key-name ,table-name)))))
(defun jsd-remove (key jsd)
"Remove given key from jsd."
(with-slots (alist) jsd
(setf alist (remove key alist :key #'car :test #'string=))))
(defun jsd-sorted-keys (jsd)
"Return a sorted list of keys in a given JSD."
(with-slots (alist) jsd
(let ((keys (loop for cons in alist collect (car cons))))
(setf keys (sort keys #'string<))
keys))) | 6,760 | Common Lisp | .lisp | 167 | 35.760479 | 113 | 0.649832 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 59c5822ac3a571695f502f6c280c7d027583c7551e89db693a1ff76fc5e870aa | 16,491 | [
-1
] |
16,492 | frame.lisp | RDProjekt_cl-json-ld/src/frame.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-json-ld)
(defun frame (input frame &optional (options nil))
"Perform JSON-LD framing.
Converted from pyld's frame function."
;; Set default options
(plist-setdefault options :base (if (stringp input) input ""))
(plist-setdefault options :compact-arrays t)
(plist-setdefault options :embed t)
(plist-setdefault options :document-loader *default-document-loader*)
;; If frame is a string, attempt to dereference remote document
(multiple-value-bind (context-url document-url document)
(if (stringp frame)
(funcall (getf options :document-loader) frame)
(values +jsd-null+ nil frame))
(declare (ignore document-url))
(handler-bind ((json-ld-error #'(lambda (cause)
(error 'json-ld-error
:message "Could not retrieve a JSON-LD document from the URL."
:code "loading document failed"
:cause cause))))
(unless document
(error 'json-ld-error :message "No remote document found at the given URL."))
(when (stringp document)
(setf document (jsd-read document))))
;; Preserve frame context
(let ((frame document)
(ctx nil)
(expanded nil)
(expanded-frame nil))
(when frame
(setf ctx (jsd-get +context-key+ frame))
(when (not (eq context-url +jsd-null+))
(setf ctx (if ctx
(append (to-list ctx) (list context-url))
context-url)
(jsd-get +context-key+ frame) ctx)))
;; If no context present, make an empty context.
(setf ctx (or ctx (jsd-make)))
;; Expand input
(handler-bind ((json-ld-error #'(lambda (cause)
(error 'json-ld-error
:message "Could not expand input before framing"
:cause cause))))
(setf expanded (expand input options)))
;; Expand frame
(let ((opts (copy-list options)))
(setf (getf opts :keep-free-floating-nodes) t)
(handler-bind ((json-ld-error #'(lambda (cause)
(error 'json-ld-error
:message "Could not expand frame before framing"
:cause cause))))
(setf expanded-frame (expand frame opts))))
;; Do framing
(let ((framed (internal-frame expanded expanded-frame options))
(compacted nil)
(active-ctx nil))
;; Compact result (force @graph option to T)
(setf (getf options :graph) t
(getf options :skip-expansion) t
(getf options :active-ctx) t)
(handler-bind ((json-ld-error #'(lambda (cause)
(error 'json-ld-error
:message "Could not compact framed output."
:cause cause))))
(multiple-value-bind (comp act-ctx) (compact framed ctx options)
(setf compacted comp
active-ctx act-ctx)))
;; Get graph alias
(let ((graph (compact-iri active-ctx +graph-key+)))
;; Remove @preserve from results
(setf (jsd-get graph compacted) (remove-preserve active-ctx (jsd-get graph compacted) options)))
compacted))))
(defun internal-frame (input frame options)
"Perform JSON-LD framing.
:param input_: the expanded JSON-LD to frame.
:param frame: the expanded JSON-LD frame to use.
:param options: the framing options.
Converted from pyld's JsonLdProcessor._frame method."
;; Create framing state
(let ((state (make-state :options options
:graphs (jsd-make +default-graph-name+ (jsd-make) +merged-key+ (jsd-make))))
(namer (make-namer)))
;; Produce a map of all graphs and name each bnode
(create-node-map input (state-get state :graphs) +merged-key+ namer)
(state-set state :subjects (jsd-get +merged-key+ (state-get state :graphs)))
;; Frame the subjects
(let ((framed '())
(sorted-subject-keys (jsd-sorted-keys (state-get state :subjects))))
(setf framed (match-frame state sorted-subject-keys frame framed nil))
(nreverse framed))))
(defun make-state (&rest args)
(let ((state (make-hash-table)))
(loop for (key value) on args by #'cddr do
(state-set state key value))
state))
(defun state-set (state key value)
(setf (gethash key state) value))
(defun state-get (state key)
(gethash key state))
(defun match-frame (state subjects frame parent property)
"Frame subjects according to given frame.
Return modified parent."
;; Validate the frame
(validate-frame frame)
(setf frame (first frame))
;; Filter out subjects that match the frame
(let* ((matches (filter-subjects state subjects frame))
(options (state-get state :options))
(embed-on (get-frame-flag frame options "embed"))
(explicit-on (get-frame-flag frame options "explicit")))
;; Add matches to output
(sorted-maphash #'(lambda (id subject)
(setf parent (process-frame-match id subject state frame parent
property options embed-on explicit-on)))
matches))
parent)
(defun validate-frame (frame)
"Validate a JSON-LD frame, throwing an exception if the frame is invalid."
(unless (and (listp frame)
(= (length frame) 1)
(is-object (first frame)))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; a JSON-LD frame must be a single object.")))
(defun filter-subjects (state subjects frame)
"Return a hashmap of all of the subjects that match a parsed frame."
(let ((rval (make-string-hashtable)))
(loop for id in subjects
for subject = (jsd-get id (state-get state :subjects))
when (filter-subject subject frame)
do (setf (gethash id rval) subject))
rval))
(defun filter-subject (subject frame)
"Return T iff the given subject matches the given frame."
;; Check @type (object value means 'any' type, fall through to ducktyping.
(let ((frame-types (jsd-get +type-key+ frame)))
(when (and frame-types
(not (and (= (length frame-types) 1)
(is-object (first frame-types)))))
;; Any matching @type is a match.
(return-from filter-subject
(some #'(lambda (type) (node-has-value-p subject +type-key+ type)) frame-types))))
;; Check ducktype
(jsd-map #'(lambda (k v)
(declare (ignore v))
;; Only not a duck if @id or non-keyword isn't in subject
(when (and (or (equal k +id-key+)
(not (is-keyword k)))
(not (jsd-haskey k subject)))
(return-from filter-subject nil)))
frame)
t)
(defun get-frame-flag (frame options name)
"Get the frame flag value (boolean) for the given flag name.
Name should be in camelCase."
(let* ((key (concatenate 'string "@" name))
(value (jsd-get key frame)))
(if value
(eq (first value) +jsd-true+)
;; else take value from options
(getf options (camel-case->symbol name :keyword)))))
(defun process-frame-match-set-embed (embed-on id state output)
(let ((existing (gethash id (state-get state :embeds))))
(when (and embed-on existing)
;; Only overwrite an existing embed if it has already been added
;; to its parent -- otherwise its parent is somewhere up
;; the tree from this embed and the embed would occur twice
;; once the tree is added
(setf embed-on nil)
(let ((existing-parent (getf existing :parent)))
(cond
((listp existing-parent)
;; Existing embed's parent is a list
(setf embed-on (some #'(lambda (p) (compare-values output p)) existing-parent)))
((node-has-value-p existing-parent (getf existing :property) output)
;; Existing embed's parent is an object
(setf embed-on t))))
;; Existing embed has already been added, so allow an overwrite
(when embed-on
(remove-embed state id))))
embed-on)
(defun add-frame-output (parent property output)
"Add framing output to the given parent.
Return modified parent."
(if (is-object parent)
(node-add-value parent property output :property-is-array t)
(push output parent))
parent)
(defun remove-preserve (ctx input options)
"Remove the @preserve keywords as the last step of the framing algorithm."
(cond
((listp input)
;; Recurse through lists
(return-from remove-preserve (loop for e in input
for result = (remove-preserve ctx e options)
;; drop nulls from arrays
unless (eq result +jsd-null+)
collect result)))
((is-object input)
;; Remove @preserve
(jsd-when-get +preserve-key+ input (preserve)
(return-from remove-preserve (if (equal preserve +null-key+) +jsd-null+ preserve)))
;; Skip @values
(when (is-value input)
(return-from remove-preserve input))
;; Recurse through @lists
(when (is-list input)
(setf (jsd-get +list-key+ input) (remove-preserve ctx (jsd-get +list-key+ input) options))
(return-from remove-preserve input))
;; Recurse through properties
(jsd-map #'(lambda (prop v)
(let ((result (remove-preserve ctx v options))
(container (get-context-value ctx prop +container-key+)))
(when (and (getf options :compact-arrays)
(listp result)
(= (length result) 1)
(not (equal container +set-key+))
(not (equal container +list-key+)))
(setf result (first result)))
(setf (jsd-get prop input) result)))
input)))
input)
(defun process-frame-match (id subject state frame parent property options embed-on explicit-on)
"Return modified parent."
;; In order to treat each top-level match as a compartmentalized result,
;; create an independent copy of the embedded subjects map when the property is nil,
;; which only occurs at top-level.
(unless property
(state-set state :embeds (make-string-hashtable)))
;; Start output
(let* ((output (make-id-entry id))
(embed-on (process-frame-match-set-embed embed-on id state output)))
(when embed-on
(setf (gethash id (state-get state :embeds)) (list :parent parent :property property))
;; Iterate over subject properties in order
(jsd-sorted-map #'(lambda (prop objects)
(process-frame-match-process-property subject prop objects state frame output explicit-on))
subject)
;; Handle defaults in order
(loop for prop in (jsd-sorted-keys frame)
unless (is-keyword prop) ; skip keywords
do (process-frame-match-handle-frame-default prop frame output options)))
;; Add output to parent
(add-frame-output parent property output)))
(defun process-frame-match-process-property (subject prop objects state frame output explicit-on)
"Converted from part of pyld's _match_frame method."
(cond
((is-keyword prop)
;; Copy keywords to output
(setf (jsd-get prop output) (deepcopy (jsd-get prop subject))))
((not (jsd-haskey prop frame))
;; If property isn't in the frame,
;; If explicit is off, embed values.
(unless explicit-on
(embed-values state subject prop output)))
(t
;; Add objects
(loop for object in objects do
(process-frame-match-add-object prop object state frame output)))))
(defun process-frame-match-add-object (prop object state frame output)
"Converted from part of pyld's _match_frame method."
(cond
((is-list object)
;; Recurse into list.
;; Add empty list.
(let ((list (jsd-make +list-key+ '())))
(add-frame-output output prop list)
;; Add list objects
(loop for object in (jsd-get +list-key+ object) do
(if (is-subject-reference object)
;; Recurse into subject reference
(match-frame state (list (jsd-get +id-key+ object))
(jsd-get +list-key+ (first (jsd-get prop frame)))
list +list-key+)
;; else include other values automatically
(add-frame-output list +list-key+ (deepcopy object))))))
((is-subject-reference object)
;; Recurse into subject reference
(match-frame state (list (jsd-get +id-key+ object))
(jsd-get prop frame) output prop))
(t
;; Include other values automatically
(add-frame-output output prop (deepcopy object)))))
(defun embed-values (state subject property output)
"Embed values for the given subject and property into the given output
during the framing algorithm.
Returns modified output.
Converted from pyld's JsonLdProcessor._embed_values method."
;; Embed subject properties in output
(loop for object in (jsd-get property subject) do
(cond
((is-list object)
;; Recurse into @list
(let ((list (jsd-make +list-key+ '())))
(setf output (add-frame-output output property list)
(jsd-get +list-key+ list)
(reverse (embed-values state object +list-key+ (jsd-get +list-key+ list)))))
(return-from embed-values output))
((is-subject-reference object)
;; Handle subject reference
(let ((id (jsd-get +id-key+ object))
(state-embeds (state-get state :embeds)))
;; Embed full subject if isn't already embedded
(unless (gethash id state-embeds)
;; Add embed
(setf (gethash id state-embeds) (list :parent output :property property))
;; Recurse into subject
(setf object (jsd-make))
(let ((state-subject (jsd-get id (state-get state :subjects))))
(jsd-map #'(lambda (prop value)
;; Copy keywords
(if (is-keyword prop)
(setf (jsd-get prop object) (deepcopy value))
(embed-values state state-subject prop object)))
state-subject)))
(setf output (add-frame-output output property object)
(getf (gethash id state-embeds) :parent) output)
output))
(t
;; Copy non-subject value
(add-frame-output output property (deepcopy object))))))
(defun process-frame-match-handle-frame-default (prop frame output options)
"Converted from part of pyld's JsonLdProcessor._match_frame method."
;; If omit default is off, then include default values for properties
;; that appear in the next frame but are not in the matching subject.
(let* ((next (first (jsd-get prop frame)))
(omit-default-on (get-frame-flag next options "omitDefault")))
(unless (or omit-default-on (jsd-haskey prop output))
(let ((preserve (to-list (if (jsd-haskey +default-graph-name+ next)
(deepcopy (jsd-get +default-graph-name+ next))
+null-key+))))
(setf (jsd-get prop output) (list (jsd-make +preserve-key+ preserve)))))))
(defun remove-embed (state id)
"Remove an existing embed."
;; Get existing embed
(let* ((embeds (state-get state :embeds))
(embed (gethash id embeds))
(property (getf embed :property))
;; Create reference to replace embed
(subject (make-id-entry id)))
;; Remove existing embed
(let ((new-parent (remove-embed-only embed subject property)))
;; Update parent, which is a list and must be manually updated:
(setf (getf embed :parent) new-parent
(gethash id embeds) embed))
;; Recursively remove dependent dangling embeds
(labels ((remove-dependents (id)
;; Get embed keys as a separate array
;; to enable deleting keys in map
(loop for next in (alexandria:hash-table-keys embeds)
for embed-next = (gethash next embeds) ; might have been removed already
when (and embed-next
(is-object (getf embed-next :parent))
(equal (jsd-get +id-key+ (getf embed-next :parent)) id))
do (remhash next embeds)
(remove-dependents next))))
(remove-dependents id))))
(defun remove-embed-only (embed subject property)
"Remove the embed itself (without dependents).
Return the new parent."
(let ((old-parent (getf embed :parent)))
(if (listp old-parent)
;; Replace subject with reference in list
(mapcar #'(lambda (parent) (if (compare-values parent subject) subject parent)) old-parent)
;; else replace subject with reference
(let ((use-array (listp (jsd-get property old-parent))))
(node-remove-value old-parent property subject :property-is-array use-array)
(node-add-value old-parent property subject :property-is-array use-array)
old-parent))))
(defun node-remove-value (subject property value &key property-is-array)
(let ((values (remove-if #'(lambda (e) (compare-values e value)) (node-get-values subject property))))
(cond
((= (length values) 0)
(remove-property subject property))
((and (= (length values) 1) (not property-is-array))
(setf (jsd-get property subject) (first values)))
(t
(setf (jsd-get property subject) values)))))
(defun remove-property (subject property)
(jsd-remove property subject))
(defun node-get-values (subject property)
(to-list (jsd-getdefault property subject '())))
| 19,276 | Common Lisp | .lisp | 399 | 37.867168 | 116 | 0.611728 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | b8f839acdeff2b9cafb7e125d22b1d63f2e1eb25e5d8a936d705fc87fb5c285c | 16,492 | [
-1
] |
16,493 | context.lisp | RDProjekt_cl-json-ld/src/context.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-json-ld)
(defvar *cache* nil)
(defun get-initial-context (options)
(jsd-make +base-key+ (getf options :base) "mappings" (jsd-make) "inverse" nil))
(defun get-context-value (context key type)
"Gets the value for the given active context key and type, nil if none is set."
;; return :null for invalid key
(when (eq key +jsd-null+)
(return-from get-context-value +jsd-null+))
(let ((rval +jsd-null+))
;; get default language
(when (equal type +language-key+)
(jsd-when-get type context (type-value)
(setf rval type-value)))
;; get specific entry information
(jsd-when-get key (jsd-get "mappings" context) (entry)
(when (eq entry +jsd-null+)
(return-from get-context-value +jsd-null+))
;; return whole entry
(if (not type)
(setf rval entry)
(jsd-when-get type entry (type-value)
(setf rval type-value))))
rval))
(defun get-context-mapping (context mapping-key)
(let ((mappings (jsd-get "mappings" context)))
(jsd-get mapping-key mappings)))
(defun clone-active-context (active-ctx)
"Clones an active context, creating a child active context."
(let ((child (jsd-make +base-key+ (jsd-get +base-key+ active-ctx)
"mappings" (deepcopy (jsd-get "mappings" active-ctx))
"inverse" nil))
(language-val (jsd-get +language-key+ active-ctx))
(vocab-val (jsd-get +vocab-key+ active-ctx)))
(when language-val
(setf (jsd-get +language-key+ child) language-val))
(when vocab-val
(setf (jsd-get +vocab-key+ child) vocab-val))
child))
(defun term-definition-handle-reverse (reverse-value value active-ctx local-ctx defined mapping)
(when (jsd-haskey +id-key+ value)
(error 'json-ld-error
:message "Invalid JSON-LD syntax; an @reverse term definition must not contain @id."
:code "invalid reverse property"))
(when (not (stringp reverse-value))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context @reverse value must be a string."
:code "invalid IRI mapping"))
;; expand and add @id mapping
(let ((id (expand-iri active-ctx reverse-value :vocab t :base nil :local-ctx local-ctx :defined defined)))
(when (not (absolute-iri-p id))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context @reverse value must be an absolute IRI or a blank node identifier."
:code "invalid IRI mapping"))
(setf (jsd-get +id-key+ mapping) id)
(setf (jsd-get "reverse" mapping) t)))
(defun create-term-definition (active-ctx local-ctx term defined)
"Creates a term definition during context processing."
(multiple-value-bind (defined-p present-p) (gethash term defined)
(when present-p
;; term already defined
(when defined-p
(return-from create-term-definition))
;; cycle detected
(error 'json-ld-error
:message "Cyclical context definition detected."
:code "cyclic IRI mapping")))
;; now defining term
(setf (gethash term defined) nil)
(when (is-keyword term)
(error 'json-ld-error
:message "Invalid JSON-LD syntax; keywords cannot be overridden."
:code "keyword redefinition"))
;; remove old mapping
(let ((active-mappings (jsd-get "mappings" active-ctx)))
(when (jsd-get term active-mappings)
(jsd-remove term active-mappings))
;; get context term value
(let ((value (jsd-get term local-ctx)))
;; clear context entry
(when (or (eq value +jsd-null+)
(and (is-object value) (multiple-value-bind (id-value id-present-p) (jsd-get +id-key+ value)
(and id-present-p (eq id-value +jsd-null+)))))
(setf (jsd-get term active-mappings) +jsd-null+)
(setf (gethash term defined) t)
(return-from create-term-definition))
;; convert short-hand value to object w/@id
(when (stringp value)
(setf value (jsd-make +id-key+ value)))
(when (not (is-object value))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context property values must be strings or objects."
:code "invalid term definition"))
;; create new mapping
(let ((mapping (jsd-make "reverse" nil)))
(setf (jsd-get term active-mappings) mapping)
(multiple-value-bind (reverse-value reverse-present-p) (jsd-get +reverse-key+ value)
(if reverse-present-p
(term-definition-handle-reverse reverse-value value active-ctx local-ctx defined mapping)
(multiple-value-bind (id id-present-p) (jsd-get +id-key+ value)
(when id-present-p
(when (not (stringp id))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context @id value must be a string"
:code "invalid IRI mapping"))
(when (not (equal id term))
(setf id (expand-iri active-ctx id :vocab t :base nil :local-ctx local-ctx :defined defined))
(when (and (not (absolute-iri-p id)) (not (is-keyword id)))
(error 'json-ld-error
:message "Invalid JSON-LD syntax;
@context @id value must be an absolute IRI, a blank node identifier, or a keyword"
:code "invalid IRI mapping"))
(setf (jsd-get +id-key+ mapping) id))))))
(unless (jsd-haskey +id-key+ mapping)
;; see if the term has a prefix
(if (find #\: term)
(progn
(multiple-value-bind (prefix suffix) (split-string term #\:)
(when (jsd-get prefix local-ctx)
;; define parent prefix
(create-term-definition active-ctx local-ctx prefix defined))
;; set @id based on prefix parent
(multiple-value-bind (prefix-mapping prefix-mapping-present-p) (jsd-get prefix active-mappings)
(setf (jsd-get +id-key+ mapping)
(if prefix-mapping-present-p
(concatenate 'string (jsd-get +id-key+ prefix-mapping) suffix)
;; term is an absolute IRI
term)))))
;; else
(progn
(multiple-value-bind (vocab-value vocab-present-p) (jsd-get +vocab-key+ active-ctx)
(when (not vocab-present-p)
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context terms must define an @id."
:code "invalid IRI mapping"))
;; prepend vocab to term
(setf (jsd-get +id-key+ mapping) (concatenate 'string vocab-value term))))))
;; IRI mapping now defined
(setf (gethash term defined) t)
(multiple-value-bind (type type-present-p) (jsd-get +type-key+ value)
(when type-present-p
(when (not (stringp type))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context @type value must be a string."
:code "invalid type mapping"))
(when (and (not (equal type +id-key+))
(not (equal type +vocab-key+)))
;; expand @type to full IRI
(setf type (expand-iri active-ctx type :vocab t :local-ctx local-ctx :defined defined))
(when (not (absolute-iri-p type))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; an @context @type value must be an absolute IRI."
:code "invalid type mapping"))
(when (blank-name-p type)
(error 'json-ld-error
:message "Invalid JSON-LD syntax; an @context @type values must be an IRI, not a blank node identifier."
:code "invalid type mapping")))
;; add @type to mapping
(setf (jsd-get +type-key+ mapping) type))
(multiple-value-bind (container container-present-p) (jsd-get +container-key+ value)
(when container-present-p
(when (not (find container (list +list-key+ +set-key+ +index-key+ +language-key+) :test #'string=))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context @container value must be one of the following: @list, @set, @index, or @language."
:code "invalid container mapping"))
(when (and (jsd-get "reverse" mapping)
(not (equal container +index-key+))
(not (equal container +set-key+))
(not (eq container +jsd-null+)))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context @container value for an @reverse type definition must be @index or @set."
:code "invalid reverse property"))
;; add @container to mapping
(setf (jsd-get +container-key+ mapping) container)))
(multiple-value-bind (language language-present-p) (jsd-get +language-key+ value)
(when (and language-present-p (not type-present-p))
(when (not (or (eq language +jsd-null+) (stringp language)))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context @language value must be a string or null."
:code "invalid language mapping"))
;; add @language to mapping
(when (not (eq language +jsd-null+))
(setf language (string-downcase language)))
(setf (jsd-get +language-key+ mapping) language))))
;; disallow aliasing @context and @preserve
(let ((id (jsd-get +id-key+ mapping)))
(when (or (equal id +context-key+) (equal id +preserve-key+))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context and @preserve cannot be aliased"
:code "invalid keyword alias")))))))
(defun process-context (active-ctx local-ctx options)
"Processes a local context, retrieving any URLs as necessary, and
returns a new active context.
Converted from pyld's JsonLdProcessor.process_context method."
;; Return initial context early for null context
(when (eq local-ctx +jsd-null+)
(return-from process-context (get-initial-context options)))
;; Set default options
(plist-setdefault options :base "")
(plist-setdefault options :document-loader *default-document-loader*)
;; Retrieve URLs in local-ctx
(setf local-ctx (deepcopy local-ctx))
(when (or (stringp local-ctx)
(and (is-object local-ctx) (not (jsd-haskey +context-key+ local-ctx))))
(setf local-ctx (jsd-make +context-key+ local-ctx)))
(retrieve-context-urls local-ctx nil (getf options :document-loader) :base (getf options :base))
(internal-process-context active-ctx local-ctx options))
(defun internal-process-context (active-ctx local-ctx options)
"Processes a local context and returns a new active context.
Converted from pyld's JsonLdProcessor._process_context method."
;; normalize local context to an array
(when (is-object local-ctx)
(multiple-value-bind (context context-present-p) (jsd-get +context-key+ local-ctx)
(when (and context-present-p (listp context))
(setf local-ctx (jsd-get +context-key+ local-ctx)))))
(let ((ctxs (arraify local-ctx))
(rval active-ctx)
(active-context-cache (getf *cache* :active-ctx))
(must-clone t))
;; no contexts in array, clone existing context
(when (= (length ctxs) 0)
(return-from internal-process-context (clone-active-context active-ctx)))
;; process each context in order
(loop for ctx in ctxs do
(block continue-block
;; reset to initial context
(when (eq ctx +jsd-null+)
(setf rval (get-initial-context options))
(setf must-clone nil)
(return-from continue-block))
;; dereference @context key if present
(when (and (is-object ctx) (jsd-get +context-key+ ctx))
(setf ctx (jsd-get +context-key+ ctx)))
;; context must be an object now, all URLs retrieved prior to call
(when (not (is-object ctx))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; @context must be an object."
:code "invalid local context"))
;; get context from cache if available
(when active-context-cache
(let ((cached (context-cache-get active-context-cache active-ctx ctx)))
(when cached
(setf rval cached)
(setf must-clone t)
(return-from continue-block))))
;; clone context, if required, before updating
(when must-clone
(setf rval (clone-active-context active-ctx))
(setf must-clone nil))
(let ((defined (make-string-hashtable)))
;; handle @base
(jsd-when-get +base-key+ ctx (base)
(cond
((eq base +jsd-null+)
(setf base nil))
((not (stringp base))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; the value of \"@base\" in a @context must be a string or null."
:code "invalid base IRI"))
((and (not (equal base "")) (not (absolute-iri-p base)))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; the value of \"@base\" in a @context must be an absolute IRI or the empty string."
:code "invalid base IRI")))
(setf (jsd-get +base-key+ rval) base)
(setf (gethash +base-key+ defined) t))
;; handle @vocab
(multiple-value-bind (vocab-value vocab-present-p) (jsd-get +vocab-key+ ctx)
(when vocab-present-p
(cond ((eq vocab-value +jsd-null+) (jsd-remove +vocab-key+ rval))
((not (stringp vocab-value))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; the value of \"@vocab\" in a @context must be a string or null."
:code "invalid vocab mapping"))
((not (absolute-iri-p vocab-value))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; the value of \"@vocab\" in a @context must be an absolute IRI."
:code "invalid vocab mapping"))
(t (setf (jsd-get +vocab-key+ rval) vocab-value)))
(setf (gethash +vocab-key+ defined) t)))
;; handle @language
(multiple-value-bind (language-value language-present-p) (jsd-get +language-key+ ctx)
(when language-present-p
(cond ((eq language-value +jsd-null+) (jsd-remove +language-key+ rval))
((not (stringp language-value))
(error 'json-ld-error
:message "Invalid JSON-LD syntax; the value of \"@language\" in a @context must be a string or null."
:code "invalid default language"))
(t (setf (jsd-get +language-key+ rval) (string-downcase language-value))))
(setf (gethash +language-key+ defined) t)))
;; process all other keys
(jsd-map #'(lambda (k v)
(declare (ignore v))
(create-term-definition rval ctx k defined))
ctx)
;; Cache result:
(when active-context-cache
(context-cache-set active-context-cache active-ctx ctx rval)))))
rval))
(defclass limited-queue ()
((size :initarg :size :initform 100)
(array :initform nil)
(start :initform 0)
(end :initform 0)))
(defmethod initialize-instance :after ((queue limited-queue) &key)
(with-slots (size array) queue
(setf array (make-array size))))
(defun queue-full (queue)
(with-slots (size start end) queue
(= (mod (1+ end) size) start)))
(defun queue-push (queue value)
(when (queue-full queue)
(error "Queue full."))
(with-slots (array end size) queue
(setf (elt array end) value)
(setf end (mod (1+ end) size))))
(defun queue-pop-first (queue)
(with-slots (array start end size) queue
(when (= start end)
(error "Queue empty."))
(prog1
(elt array start)
(setf (elt array start) nil)
(setf start (mod (1+ start) size)))))
(defclass active-context-cache ()
((order :initform (make-instance 'limited-queue :size 100))
(cache :initform (make-string-hashtable))))
(defun context-cache-get (cache active-ctx local-ctx)
(let* ((key1 (jsd-to-string active-ctx))
(key2 (jsd-to-string local-ctx))
(first-entry (gethash key1 (slot-value cache 'cache))))
(and first-entry (gethash key2 first-entry))))
(defun context-cache-set (cache active-ctx local-ctx result)
(with-slots (order cache) cache
(when (queue-full order)
(destructuring-bind (key1 . key2) (queue-pop-first order)
(remhash key2 (gethash key1 cache))
(when (zerop (hash-table-count (gethash key1 cache)))
(remhash key1 cache))))
(let ((key1 (jsd-to-string active-ctx))
(key2 (jsd-to-string local-ctx)))
(queue-push order (cons key1 key2))
(setf (gethash key2 (hashtable-setdefault cache key1 (make-string-hashtable)))
(deepcopy result)))))
(setf (getf *cache* :active-ctx) (make-instance 'active-context-cache))
| 19,005 | Common Lisp | .lisp | 362 | 40.51105 | 143 | 0.594318 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 012d665380e9f15eb2fefa933efc0e2f4a4c350349032068556686e6cbf18260 | 16,493 | [
-1
] |
16,494 | jsd-yason.lisp | RDProjekt_cl-json-ld/src/jsd-yason.lisp | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(in-package :cl-json-ld-jsd)
(defun jsd-read (source)
(let* ((yason:*parse-json-booleans-as-symbols* t)
(yason:*parse-json-null-as-keyword* t))
(yason:parse source)))
(defun jsd-make (&rest args)
(let ((res (make-string-hashtable)))
(loop for (key value) on args by #'cddr do
(setf (gethash key res) value))
res))
(defmethod yason:encode ((object (eql :null)) &optional (stream *standard-output*))
(yason:encode 'yason:null stream))
(defun jsd-to-string (element)
(let ((s (make-string-output-stream)))
(yason:encode element s)
s))
(defconstant +jsd-null+ :null)
(defconstant +jsd-true+ 'yason:true)
(defconstant +jsd-false+ 'yason:false)
(defun jsd-bool-p (value)
(or (eql value +jsd-true+)
(eql value +jsd-false+)))
| 1,613 | Common Lisp | .lisp | 40 | 37.775 | 83 | 0.687739 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 7d963a928b056e705230e82c56b44e29c1f45cf3aef8a5215b5b8c653d319f4c | 16,494 | [
-1
] |
16,495 | cl-json-ld.asd | RDProjekt_cl-json-ld/cl-json-ld.asd | ;;;; Copyright (c) 2014 RD Projekt Sp. z o.o. Sp. k.
;;;; http://www.rdprojekt.pl/
;;;; Use is subject to license terms.
;;;;
;;;; This file is part of CL-JSON-LD.
;;;;
;;;; CL-JSON-LD 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.
;;;;
;;;; CL-JSON-LD 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 CL-JSON-LD. If not, see <http://www.gnu.org/licenses/>.
(defpackage :cl-json-ld-system (:use :asdf :cl))
(in-package :cl-json-ld-system)
(defparameter *json-library* (cond
((find-system :st-json nil)
:st-json)
((find-system :yason nil)
:yason)
(t :st-json)))
(format t "~&CHOSEN JSON LIBRARY: ~a~%" *json-library*)
(defparameter *depends*
(cons *json-library* (list :puri :split-sequence :drakma :cl-ppcre :cl-fad :alexandria :ironclad)))
(defparameter *jsd-inner-filename* (if (eq *json-library* :st-json) "jsd-st-json" "jsd-yason"))
(eval `(asdf:defsystem :cl-json-ld
:name "CL-JSON-LD"
:description "JSON-LD API implementation"
:author "RD Projekt Sp. z o.o. Sp. k."
:licence "GPL v3 (see COPYING.txt)"
:version "0.1"
:depends-on ,*depends*
:components ((:static-file "cl-json-ld.asd")
(:static-file "COPYING.txt")
(:static-file "README.md")
(:module src
:components ((:file "package")
(:file "utils" :depends-on("package"))
(:file "sha1" :depends-on("package"))
(:file ,*jsd-inner-filename* :depends-on("utils"))
(:file "jsd-hashmap" :depends-on("utils" ,*jsd-inner-filename*))
(:file "jsonld" :depends-on("utils" "jsd-hashmap"))
(:file "context" :depends-on("utils" "jsd-hashmap"))
(:file "compact" :depends-on("utils" "jsd-hashmap"))
(:file "flatten" :depends-on("utils" "jsd-hashmap"))
(:file "normalize" :depends-on("utils" "jsd-hashmap"))
(:file "frame" :depends-on("utils" "jsd-hashmap")))))))
(asdf:defsystem :cl-json-ld-tests
:description "JSON-LD API tests"
:author "RD Projekt Sp. z o.o. Sp. k."
:version "0.1"
:depends-on (:cl-fad :fiveam :cl-json-ld)
:components ((:module src
:components ((:file "package-tests")
(:file "unit-tests" :depends-on("package-tests"))))))
;; In order to execute tests first load the current asd file (e.g. (load "cl-json-ld.asd"))
;; Then execute (asdf:operate 'asdf:test-op :cl-json-ld-tests)
;; In order to use non-default manifest path use (cl-json-ld-tests:run-unit-tests <manifest-path>)
(defparameter *jsonld-tests-manifest*
(let ((jsonld-dir (make-pathname :directory (pathname-directory *load-truename*))))
(merge-pathnames "./json-ld.org/test-suite/manifest.jsonld" jsonld-dir)))
(defmethod perform ((op test-op) (c (eql (find-system :cl-json-ld-tests))))
(format t "~&Running unit tests with manifest: ~s" *jsonld-tests-manifest*)
(funcall (intern (symbol-name `#:run-unit-tests) :cl-json-ld-tests) *jsonld-tests-manifest*))
| 3,609 | Common Lisp | .asd | 69 | 44.753623 | 101 | 0.617914 | RDProjekt/cl-json-ld | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 952ed62d3c78d685c0d85e56c6e6433c25d9b56b2a2ded2a5f63920e1306bfa6 | 16,495 | [
-1
] |
16,523 | parallax-demo.lisp | sebity_parallax-demo/parallax-demo.lisp | ;;;; parallax-demo.lisp
(in-package #:parallax-demo)
;;;;;;;;;;;;;;;;;;;;;;;; CONFIG/PRESETS ;;;;;;;;;;;;;;;;;;;;;;;;
(defparameter *data-root* (asdf:system-source-directory 'parallax-demo))
(defparameter *gfx-root* (merge-pathnames "gfx/" *data-root*))
;;;; Game Params
(defparameter *game-width* 800)
(defparameter *game-height* 600)
(defparameter *game-ticks* 0)
(defparameter *pause* nil)
(defparameter *max-speed* 20)
(defparameter *car* nil) ; width 200
(defparameter *road* nil) ; width 1190
(defparameter *mountain-front* nil) ; width 1190
(defparameter *mountain-behind* nil) ; width 1190
(defparameter *tree* nil)
(defparameter *cells* nil)
(defparameter *ss-car* nil)
;;;; GFX Params
(defparameter *gfx-ss-car* (merge-pathnames "cars.png" *gfx-root*))
(defparameter *gfx-road* (merge-pathnames "road.png" *gfx-root*))
(defparameter *gfx-mountain-front* (merge-pathnames "mountain1.png" *gfx-root*))
(defparameter *gfx-mountain-behind* (merge-pathnames "mountain2.png" *gfx-root*))
(defparameter *gfx-tree* (merge-pathnames "tree.png" *gfx-root*))
;;;;;;;;;;;;;;;;;;;;;;;; STRUCTS ;;;;;;;;;;;;;;;;;;;;;;;;
(defstruct the-car
(x 0)
(y 0)
(vx 0))
(defstruct road
(x 0)
(y 0))
(defstruct mountain
(x 0)
(y 0))
(defstruct the-tree
(x 0)
(y 0))
;;;;;;;;;;;;;;;;;;;;;;;; SLIME ;;;;;;;;;;;;;;;;;;;;;;;;
;;;; CONTINUABLE macro
(defmacro continuable (&body body)
`(restart-case
(progn ,@body)
(continue () :report "Continue")))
;;;; UPDATE-SWANK function
(defun update-swank ()
(continuable
(let ((connection (or swank::*emacs-connection*
(swank::default-connection))))
(when connection
(swank::handle-requests connection t)))))
;;;;;;;;;;;;;;;;;;;;;;;; CAR ;;;;;;;;;;;;;;;;;;;;;;;;
;;;; CREATE-CAR function
(defun create-car ()
(setf *car* (make-the-car :x 300 :y 300 :vx 0)))
;;;; DISPLAY-CAR function
(defun display-car (c)
(sdl:draw-surface-at-* *ss-car* (the-car-x c) (the-car-y c)
:cell (floor (mod *game-ticks* 19) 4)))
;;;; MOVE-CAR function
(defun move-car (c speed)
(cond ((equal speed 'accelerate) (unless (= (the-car-vx c) *max-speed*)
(setf (the-car-vx c) (+ (the-car-vx c) 2))))
((equal speed 'decelerate) (unless (zerop (the-car-vx c))
(setf (the-car-vx c) (- (the-car-vx c) 2))))))
;;;; UPDATE-CAR function
(defun update-car (c)
(setf (the-car-x c) (+ (the-car-x c) (the-car-vx c))))
;;;;;;;;;;;;;;;;;;;;;;;; TREE ;;;;;;;;;;;;;;;;;;;;;;;;
;;;; CREATE-TREE function
(defun create-tree ()
(setf *tree* (make-the-tree :x 900 :y -100)))
;;;; DISPLAY-TREE function
(defun display-tree (tr)
(sdl:draw-surface-at-* (sdl:load-image *gfx-tree* :alpha 255) (the-tree-x tr) (the-tree-y tr)))
;;;; UPDATE-TREE function
(defun update-tree (c tr)
(setf (the-tree-x tr) (- (the-tree-x tr) (* (the-car-vx c) 4)))
(determine-repeat-tree tr))
;;;; DETERMINE-REPEAT-TREE function
(defun determine-repeat-tree (tr)
(when (< (the-tree-x tr) -900)
(setf (the-tree-x tr) 900)))
;;;;;;;;;;;;;;;;;;;;;;;; ROAD ;;;;;;;;;;;;;;;;;;;;;;;;
;;;; CREATE-ROAD function
(defun create-road ()
(push (make-road :x 0 :y 350) *road*)
(push (make-road :x 1190 :y 350) *road*))
;;;; DISPLAY-ROAD function
(defun display-road (roads)
(dolist (r roads)
(sdl:draw-surface-at-* (sdl:load-image *gfx-road* :alpha 255) (road-x r) (road-y r))))
;;;; UPDATE-ROAD function
(defun update-road (c roads)
(dolist (r roads)
(setf (road-x r) (- (road-x r) (the-car-vx c))))
(determine-furthest-road))
;;;; DETERMINE-FURTHEST-ROAD function
(defun determine-furthest-road ()
(let ((road-1 (road-x (first *road*)))
(road-2 (road-x (second *road*))))
(when (< road-1 -1300)
(setf (road-x (first *road*)) (+ road-2 1190)))
(when (< road-2 -1300)
(setf (road-x (second *road*)) (+ road-1 1190)))))
;;;;;;;;;;;;;;;;;;;;;;;; MOUNTIAN ;;;;;;;;;;;;;;;;;;;;;;;;
;;;; CREATE-MOUNTAIN function
(defun create-mountain ()
; Front Mountain
(push (make-mountain :x 0 :y 0) *mountain-front*)
(push (make-mountain :x 1180 :y 0) *mountain-front*)
; Behind Mountain
(push (make-mountain :x 0 :y -50) *mountain-behind*)
(push (make-mountain :x 1190 :y -50) *mountain-behind*))
;;;; DISPLAY-MOUNTAINS function
(defun display-mountains ()
(dolist (m *mountain-behind*)
(sdl:draw-surface-at-* (sdl:load-image *gfx-mountain-behind* :alpha 255)
(mountain-x m) (mountain-y m)))
(dolist (m *mountain-front*)
(sdl:draw-surface-at-* (sdl:load-image *gfx-mountain-front* :alpha 255)
(mountain-x m) (mountain-y m))))
;;;; UPDATE-MOUNTAINS function
(defun update-mountains (c)
(dolist (m *mountain-front*)
(setf (mountain-x m) (- (mountain-x m) (the-car-vx c))))
(dolist (m *mountain-behind*)
(setf (mountain-x m) (- (mountain-x m) (floor (the-car-vx c) 3))))
(determine-furthest-mountain))
;;;; DETERMINE-FURTHEST-MOUNTAIN function
(defun determine-furthest-mountain ()
(let ((mountain-1 (mountain-x (first *mountain-front*)))
(mountain-2 (mountain-x (second *mountain-front*)))
(mountain-3 (mountain-x (first *mountain-behind*)))
(mountain-4 (mountain-x (second *mountain-behind*))))
(when (< mountain-1 -1300)
(setf (mountain-x (first *mountain-front*)) (+ mountain-2 1180)))
(when (< mountain-2 -1300)
(setf (mountain-x (second *mountain-front*)) (+ mountain-1 1180)))
(when (< mountain-3 -1300)
(setf (mountain-x (first *mountain-behind*)) (+ mountain-4 1180)))
(when (< mountain-4 -1300)
(setf (mountain-x (second *mountain-behind*)) (+ mountain-3 1180)))))
;;;;;;;;;;;;;;;;;;;;;;;; THE GAME ;;;;;;;;;;;;;;;;;;;;;;;;
;;;; UPDATE-GAME-TICKS function
(defun update-game-ticks ()
(setf *game-ticks* (incf *game-ticks*)))
;;;; RENDER function
(defun render ()
(update-swank)
(sdl:clear-display sdl:*white*)
(update-game-ticks)
(update-road *car* *road*)
(update-mountains *car*)
(update-tree *car* *tree*)
(display-mountains)
(display-road *road*)
(display-car *car*)
(display-tree *tree*)
(sdl:update-display))
;;;; INITIALIZE-GAME function
(defun initialize-game ()
(setf *pause* nil)
(setf *game-ticks* 0)
(setf *car* nil)
(setf *road* nil)
(setf *mountain-front* nil)
(setf *mountain-behind* nil)
(setf *tree* nil)
(create-car)
(create-road)
(create-mountain)
(create-tree))
;;;; LOAD-SPRITE-SHEET function
(defun load-sprite-sheet ()
; enemy sprite sheet
(setf *ss-car* (sdl:load-image *gfx-ss-car* :alpha 255))
(setf *cells* '((0 0 200 97) (200 0 200 97) (400 0 200 97) (600 0 200 97) (800 0 200 97)))
(setf (sdl:cells *ss-car*) *cells*))
;;;; START function
(defun start ()
(initialize-game)
(sdl:with-init (sdl:sdl-init-video)
(sdl:window *game-width* *game-height* :title-caption "Parallax Demo")
(setf (sdl:frame-rate) 30)
(load-sprite-sheet)
(sdl:with-events ()
(:quit-event () t)
(:key-down-event (:key key)
(case key
(:sdl-key-right (move-car *car* 'accelerate))
(:sdl-key-left (move-car *car* 'decelerate))
(:sdl-key-escape (sdl:push-quit-event))))
(:key-up-event (:key key)
(case key))
(:idle ()
;(when (sdl:get-key-state :sdl-key-up) (move-player 'player 'up))
;(when (sdl:get-key-state :sdl-key-down) (move-player 'player 'down))
(render)))))
| 7,377 | Common Lisp | .lisp | 199 | 33.628141 | 97 | 0.619788 | sebity/parallax-demo | 4 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | ecdf89694113702ba14c731005014590de9865711468686e8eac89d7bbad2f16 | 16,523 | [
-1
] |
16,524 | parallax-demo.asd | sebity_parallax-demo/parallax-demo.asd | ;;;; parallax-demo.asd
(asdf:defsystem #:parallax-demo
:description "A Parallax Scrolling demo"
:author "Jan Tatham <[email protected]>"
:license "GPL v2"
:depends-on (#:lispbuilder-sdl)
:serial t
:components ((:file "package")
(:file "parallax-demo")))
| 280 | Common Lisp | .asd | 9 | 26.888889 | 42 | 0.665428 | sebity/parallax-demo | 4 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 3a44d9d561de8cbdb28bf1c50707e0969e2bfe82ec9677661fe4964641c199f9 | 16,524 | [
-1
] |
16,542 | run-tests.lisp | zltl_cc/run-tests.lisp |
(load "cc.asd")
(load "cc-tests.asd")
(ql:quickload "cc-tests")
(in-package :cc-tests)
(uiop:quit (if (run-all-tests) 0 1))
| 128 | Common Lisp | .lisp | 5 | 23.8 | 36 | 0.672269 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | b960dbd46b692d4508fccdc2b1913a9dbd48531a154d9957013418c30483f414 | 16,542 | [
-1
] |
16,543 | run.lisp | zltl_cc/run.lisp | "
Usage:
rlwrap sbcl --load run.lisp
This loads the project's asd, loads the quicklisp dependencies, and
calls the main function.
Then, we are given the lisp prompt.
If you don't want to land in the REPL, you can (quit) below or call lisp with the --non-interactive flag.
Another solution to run the app is to build and run a binary (see README).
"
(load "cc.asd")
(ql:quickload "cc")
(in-package :cc)
(handler-case
(main)
(error (c)
(format *error-output* "~&An error occured: ~a~&" c)
(uiop:quit 1)))
| 525 | Common Lisp | .lisp | 17 | 28.588235 | 105 | 0.718 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | f32613b4511817436158de55f8a52d528ffc4d702f6f0cff5516a9f7470dca96 | 16,543 | [
-1
] |
16,544 | http-simple-server.lisp | zltl_cc/examples/http-simple-server.lisp | (in-package :cc-examples)
(defun handle-root (req)
(log:info "/ => return 111")
(http:request-reply-string req http:+ok+ "111"))
(defun handle-error (req)
(log:info "/error => 500")
(/ 3 0))
(defun handle-foo (req)
(log:info "/foo => return 222")
(http:request-reply-string req http:+ok+ "222"))
;; html generator
(defparameter *shopping-list*
'("Atmospheric ponds"
"Electric gumption socks"
"Mrs. Leland's embyronic television combustion"
"Savage gymnatic aggressors"
"Pharmaceutical pianos"
"Intravenous retribution champions"))
(defparameter *user-name* "John Q. Lisper")
(defparameter *last-login* "12th Never")
(defmacro with-page ((&key title) &body body)
`(with-html-string
(:doctype)
(:html
(:head
(:title ,title))
(:body ,@body))))
(defun shopping-list ()
(with-page (:title "Home page")
(:header
(:h1 "Home page"))
(:section
("~A, here is *your* shopping list: " *user-name*)
(:ol (dolist (item *shopping-list*)
(:li (1+ (random 10)) item))))
(:footer ("Last login: ~A" *last-login*))))
(defun handle-shop (req)
(log:info "/html/shop => return generated html")
(http:request-reply-string req http:+ok+ (shopping-list)))
(defun handle-json (req)
(log:info "/json/bar => return json")
(let ((h (http:make-keyvals)))
(http:keyvals-add h "Content-Type" "application/json")
(http:request-set-output-headers req h))
(http:request-reply-string
req
http:+ok+
(json:encode-json-to-string '#(((foo . (1 2 3)) (bar . t) (baz . #\!)) "quux" 4/17 4.25))))
(defun handle-post-json (req)
(log:info "/json/bar => parse json then echo")
(let ((h (http:make-keyvals)))
(http:keyvals-add h "Content-Type" "application/json")
(http:request-set-output-headers req h))
(let* ((inbuf (http:request-get-input-buffer req))
(instr (net:buffer-to-string inbuf)))
(log:info "request body = ~a" instr)
(log:info "parsed: ~a" (json:decode-json-from-string instr))
(http:request-reply-string
req
http:+ok+
instr)))
(defun handle-varname3 (req)
(log:info "/text/:xxx/:yyy/:zzz => return 222")
(let ((params (list
(http:request-param req "xxx")
(http:request-param req "yyy")
(http:request-param req "zzz"))))
(log:info "param: ~a" params)
(let ((h (http:make-keyvals)))
(http:keyvals-add h "Content-Type" "application/json")
(http:request-set-output-headers req h))
(http:request-reply-string req http:+ok+ (json:encode-json-to-string params))))
(defun handle-varname2 (req)
(log:info "/text/:xxx/:yyy => return 222")
(let ((params (list
(http:request-param req "xxx")
(http:request-param req "yyy"))))
(log:info "param: ~a" params)
(let ((h (http:make-keyvals)))
(http:keyvals-add h "Content-Type" "application/json")
(http:request-set-output-headers req h))
(http:request-reply-string req http:+ok+ (json:encode-json-to-string params))))
(defun handle-varname1 (req)
(log:info "/text/:xxx => return 222")
(let ((params (list
(http:request-param req "xxx"))))
(log:info "param: ~a" params)
(let ((h (http:make-keyvals)))
(http:keyvals-add h "Content-Type" "application/json")
(http:request-set-output-headers req h))
(http:request-reply-string req http:+ok+ (json:encode-json-to-string params))))
(defun handle-varname-jump (req)
(log:info "/jump/:xxx/foo => return 222")
(let ((params (list
(http:request-param req "xxx"))))
(log:info "param: ~a" params)
(let ((h (http:make-keyvals)))
(http:keyvals-add h "Content-Type" "application/json")
(http:request-set-output-headers req h))
(http:request-reply-string req http:+ok+ (json:encode-json-to-string params))))
(defun handle-matchall (req)
(log:info "/mall/*rest => return 222")
(let ((params (list
(http:request-param req "rest"))))
(log:info "param: ~a" params)
(let ((h (http:make-keyvals)))
(http:keyvals-add h "Content-Type" "application/json")
(http:request-set-output-headers req h))
(http:request-reply-string req http:+ok+ (json:encode-json-to-string params))))
(defun http-simple-server ()
"Entry point for the example."
(log:info "start http-simple-server")
(event:with-base-loop (eb)
(let ((srv (http:server-new eb))
(mux (http:mux-new)))
;; set handles to mux
(http:mux-get mux "/" #'handle-root)
(http:mux-get mux "/error" #'handle-error)
(http:mux-get mux "/text/foo" #'handle-foo)
(http:mux-get mux "/html/shop" #'handle-shop)
(http:mux-get mux "/json/bar" #'handle-json)
(http:mux-post mux "/json/bar" #'handle-post-json)
(http:mux-get mux "/text/:xxx/:yyy/:zzz" #'handle-varname3)
(http:mux-get mux "/text/:xxx/:yyy" #'handle-varname2)
(http:mux-get mux "/text/:xxx" #'handle-varname1)
(http:mux-get mux "/jump/:xxx/foo" #'handle-varname-jump)
(http:mux-get mux "/mall/*rest" #'handle-matchall)
;; print mux list
(http:mux-dfs-print (http:mux-root mux) nil)
;; bind server with address and port
(http:server-bind srv
(net:sockaddr-from-string "0.0.0.0:8899"))
;; the default content type
(http:server-set-default-content-type srv "text/html")
;; set MUX to server SRV as request handle
(http:server-set-cb srv :cb (http:mux-serve mux)))))
| 5,373 | Common Lisp | .lisp | 136 | 34.941176 | 94 | 0.645223 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | f9ca13aff3e9f10df82640cf63d64f441b09424c5be264e0fdcd6df2ad98b3ba | 16,544 | [
-1
] |
16,545 | packages.lisp | zltl_cc/examples/packages.lisp | (defpackage :cc-examples
(:use :cl :common-lisp :cffi :spinneret)
(:export
:http-simple-server
))
| 108 | Common Lisp | .lisp | 5 | 18.6 | 42 | 0.679612 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 9d643d82f94708d149f0a15263a392eb244d4038edd55103c63704d73761b2b9 | 16,545 | [
-1
] |
16,546 | log.lisp | zltl_cc/src/log.lisp | (in-package :cc-log)
;; TODO change to info
(log:config :D
:pretty
:thread
:package
:sane :this-console)
(log:debug "logger loaded")
| 157 | Common Lisp | .lisp | 8 | 15.625 | 27 | 0.648276 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | c5b2d6f978fb6f3589fb974982ee67fc2150a2332c0f1f606ea10dfcc83fd970 | 16,546 | [
-1
] |
16,547 | util.lisp | zltl_cc/src/util.lisp | (in-package :cc-util)
(defun make-pointer-eql-able (pointer)
"Abstraction to make a CFFI pointer #'eql to itself. Does its best to be the
most performant for the current implementation."
(when pointer
#+(or ccl)
pointer
#-(or ccl)
(if (cffi:pointerp pointer)
(cffi:pointer-address pointer)
pointer)))
| 349 | Common Lisp | .lisp | 11 | 26.363636 | 78 | 0.667656 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | cc194fb99503d35d902f128022eb25089dfab7eb96519dd4d51faa38b2f51eb1 | 16,547 | [
-1
] |
16,548 | error.lisp | zltl_cc/src/error.lisp | (in-package :cc-error)
(define-condition cc-error (error)
((msg :initarg :msg
:initform ""
:accessor msg))
(:documentation "Custom error of cc"))
(define-condition invalid-duration-string (cc-error)
()
(:documentation "Error when parse duration that not a valid duration string"))
(define-condition oom (cc-error)
()
(:documentation "Error when alloc functions return nil"))
(define-condition already-start (cc-error)
()
(:documentation "Error when duplicate call starting functions"))
(define-condition bad-argument (cc-error)
()
(:documentation "Error processing arguments"))
(define-condition conflict (cc-error)
()
(:documentation "Error when conflict occur"))
| 697 | Common Lisp | .lisp | 21 | 30.666667 | 80 | 0.744776 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | d48cfa28bc963b0e41acdb1d30095fb024abc8c23be4cb8f77ba6e1b3e868395 | 16,548 | [
-1
] |
16,549 | event.lisp | zltl_cc/src/event.lisp | (in-package :cc-event)
;; use pthread globally
(cc-libevent:evthread-use-pthreads)
;; id generator for base:id
;; class BASE have an id field, function next-id generate an autoincrement
;; integer id for it.
(defvar *event-base-next-id* 0)
(defvar *event-base-id-lock* (bt:make-lock))
(defun next-id ()
"Advance *event-base-next-id* and return old value."
(bt:with-lock-held (*event-base-id-lock*)
(let* ((r *event-base-next-id*)
(*event-base-next-id* (+ r 1)))
r)))
(defconstant +EV-TIMEOUT+ #x01)
(defconstant +EV-READ+ #x02)
(defconstant +EV-WRITE+ #x04)
(defconstant +EV-SIGNAL+ #x08)
(defconstant +EV-PERSIST+ #x10)
(defconstant +EV-ET+ #x20)
(defconstant +EV-FINALIZE+ #x40)
(defconstant +EV-CLOSED+ #x80)
;; wraper for C libevent's event, containing C event, base instance and
;; callback functions.
(defstruct event
;; result of event_new()
c
;; the base object
base
;; default callback function
;; FORM: (cb event &optional arg1 arg2 arg3 ...)
cb
;; argument list of callback function
cb-arg-list
;; the event types that trigger
triggered-event-types)
(defun event-fd (ev)
"Get the socket or signal assigned to an event, or -1 if the
event has no socket."
(cc-libevent:event-get-fd (event-c ev)))
(defun event-types (ev)
"Get the event that triggered, only canbe call from event
callback functions."
(event-triggered-event-types ev))
;; map from C event pointer to struct event
(defvar *event-table* (make-hash-table :test #'eql))
(defvar *event-table-lock* (bt:make-lock))
(defun event-table-get (pointer)
"Get event struct by pointer form hash table *event-table*"
(bt:with-lock-held (*event-table-lock*)
(gethash (cc-util:make-pointer-eql-able pointer)
*event-table*)))
(defun event-table-set (pointer event)
"Set pointer-> event-struct into hash table *event-table*"
(bt:with-lock-held (*event-table-lock*)
(setf (gethash (cc-util:make-pointer-eql-able pointer)
*event-table*)
event)))
(defun event-table-del (pointer)
"Clear out event for the givent pointer"
(bt:with-lock-held (*event-table-lock*)
(remhash (cc-util:make-pointer-eql-able pointer)
*event-table*)))
;; default defer queue size
(defconstant +default-defer-task-queue-size+ 40000)
;; the core dispather class
(defclass base ()
((c :accessor base-c :initarg c :initform nil
:documentation "Holds the C object that event_base_new() created.")
(dns-c :accessor base-dns-c :initarg dns-c :initform nil
:documentation "Holds the C object that evdns_base-new()
created.")
(ev :accessor base-ev :initarg ev :initform nil
:documentation "Holds the event for running differ queues tasks")
(id :accessor base-id :initarg :id :initform (next-id))
(defer-task-queue
:accessor base-defer-task-queue :initarg defer-task-queue
:initform (lparallel.queue:make-queue
:fixed-capacity +default-defer-task-queue-size+))
(lock :accessor base-lock :initarg :lock :initform (bt:make-lock))
(started :accessor base-started :initarg :started :initform nil
:documentation "Flag to specify that if loop started and
not stop yet."))
(:documentation
"A class that holds event base and all the state it manages."))
;; Callback function called by libevent when event trigger.
;; Find the lispy event from hash-table and call the real
;; function in lisp.
(defcallback base-event-callback :void
((fd :int) (event-types :short) (arg :pointer))
;; arg always be pointer to event it self
(let* ((ev (event-table-get arg))
(cb-args (event-cb-arg-list ev)))
(if ev
;; (apply (alexandria:curry (event-cb ev) ev) cb-args)
;; seems APPLY is enough
(progn
(setf (event-triggered-event-types ev) event-types)
(apply (event-cb ev) ev cb-args))
;; log error if event-struct not exists
;; MUST be a bug here
(log:error "event not found ~a" arg))))
(defmethod event-new ((eb base) fd event-types cb &optional &rest arg-list)
"Create a event struct and register callback functions."
(let ((event (make-event :base eb :cb cb :cb-arg-list arg-list))
(event-c (cc-libevent:event-new (base-c eb)
fd
event-types
(callback base-event-callback)
(cc-libevent:event-self-cbarg))))
(if (null-pointer-p event-c) (error oom :msg "event-new"))
(setf (event-c event) event-c)
(event-table-set event-c event)
event))
(defun event-free (event)
"Deallocate event struct and free c event. If the event is pending or
active, this function makes it non-pending and non-active first."
(defer-submit (event-base event)
(lambda ()
(and (event-c event)
(cc-libevent:event-free (event-c event))
(event-table-del (event-c event))
(setf (event-c event) nil)))))
(defun event-add (ev timeout)
"Add event to the set of pending events
EB: base
EV: the event struct
TIMEOUT: '(second, microsecond) the time to wait for the event"
(defer-submit (event-base ev)
(lambda ()
(and (event-c ev)
(let ((eb (event-base ev)))
(cc-timeval:with-c-timeval-values (tv timeout)
(cc-libevent:event-add (event-c ev) tv)))))))
(defun event-del (event)
"Remove an event from the set of monitored events."
(defer-submit (event-base ev)
(lambda ()
(and (event-c event)
(cc-libevent:event-del (event-c event))))))
;; struct holding defer task fn and arg
(defstruct defer-task
;; function
;; form (cb cb-arg1 cb-arg2 cb-arg2)
cb
;; argument list
cb-args)
(defmethod defer-task-runner ((eb base) event)
"Pop all task and run until queue empty"
(loop for task = (lparallel.queue:try-pop-queue (base-defer-task-queue eb))
while task
do
;; apply function
(apply (defer-task-cb task)
(defer-task-cb-args task))))
(defun defer-task-callback (event)
"Callback of defer task event."
(defer-task-runner (event-base event) event))
(defmethod defer-submit ((eb base) cb &optional &rest cb-args)
"Submit defer task."
(lparallel.queue:push-queue
(make-defer-task :cb cb :cb-args cb-args)
(base-defer-task-queue eb))
(cc-libevent:event-active (event-c (base-ev eb)) 0 0))
;; timer
(defstruct timer
;; the callback
;; FORM as (cb cb-arg)
cb
;; arguments of callback
cb-args)
(defun timer-base-callback (event timer)
"callback function of timer, arg always be the timer object"
;; callback
(apply (timer-cb timer) (timer-cb-args timer))
;; free event
(event-free event))
(defmethod timer-submit ((eb base) timeout cb &optional &rest cb-args)
"Create, pending and return timer event. The return value can be use
EVENT-FREE to cancel
TIMEOUT: '(second, microsecond) the time to wait for the event
CB: callback function when timer trigger. Form as (cb event event-types cb-arg)
CB-ARG-LIST: arguments of cb
"
;; for multiple thread app, we add timer task in a defer task
(let* ((timer (make-timer :cb cb :cb-args cb-args))
(event (event-new eb -1 0 #'timer-base-callback timer)))
(event-add event timeout)
event))
(defmethod base-init/nolock ((eb base))
"Alloc c and ev"
;; just return if already init
(or (base-c eb)
(let* ((eb-c (cc-libevent:event-base-new))
;; new dns-base
(dns-c nil)
;; new defer task notificer event
(eb-ev nil))
;; error when return null
(and (null-pointer-p eb-c)
(error cc-error:oom :msg "event-base-new"))
(setf dns-c
(cc-libevent:evdns-base-new
eb-c
cc-libevent:+EVDNS-BASE-INITIALIZE-NAMESERVERS+))
(and (null-pointer-p dns-c)
(progn
(cc-libevent:event-base-free eb-c)
(error cc-error:oom :msg "evdns-base-new")))
;; load /etc/hosts
(with-foreign-string (fname "/etc/hosts")
(cc-libevent:evdns-base-load-hosts dns-c fname))
(setf (base-c eb) eb-c)
(setf (base-dns-c eb) dns-c)
(setf eb-ev (event-new eb -1 cc-libevent:+EV-PERSIST+
#'defer-task-callback))
(setf (base-ev eb) eb-ev)))
eb)
(defmethod base-init ((eb base))
"Initialize base"
(bt:with-lock-held ((base-lock eb))
(base-init/nolock eb)))
(defmethod base-deinit/nolock ((eb base))
"Dealloc c and ev"
(and (base-ev eb)
(cc-libevent:event-free (event-c (base-ev eb))))
(and (base-dns-c eb)
(cc-libevent:evdns-base-free (base-dns-c eb) 0))
(and (base-c eb)
(cc-libevent:event-base-free (base-c eb)))
(setf (base-ev eb) nil)
(setf (base-c eb) nil)
(setf (base-dns-c eb) nil))
(defmethod base-deinit ((eb base))
"Uninitialize base, free C objects."
(bt:with-lock-held ((base-lock eb))
(base-deinit/nolock eb)))
(defmethod base-loop-started-p ((eb base))
"Return t if loop started"
(bt:with-lock-held ((base-lock eb))
(base-started eb)))
(defmethod base-loop-start ((eb base))
"Wait for events to become active, and run their callbacks."
;; start loop
(or (base-loop-started-p eb)
(progn
(bt:with-lock-held ((base-lock eb))
(setf (base-started eb) t))
(cc-libevent:event-base-loop
(base-c eb)
cc-libevent:+EVLOOP-NO-EXIT-ON-EMPTY+)
(bt:with-lock-held ((base-lock eb))
(setf (base-started eb) nil)))))
(defmethod base-loop-stop ((eb base))
"Stop the event loop."
(and (base-loop-started-p eb)
(cc-libevent:event-base-loopexit (base-c eb) (null-pointer))))
;; create event-base eb, run body, then start loop
(defmacro with-base-loop ((eb) &body body)
`(let ((,eb (make-instance 'base)))
(base-init ,eb)
(defer-submit ,eb (lambda () ,@body))
(base-loop-start ,eb)
(base-deinit ,eb)))
| 9,578 | Common Lisp | .lisp | 264 | 32.416667 | 79 | 0.687575 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 46fbc38e3d4a602a80dfd38f9adf94471436828bd0d300035ea93f179ac557f8 | 16,549 | [
-1
] |
16,550 | errno.lisp | zltl_cc/src/errno.lisp | (in-package :cc-errno)
(defcvar "errno" :int)
(defcfun (strerror "strerror") :string (errno :int))
(defun str ()
"Return string by C code: strerror(errno)"
(strerror *errno*))
(defun code ()
"Return linux C integer variable value: errno"
*errno*)
| 259 | Common Lisp | .lisp | 9 | 26.444444 | 52 | 0.699187 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | f0cb765f73ec83b33ffabee26a0986224caceed6b77d7ff4fc9b548c9bc86d9f | 16,550 | [
-1
] |
16,551 | conf.lisp | zltl_cc/src/conf.lisp | (in-package :cc-conf)
(defclass conf ()
((name :documentation "Name of configuration"
:initform "CC"
:initarg :name
:type string
:accessor name)
(try-files :documentation "Files list that conf will try to load,
yaml format only"
:initform nil
:initarg :try-files
:accessor try-files
:type list)
(from-env :documentation "Load from environtment variables if
t. E.g. if you search \"cc.foo.bar\", env registry will look for env
variable name \"CC_FOO_BAR\""
:initform t
:initarg :from-env
:accessor from-env)
(env-prefix :documentation "Defines a prefix that ENVIRONMENT
variables will use. E.g. if your prefix is \"CC\", the env registry
will look for env variable that start with \"CC_\""
:initform ""
:initarg :env-prefix
:accessor env-prefix
:type string)
(yaml-object :documentation "Object that store results of
yaml:parse"
:initform nil))
(:documentation "Configuration class"))
(defparameter *default-conf*
(make-instance 'conf
:name "cc-conf"
:try-files (list "/etc/config.yaml" "./config.yaml")
:from-env t
:env-prefix "")
"The default conf")
(defmethod load-yaml ((c conf))
"Load and return yaml files from try-files, set object to
conf:yaml-object."
(with-slots (yaml-object try-files) c
(let ((real-filename nil))
(loop for filename in try-files
until real-filename
do (setf real-filename (probe-file filename)))
(and real-filename (setf yaml-object (yaml:parse real-filename))))))
(defun string/int/float (str)
"Check if str can parse to float or int, float -> 'float
int -> 'int
else return 'string"
(if (not str) nil
(let ((have-chr nil)
(have-dot nil))
(loop for c across str
for digit = (digit-char-p c)
:until have-chr
do
(and (not digit)
(case c
(#\. (setf have-dot t))
(otherwise (setf have-chr t)))))
(or (and have-chr 'string)
(and have-dot 'float)
(and t 'int)))))
(defun dot-split-to-env-name (name &optional &key env-prefix)
"Convert dot-split string like \"cc.foo.bar\" to environment
variable name like \"CC_FOO_BAR\", with env-prefix concated as
prefix."
(let ((suffix (string-upcase (ppcre:regex-replace-all "\\." name "_"))))
(if (> (length env-prefix) 0)
(concatenate 'string env-prefix "_" suffix)
suffix)))
(defun parse-float (str)
(with-input-from-string (s str)
(car (loop
:for num := (read s nil nil)
:while num
:collect num))))
(defun parse-duration (str)
"Parse string to seconds and microseconds as multiple value. 1d3h12m1s.123
where 123 is microsecond, 1s=1e6 microsecond."
(let ((second 0)
(microsecond 0)
(value 0)) ;; value store temp number
(loop for idex from 0 to (- (length str) 1)
do
(let* ((chr (aref str idex)) ;; chr = char of str[idex]
(digit (digit-char-p chr))) ;; digit = digit number of chr
(if digit
;; if is digit, value = value *10 + digit
(setf value (+ (* 10 value) digit))
;; else check d,h,m,s .xxxx
(case chr
(#\. (setf second (+ second value)
microsecond
(* 1000000 (parse-float (subseq str idex)))
value 0
;; break when reach .xyz
idex (length str)))
(#\d (setf second (+ second (* 60 60 24 value))
value 0))
(#\h (setf second (+ second (* 60 60 value))
value 0))
(#\m (setf second (+ second (* 60 value))
value 0))
(#\s (setf second (+ second value)
value 0))
(otherwise (error cc-error:invalid-duration-string
:msg (concatenate
'string
"Unreconize char: "
(string chr))))))))
(setf second (+ second value))
(values second microsecond)))
(defun get-string-from-env (name &optional &key env-prefix)
"Convert name to env-name and get env value string"
(let ((env-name (dot-split-to-env-name name :env-prefix env-prefix)))
(uiop:getenv env-name)))
(defun get-from-object (name obj)
"Get object from yaml object"
(let ((hierarches (ppcre:split "\\." name))
(cur-obj obj))
(dolist (field hierarches cur-obj)
(setf cur-obj
(if (hash-table-p cur-obj)
(gethash field cur-obj))))))
(defmethod get-value ((c conf) name)
"Get object specify by name like \"cc.foo.bar\""
;; get from env
(or (let ((v (get-string-from-env name :env-prefix (env-prefix c))))
(case (string/int/float v)
(string v)
(int (parse-integer v))
(float (parse-float:parse-float v))
(otherwise nil)))
;; get from conf::yaml-object
(get-from-object name (slot-value c 'yaml-object))))
(defun +load-yaml ()
"Load yaml file from try-files into *default-conf*:yaml-object."
(load-yaml *default-conf*))
(defun +get-value (name)
"Get object specify by name lik \"cc.foo.bar\" from *default-conf*"
(get-value *default-conf* name))
| 4,906 | Common Lisp | .lisp | 143 | 29.41958 | 76 | 0.644383 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 58023d49dd4f92c687069ffb8ec950ab5e3d7bffd8732cf3af33370dec9adf89 | 16,551 | [
-1
] |
16,552 | ip.lisp | zltl_cc/src/ip.lisp | (in-package :cc-net)
(defconstant +AF-INET+ 2)
(defconstant +AF-INET6+ 10)
(defconstant +V4+ 'V4)
(defconstant +V6+ 'V6)
(defconstant +max-ip-string-len+ 64)
(defclass ip ()
((family :accessor ip-family :initarg :ip-family :initform nil
:documentation "IP family: 'V4 or 'V6")
(addr :accessor ip-addr :initarg :ip-addr :initform nil
:documentation "The addr octet array"))
(:documentation
"The ip address"))
(defun ip-equal (a b)
"Compare if a and b are equal as IP instance."
(and
(equal (ip-family a) (ip-family b))
(equalp (ip-addr a) (ip-addr b))))
(defparameter *ipv4-scanner*
(cl-ppcre:create-scanner
"^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{2}|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{2}|[0-9])$"
:case-insensitive-mode t)
"Scanner that detects if a string is an IPV4 address.")
(defparameter *ipv6-scanner*
(cl-ppcre:create-scanner
"^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$"
:case-insensitive-mode t)
"Scanner that detects if a string is an IPV6 address.")
(defun ipv4-address-p (addr)
"Determine if the given host is an IPV4 addr or a hostname."
(cl-ppcre:scan *ipv4-scanner* addr))
(defun ipv6-address-p (addr)
"Determine if the given host is an IPV6 addr or a hostname."
(cl-ppcre:scan *ipv6-scanner* addr))
(defun ip-address-p (addr)
"Determine if the given host is an IP or a hostname."
(or (ipv4-address-p addr)
(ipv6-address-p addr)))
(defmethod ip-len ((ip ip))
"Get the length of ip address. 4 -> ipv4, 16 -> ipv6"
(if (eql (ip-family ip) 'V4)
4
16))
(defmethod ip-to-string ((ip ip))
"Convert ipv4/ipv6 address to string"
(and (ip-addr ip)
(let ((arr-len 4)
(af +AF-INET+)
(res nil))
(if (eql 'V6 (ip-family ip))
(progn (setf arr-len 16)
(setf af +AF-INET6+)))
(with-foreign-pointer-as-string (str +max-ip-string-len+)
(with-foreign-object (c-ip :uint8 arr-len)
;; set array value as ip
(dotimes (i arr-len)
(setf (mem-aref c-ip :uint8 i) (elt (ip-addr ip) i)))
;; call inet_ntop
(setf res (cc-libevent:evutil-inet-ntop af c-ip str +max-ip-string-len+)))))))
(defun ip-from-c-addr (ptr af-family)
"Convert C inet_addr or inet6_addr to IP instance."
(let ((arr-len 4)
(addr nil)
(family 'V4))
(if (eql af-family +AF-INET6+)
(progn (setf arr-len 16)
(setf family 'V6)))
(setf addr (make-array arr-len))
(dotimes (i arr-len)
(setf (elt addr i) (mem-aref ptr :uint8 i)))
(make-instance 'ip :ip-family family :ip-addr addr)))
(defun ip-copy-to-c-addr (mip ptr)
"Convert IP to C inet_addr or inet6_addr"
(let ((arr-len (ip-len mip))
(addr (ip-addr mip)))
(setf addr (make-array arr-len))
(dotimes (i arr-len)
(setf (mem-aref ptr :uint8 i) (elt addr i)))))
;; ipv4 for linux
(defcstruct in-addr-t
(s_addr :uint32))
(defcstruct sockaddr-in
(sin_family :ushort)
(sin_port :ushort)
(sin_addr (:struct in-addr-t)))
(defconstant +sockaddr-in-len+ (foreign-type-size '(:struct sockaddr-in)))
;; ipv6 for linux
(defcstruct in6-addr
(addr :int8 :count 16))
(defcstruct sockaddr-in6
(sin6_family :ushort)
(sin6_port :ushort)
(sin6_flowinfo :uint32)
(sin6_addr (:struct in6-addr))
(sin6_scope_id :uint32))
(defun ip-from-c-sockaddr (ptr)
(let ((so (sockaddr-from-c ptr)))
(sockaddr-ip so)))
(defun ip-from-string (str)
"Convert ipv4/ipv6 string to IP instance."
(let ((af +AF-INET+)
(family 'V4)
(arr-len 4)
(addr nil)
(res 0))
(if (not (ipv4-address-p str))
(progn (setf af +AF-INET6+)
(setf arr-len 16)
(setf family 'V6)))
(with-foreign-object (c-ip :uint8 arr-len)
(with-foreign-string (c-str str)
(setf res (cc-libevent:evutil-inet-pton af c-str c-ip)))
(if (eql res 1)
(ip-from-c-addr c-ip af)))))
(defmacro with-c-ip ((var ip) &body body)
"Convert ip to C then run body"
`(with-foreign-object (,var :uint8 (ip-len ip))
,@body))
(defclass sockaddr ()
((ip :accessor sockaddr-ip :initarg :ip :initform nil
:documentation "The ip address of socket")
(port :accessor sockaddr-port :initarg :port :initform nil
:documentation "Port of TCP/UDP")))
(defcfun (htons "htons") :uint16
(s :uint16))
(defun sockaddr-to-string (sock)
(concatenate 'string
(ip-to-string (sockaddr-ip sock))
":"
(write-to-string (sockaddr-port sock))))
(defmacro with-sockaddr-c ((sock sock-c sock-c-len) &body body)
"Convert sockaddr 'sock' to sockaddr_in 'sock-c' C object and run body."
`(with-foreign-pointer (,sock-c (+ +sockaddr-in-len+ 100) socklen)
(with-foreign-object (socklen-ptr :int 1)
(setf (mem-aref socklen-ptr :int 0) socklen)
(with-foreign-string (str (sockaddr-to-string sock))
(cc-libevent:evutil-parse-sockaddr-port str ,sock-c socklen-ptr)
(setf ,sock-c-len (mem-aref socklen-ptr :int 0))
,@body))))
(defmacro with-sockaddr-c-from-string ((sostr sock-c sock-c-len) &body body)
"Convert sockaddr 'sock' to sockaddr_in 'sock-c' C object and run body."
(let ((str-c (gensym))
(socklen-c (gensym))
(socklen-ptr-c (gensym)))
`(with-foreign-pointer (,sock-c (+ +sockaddr-in-len+ 100))
(with-foreign-object (,socklen-ptr-c :int 1)
(setf (mem-ref ,socklen-ptr-c :int) (+ +sockaddr-in-len+ 100))
(with-foreign-string (,str-c ,sostr)
(cc-libevent:evutil-parse-sockaddr-port ,str-c ,sock-c ,socklen-ptr-c)
(setf ,sock-c-len (mem-ref ,socklen-ptr-c :int))
,@body)))))
(defun sockaddr-from-c (ptr)
"Create sockaddr object from c sockaddr_in"
(let ((osin_family nil)
(inptr nil)
(sptr nil)
(port 0))
(with-foreign-slots ((sin_family sin_port sin_addr) ptr (:struct sockaddr-in))
(setf osin_family sin_family)
(setf port (htons sin_port)))
(let
((mip
(if (eql osin_family +AF-INET+)
;; ipv4
(let* ((sin-addr (foreign-slot-pointer ptr '(:struct sockaddr-in) 'sin_addr))
(s-addr (foreign-slot-pointer sin-addr '(:struct in-addr-t) 's_addr)))
(ip-from-c-addr s-addr osin_family))
;; ipv6
(let* ((sin6-addr (foreign-slot-pointer ptr '(:struct sockaddr-in6) 'sin6_addr))
(addr (foreign-slot-pointer sin6-addr '(:struct in6-addr) 'addr)))
(ip-from-c-addr addr osin_family)))))
(make-instance 'sockaddr :ip mip :port port))))
(defun sockaddr-from-string (str)
"Convert 127.0.0.1:1234 to sockaddr"
(with-sockaddr-c-from-string (str -sock-c -sock-c-len)
(sockaddr-from-c -sock-c)))
| 7,984 | Common Lisp | .lisp | 176 | 38.806818 | 1,084 | 0.575609 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | c3b8e007f2ed509330ade47a7dae36410d263f396db5aeed86bd6fc53288ed7d | 16,552 | [
-1
] |
16,553 | libevent.lisp | zltl_cc/src/libevent.lisp |
;; (ql:quickload "cffi")
;; bind libevent
(in-package :cc-libevent)
(define-foreign-library libevent
(:unix (:or "libevent.so"))
(t (:default "libevent")))
(define-foreign-library libevent_core
(:unix (:or "libevent_core.so"))
(t (:default "libevent_core")))
(define-foreign-library libevent_extra
(:unix (:or "libevent_extra.so"))
(t (:default "libevent_extra")))
(define-foreign-library libevent_openssl
(:unix (:or "libevent_openssl.so"))
(t (:default "libevent_openssl")))
(define-foreign-library libevent_pthreads
(:unix (:or "libevent_pthreads.so"))
(t (:default "libevent_pthreads")))
(use-foreign-library libevent)
(use-foreign-library libevent_core)
(use-foreign-library libevent_extra)
(use-foreign-library libevent_openssl)
(use-foreign-library libevent_pthreads)
;; begin /event2/event.h
(defcfun (event-enable-debug-mode "event_enable_debug_mode") :void)
(defcfun (event-debug-unassign "event_debug_unassign") :void
(event :pointer))
(defcfun (event-base-new "event_base_new") :pointer)
(defcfun (event-reinit "event_reinit") :int (base :pointer))
(defcfun (event-base-dispatch "event_base_dispatch") :int (base :pointer))
(defcfun (event-base-get-method "event_base_get_method") :string
(base :pointer))
(defcfun (event-get-supported-methods "event_get_supported_methods")
:pointer)
(defcstruct timeval
(tv_sec :ulong)
(tv_usec :ulong))
(defcfun (event-gettime-monotonic "event_gettime_monotonic") :int
(base :pointer)
(tp :pointer))
(defconstant +EVENT-BASE-COUNT-ACTIVE+ 1)
(defconstant +EVENT-BASE-COUNT-VIRTUAL+ 2)
(defconstant +EVENT-BASE-COUNT-ADDED+ 4)
(defcfun (event-base-get-num-events "event_base_get_num_events") :int
(eb :pointer)
(flags :uint))
(defcfun (event-base-get-max-events "event_base_get_max_events") :int
(eb :pointer)
(flags :uint)
(clear :int))
(defcfun (event-config-new "event_config_new") :pointer)
(defcfun (event-config-free "event_config_free") :void
(cfg :pointer))
(defcfun (event-config-avoid-method "event_config_avoid_method") :int
(cfg :pointer)
(method :pointer))
(defconstant +EV-FEATURE-ET+ #x01)
(defconstant +EV-FEATURE-O1+ #x02)
(defconstant +EV-FEATURE-FDS+ #x04)
(defconstant +EV-FEATURE-CLOSE+ #x08)
(defconstant +EVENT-BASE-FLAG-NOLOCK+ #x01)
(defconstant +EVENT-BASE-FLAG-IGNORE-ENV+ #x02)
(defconstant +EVENT-BASE-FLAG-STARTUP-IOCP+ #x04)
(defconstant +EVENT-BASE-FLAG-NO-CACHE-TIME+ #x08)
(defconstant +EVENT-BASE-FLAG-EPOLL-USE-CHANGELIST+ #x10)
(defconstant +EVENT-BASE-FLAG-PRECISE-TIMER+ #x20)
(defcfun (event-base-get-features "event_base_get_features") :int
(base :pointer))
(defcfun (event-config-require-features "event_config_require_features")
:int
(cfg :pointer)
(feature :int))
(defcfun (event-config-set-flag "event_config_set_flag") :int
(cfg :pointer)
(flag :int))
(defcfun (event-config-set-num-cpus-hint "event_config_set_num_cpus_hint")
:int
(cfg :pointer)
(cpus :int))
(defcfun (event-config-set-max-dispatch-interval
"event_config_set_max_dispatch_interval")
:int
(cfg :pointer)
(max_interval :pointer)
(max_callbacks :int)
(min_priority :int))
(defcfun (event-base-new-with-config "event_base_new_with_config")
:pointer
(cfg :pointer))
(defcfun (event-base-free "event_base_free") :void (eb :pointer))
(defcfun (event-base-free-nofinalize "event_base_free_nofinalize") :void
(eb :pointer))
(defconstant +EVENT-LOG-DEBUG+ 0)
(defconstant +EVENT-LOG_MSG+ 1)
(defconstant +EVENT-LOG-WARN+ 2)
(defconstant +EVENT-LOG-ERR+ 3)
(defcfun (event-set-log-callback "event_set_log_callback") :void
(cb :pointer))
(defcfun (event-set-fatal-callback "event_set_fatal_callback") :void
(cb :pointer))
(defconstant +EVENT-DBG-ALL+ #xffffffff)
(defconstant +EVENT-DBG-NONE+ 0)
(defcfun (event-enable-debug-logging "event_enable_debug_logging") :void
(which :uint32))
(defcfun (event-base-set "event_base_set") :int
(eb :pointer)
(ev :pointer))
(defconstant +EVLOOP-ONCE+ #x01)
(defconstant +EVLOOP-NONBLOCK+ #x02)
(defconstant +EVLOOP-NO-EXIT-ON-EMPTY+ #x04)
(defcfun (event-base-loop "event_base_loop") :int
(eb :pointer)
(flags :int))
(defcfun (event-base-loopexit "event_base_loopexit") :int
(eb :pointer)
(tv :pointer))
(defcfun (event-base-loopbreak "event_base_loopbreak") :int
(eb :pointer))
(defcfun (event-base-loopcontinue "event_base_loopcontinue") :int
(eb :pointer))
(defcfun (event-base-got-exit "event_base_got_exit") :int
(eb :pointer))
(defcfun (event-base-got-break "event_base_got_break") :int
(eb :pointer))
(defconstant +EV-TIMEOUT+ #x01)
(defconstant +EV-READ+ #x02)
(defconstant +EV-WRITE+ #x04)
(defconstant +EV-SIGNAL+ #x08)
(defconstant +EV-PERSIST+ #x10)
(defconstant +EV-ET+ #x20)
(defconstant +EV-FINALIZE+ #x40)
(defconstant +EV-CLOSED+ #x80)
(defcfun (event-self-cbarg "event_self_cbarg") :pointer)
(defcfun (event-new "event_new") :pointer
(base :pointer)
(fd :int)
(events :short)
(callback :pointer)
(callback_arg :pointer))
(defcfun (event-assign "event_assign") :int
(ev :pointer)
(base :pointer)
(fd :int)
(events :short)
(callback :pointer)
(callback_arg :pointer))
(defcfun (event-free "event_free") :void
(ev :pointer))
(defcfun (event-finalize "event_finalize") :int
(flags :uint)
(ev :pointer)
(callback :pointer))
(defcfun (event-free-finalize "event_free_finalize") :int
(flags :uint)
(ev :pointer)
(callback :pointer))
(defcfun (event-base-once "event_base_once") :int
(base :pointer)
(fd :int)
(events :short)
(callback :pointer)
(arg :pointer)
(timeout :pointer))
(defcfun (event-add "event_add") :int
(ev :pointer)
(timeout :pointer))
(defcfun (event-remove-timer "event_remove_timer") :int
(ev :pointer))
(defcfun (event-del "event_del") :int
(ev :pointer))
(defcfun (event-del-noblock "event_del_noblock") :int
(ev :pointer))
(defcfun (event-del-block "event_del_block") :int
(ev :pointer))
(defcfun (event-active "event_active") :void
(ev :pointer)
(res :int)
(ncalls :short))
(defcfun (event-pending "event_pending") :int
(ev :pointer)
(events :short)
(tv :pointer))
(defcfun (event-base-get-running-event "event_base_get_running_event")
:pointer
(base :pointer))
(defcfun (event-initialized "event_initialized") :int
(ev :pointer))
(defcfun (event-get-fd "event_get_fd") :int
(ev :pointer))
(defcfun (event-get-base "event_get_base") :pointer
(ev :pointer))
(defcfun (event-get-events "event_get_events") :short
(ev :pointer))
(defcfun (event-get-callback "event_get_callback") :pointer
(ev :pointer))
(defcfun (event-get-callback-arg "event_get_callback_arg") :pointer
(ev :pointer))
(defcfun (event-get-priority "event_get_priority") :int
(ev :pointer))
(defcfun (event-get-assignment "event_get_assignment") :void
(event :pointer)
(base_out :pointer)
(fd_out :pointer)
(events_out :pointer)
(callback_out :pointer)
(arg_out :pointer))
(defcfun (event-get-struct-event_size "event_get_struct_event_size")
:size)
(defcfun (event-get-version "event_get_version") :string)
(defcfun (event-get-version-number "event_get_version_number") :uint32)
(defcfun (event-base-priority-init "event_base_priority_init") :int
(eb :pointer)
(npriorities :int))
(defcfun (event-base-get-npriorities "event_base_get_npriorities") :int
(eb :pointer))
(defcfun (event-priority-set "event_priority_set") :int
(ev :pointer)
(priority :int))
(defcfun (event-base-init-common-timeout "event_base_init_common_timeout")
:pointer
(base :pointer)
(duration :pointer))
(defcfun (event-set-mem-functions "event_set_mem_functions") :void
(malloc_fn :pointer)
(realloc_fn :pointer)
(free_fn :pointer))
(defcfun (event-base-dump-events "event_base_dump_events") :void
(eb :pointer)
(filepointer :pointer))
(defcfun (event-base-active-by-fd "event_base_active_by_fd") :void
(base :pointer)
(fd :int)
(events :short))
(defcfun (event-base-active-by-signal "event_base_active_by_signal") :void
(base :pointer)
(sig :int))
(defcfun (event-base-foreach-event "event_base_foreach_event") :int
(base :pointer)
(fn :pointer)
(arg :pointer))
(defcfun (event-base-gettimeofday-cached "event_base_gettimeofday_cached")
:int
(base :pointer)
(tv :pointer))
(defcfun (event-base-update-cache-time "event_base_update_cache_time") :int
(base :pointer))
(defcfun (libevent-global-shutdown "libevent_global_shutdown") :void)
;; end event2/event.h
;; begin event2/thread.h
(defconstant +EVTHREAD-WRITE+ #x04)
(defconstant +EVTHREAD-READ+ #x08)
(defconstant +EVTHREAD-TRY+ #x10)
(defconstant +EVTHREAD-LOCKTYPE-RECURSIVE+ 1)
(defconstant +EVTHREAD-LOCKTYPE-READWRIT+ 2)
(defcfun (evthread-set-lock-callbacks "evthread_set_lock_callbacks") :int
(cbs :pointer))
(defcfun (evthread-set-condition-callbacks "evthread_set_condition_callbacks")
:int
(cbs :pointer))
;; TODO: defcstruct callback structs
(defcfun (evthread-set-id-callback "evthread_set_id_callback") :void
(id_fn :pointer))
(defcfun (evthread-use-pthreads "evthread_use_pthreads") :int)
(defcfun (evthread-enable-lock-debugging "evthread_enable_lock_debugging")
:void)
(defcfun (evthread-make-base-notifiable "evthread_make_base_notifiable")
:int
(base :pointer))
;; end event2/thread.h
;; begin event2/buffer.h
(defcstruct evbuffer-iovec
(iov_base :pointer)
(iov_len :size))
(defcfun (evbuffer-free "evbuffer_free") :void
(buf :pointer))
(defcfun (evbuffer-new "evbuffer_new") :pointer)
(defcfun (evbuffer-enable-locking "evbuffer_enable_locking") :int
(buf :pointer)
(lock :pointer))
(defcfun (evbuffer-lock "evbuffer_lock") :void
(buf :pointer))
(defcfun (evbuffer-unlock "evbuffer_unlock") :void
(buf :pointer))
(defconstant +EVBUFFER-FLAG-DRAINS-TO-FD+ 1)
(defcfun (evbuffer-set-flags "evbuffer_set_flags") :int
(buf :pointer)
(flags :uint64))
(defcfun (evbuffer-clear-flags "evbuffer_clear_flags") :int
(buf :pointer)
(flags :uint64))
(defcfun (evbuffer-get-length "evbuffer_get_length") :size
(buf :pointer))
(defcfun (evbuffer-get-contiguous-space "evbuffer_get_contiguous_space")
:size
(buf :pointer))
(defcfun (evbuffer-expand "evbuffer_expand") :int
(buf :pointer)
(datlen :size))
(defcfun (evbuffer-reserve-space "evbuffer_reserve_space") :int
(buf :pointer)
(size :size)
(vec :pointer))
(defcfun (evbuffer-commit-space "evbuffer_commit_space") :int
(buf :pointer)
(vec :pointer)
(n_vecs :int))
(defcfun (evbuffer-add "evbuffer_add") :int
(buf :pointer)
(data :pointer)
(datlen :size))
(defcfun (evbuffer-remove "evbuffer_remove") :int
(buf :pointer)
(data :pointer)
(dattlen :size))
(defcfun (evbuffer-copyout "evbuffer_copyout") :ssize
(buf :pointer)
(data_out :pointer)
(datlen :size))
(defcfun (evbuffer-copyout-from "evbuffer_copyout_from") :ssize
(buf :pointer)
(pos :pointer)
(data_out :pointer)
(datlen :size))
(defcfun (evbuffer-remove-buffer "evbuffer_remove_buffer") :int
(src :pointer)
(dst :pointer)
(datlen :size))
(defcenum evbuffer-eol-style
:EVBUFFER-EOL-ANY
:EVBUFFER-EOL-CRLF
:EVBUFFER-EOL-CRLF_STRICT
:EVBUFFER-EOL-LF
:EVBUFFER-EOL-NUL)
(defcfun (evbuffer-readln "evbuffer_readln") :pointer
(buffer :pointer)
(n_read_out :pointer)
(eol_style evbuffer-eol-style))
(defcfun (evbuffer-add-buffer "evbuffer_add_buffer") :int
(outbuf :pointer)
(evbuffer :pointer))
(defcfun (evbuffer-add-buffer-reference "evbuffer_add_buffer_reference")
:int
(outbuf :pointer)
(inbuf :pointer))
(defcfun (evbuffer-add-reference "evbuffer_add_reference") :int
(outbuf :pointer)
(data :pointer)
(datlen :pointer)
(cleanupfn :pointer)
(cleanupfn_arg :pointer))
(defcfun (evbuffer-add-file "evbuffer_add_file") :int
(outbuf :pointer)
(fd :int)
(offset :offset)
(length :offset))
(defconstant +EVBUF-FS-CLOSE-ON-FREE+ #x01)
(defconstant +EVBUF-FS-DISABLE-MMAP+ #x02)
(defconstant +EVBUF-FS-DISABLE-SENDFILE+ #x04)
(defconstant +EVBUF-FS-DISABLE-LOCKING+ #x08)
(defcfun (evbuffer-file-segment-new "evbuffer_file_segment_new") :pointer
(fd :int)
(offset :offset)
(length :offset)
(flags :uint))
(defcfun (evbuffer-file-segment-free "evbuffer_file_segment_free") :void
(set :pointer))
(defcfun (evbuffer-file-segment-add-cleanup-cb
"evbuffer_file_segment_add_cleanup_cb")
:void
(seg :pointer)
(cb :pointer)
(arg :pointer))
(defcfun (evbuffer-add-file-segment "evbuffer_add_file_segment") :int
(buf :pointer)
(seg :pointer)
(offset :offset)
(length :offset))
(defcfun (evbuffer-add-printf "evbuffer_add_printf") :int
(buf :pointer)
(fmt :pointer)
&rest)
(defcfun (evbuffer-add-vprintf "evbuffer_add_vprintf") :int
(buf :pointer)
(fmt :pointer)
(ap :pointer)) ;; TODO
(defcfun (evbuffer-drain "evbuffer_drain") :int (buf :pointer) (len :size))
(defcfun (evbuffer-write "evbuffer-write") :int (buf :pointer) (fd :int))
(defcfun (evbuffer-write-atmost "evbuffer_write_atmost") :int
(buffer :pointer)
(fd :int)
(howmuch :ssize))
(defcunion evbuffer-ptr-internal
(chain :pointer)
(pos_in_chain :size))
(defcstruct evbuffer-ptr
(pos :ssize)
(internal_ evbuffer-ptr-internal))
(defcfun (evbuffer-read "evbuffer_read") :int
(buf :pointer)
(fd :int)
(howmuch :int))
(defcfun (evbuffer-search "evbuffer_search") evbuffer-ptr
(buffer :pointer)
(what :pointer)
(len :size)
(start :pointer))
(defcfun (evbuffer-search-range "evbuffer_search_range") evbuffer-ptr
(buffer :pointer)
(what :pointer)
(len :size)
(start :pointer)
(end :pointer))
(defcenum evbuffer-ptr-how
:EVBUFFER-PTR-SET
:EVBUFFER-PTR-ADD)
(defcfun (evbuffer-ptr-set "evbuffer_ptr_set") :int
(buffer :pointer)
(ptr :pointer)
(position :size)
(how evbuffer-ptr-how))
(defcfun (evbuffer-search-eol "evbuffer_search_eol") evbuffer-ptr
(buffer :pointer)
(start :pointer)
(eol_len_out :pointer)
(eol_style evbuffer-eol-style))
(defcfun (evbuffer-peek "evbuffer_peek") :int
(buffer :pointer)
(len :ssize)
(start_at :pointer)
(vec_out :pointer)
(n_vec :int))
(defcstruct evbuffer-cb-info
(orig_size :size)
(n_added :size)
(n_deleted :size))
(defcfun (evbuffer-add-cb "evbuffer_add_cb") :pointer
(buffer :pointer)
(cb :pointer)
(cbarg :pointer))
(defcfun (evbuffer-remove-cb-entry "evbuffer_remove_cb_entry") :int
(buffer :pointer)
(ent :pointer))
(defcfun (evbuffer-remove-cb "evbuffer_remove_cb") :int
(buffer :pointer)
(cb :pointer)
(cbarg :pointer))
(defconstant +EVBUFFER-CB-ENABLED+ 1)
(defcfun (evbuffer-cb-set-flags "evbuffer_cb_set_flags") :int
(buffer :pointer)
(cb :pointer)
(flags :uint32))
(defcfun (evbuffer-cb-clear-flags "evbuffer_cb_clear_flags") :int
(buffer :pointer)
(cb :pointer)
(flags :uint32))
(defcfun (evbuffer-pullup "evbuffer_pullup") :pointer
(buf :pointer)
(size :ssize))
(defcfun (evbuffer-prepend "evbuffer_prepend") :int
(buf :pointer)
(data :pointer)
(size :size))
(defcfun (evbuffer-prepend-buffer "evbuffer_prepend_buffer") :int
(dst :pointer)
(src :pointer))
(defcfun (evbuffer-freeze "evbuffer_freeze") :int
(buf :pointer)
(at_front :int))
(defcfun (evbuffer-unfreeze "evbuffer_unfreeze") :int
(buf :pointer)
(at_front :int))
(defcfun (evbuffer-defer-callbacks "evbuffer_defer_callbacks") :int
(buffer :pointer)
(base :pointer))
(defcfun (evbuffer-add-iovec "evbuffer_add_iovec") :size
(buffer :pointer)
(iov :pointer)
(n_vec :int))
;; end event2/buffer.h
;; begin event2/bufferevent.h
(defconstant +BEV-EVENT-READING+ #x01)
(defconstant +BEV-EVENT-WRITING+ #x02)
(defconstant +BEV-EVENT-EOF+ #x10)
(defconstant +BEV-EVENT-ERROR+ #x20)
(defconstant +BEV-EVENT-TIMEOUT+ #x40)
(defconstant +BEV-EVENT-CONNECTED+ #x80)
(defconstant +BEV-OPT-CLOSE-ON-FREE+ #x01)
(defconstant +BEV-OPT-THREADSAFE+ #x02)
(defconstant +BEV-OPT-DEFER-CALLBACKS+ #x04)
(defconstant +BEV-OPT-UNLOCK-CALLBACKS+ #x08)
(defcfun (bufferevent-socket-new "bufferevent_socket_new") :pointer
(base :pointer)
(fd :int)
(options :int))
(defcfun (bufferevent-socket-connect "bufferevent_socket_connect") :int
(bufev :pointer)
(addr :pointer)
(socklen :int))
(defcfun (bufferevent-socket-connect-hostname
"bufferevent_socket_connect_hostname")
:int
(bufev :pointer)
(evdns_base :pointer)
(family :int)
(hostname :pointer)
(port :int))
(defcfun (bufferevent-socket-get-dns-error
"bufferevent_socket_get_dns_error")
:int
(bev :pointer))
(defcfun (bufferevent-base-set "bufferevent_base_set") :int
(base :pointer)
(bufev :pointer))
(defcfun (bufferevent-get-base "bufferevent_get_base") :pointer
(bev :pointer))
(defcfun (bufferevent-priority-set "bufferevent_priority_set") :int
(bufev :pointer)
(pri :int))
(defcfun (bufferevent-get-priority "bufferevent_get_priority") :int
(bufev :pointer))
(defcfun (bufferevent-free "bufferevent_free") :void
(e :pointer))
(defcfun (bufferevent-setcb "bufferevent_setcb") :void
(bufev :pointer)
(readcb :pointer)
(writecb :pointer)
(eventcb :pointer)
(cbarg :pointer))
(defcfun (bufferevent-getcb "bufferevent_getcb") :void
(bufev :pointer)
(readcb_ptr :pointer)
(writecb_ptr :pointer)
(eventcb_port :pointer)
(cbarg_ptr :pointer))
(defcfun (bufferevent-setfd "bufferevent_setfd") :int
(bufev :pointer)
(fd :int))
(defcfun (bufferevent-getfd "bufferevent_getfd") :int
(bufev :pointer))
(defcfun (bufferevent-get-underlying "bufferevent_get_underlying") :pointer
(bufev :pointer))
(defcfun (bufferevent-write "bufferevent_write") :int
(bufev :pointer)
(data :pointer)
(size :size))
(defcfun (bufferevent-write-buffer "bufferevent_write_buffer") :int
(bufev :pointer)
(buf :pointer))
(defcfun (bufferevent-read "bufferevent_read") :size
(bufev :pointer)
(data :pointer)
(size :size))
(defcfun (bufferevent-read-buffer "bufferevent_read_buffer") :int
(bufev :pointer)
(buf :pointer))
(defcfun (bufferevent-get-input "bufferevent_get_input") :pointer
(bufev :pointer))
(defcfun (bufferevent-get-output "bufferevent_get_output") :pointer
(bufev :pointer))
(defcfun (bufferevent-enable "bufferevent_enable") :int
(bufev :pointer)
(event :short))
(defcfun (bufferevent-disable "bufferevent_disable") :int
(bufev :pointer)
(event :short))
(defcfun (bufferevent-get-enabled "bufferevent_get_enabled") :short
(bufferev :pointer))
(defcfun (bufferevent-set-timeouts "bufferevent_set_timeouts") :int
(bufev :pointer)
(timeout_read :pointer)
(timeout_write :pointer))
(defcfun (bufferevent-setwatermark "bufferevent_setwatermark") :void
(bufev :pointer)
(events :short)
(lowmark :size)
(highmark :size))
(defcfun (bufferevent-getwatermark "bufferevent_getwatermark") :int
(bufev :pointer)
(events :short)
(lowmark :pointer)
(highmark :pointer))
(defcfun (bufferevent-lock "bufferevent_lock") :void
(bufev :pointer))
(defcfun (bufferevent-unlock "bufferevent_unlock") :void
(bufev :pointer))
(defcfun (bufferevent-incref "bufferevent_incref") :void
(bufev :pointer))
(defcfun (bufferevent-decref "bufferevent_decref") :int
(bufev :pointer))
(defconstant +BEV-NORMAL+ 0)
(defconstant +BEV-FLUSH+ 1)
(defconstant +BEV-FINISHED+ 2)
(defcfun (bufferevent-flush "bufferevent_flush") :int
(bufev :pointer)
(mode :int))
(defconstant +BEV-TRIG-IGNORE-WATERMARKS+ (ash 1 16))
(defconstant +BEV-TRIG-DEFER-CALLBACKS+ +BEV-OPT-DEFER-CALLBACKS+)
(defcfun (bufferevent-trigger "bufferevent_trigger") :void
(bufev :pointer)
(iotype :short)
(options :int))
(defcfun (bufferevent-trigger-event "bufferevent_trigger_event") :void
(bufev :pointer)
(what :short)
(options :int))
(defconstant +BEV-OK+ 0)
(defconstant +BEV-NEED-MORE+ 1)
(defconstant +BEV-ERROR+ 2)
(defcfun (bufferevent-filter-new "bufferevent_filter_new") :pointer
(underlying :pointer)
(input_filter :pointer)
(output_filter :pointer)
(options :int)
(free_context :pointer)
(ctx :pointer))
(defcfun (bufferevent-pair-new "bufferevent_pair_new") :int
(base :pointer)
(options :int)
(pair :pointer))
(defcfun (bufferevent-pair-get-partner "bufferevent_pair_get_partner")
:pointer
(bev :pointer))
(defcfun (ev-token-bucket-cfg-new "ev_token_bucket_cfg_new") :pointer
(read_rate :size)
(read_burst :size)
(write_rate :size)
(write_burst :size)
(tick_len :pointer))
(defcfun (ev-token-bucket-cfg-free "ev_token_bucket_cfg_free") :void
(cfg :pointer))
(defcfun (bufferevent-set-rate-limit "bufferevent_set_rate_limit") :int
(bev :pointer)
(cfg :pointer))
(defcfun (bufferevent-rate-limit-group "bufferevent_rate_limit_group")
:pointer
(base :pointer)
(cfg :pointer))
(defcfun (bufferevent-rate-limit-group-set-cfg
"bufferevent_rate_limit_group_set_cf")
:int
(group :pointer)
(cfg :pointer))
(defcfun (bufferevent-rate-limit-group-set-min-share
"bufferevent_rate_limit_group_set_min_share") :int
(group :pointer)
(len :size))
(defcfun (bufferevent-rate-limit-group-free
"bufferevent_rate_limit_group_free")
:void
(group :pointer))
(defcfun (bufferevent-add-to-rate-limit-group
"bufferevent_add_to_rate_limit_group") :int
(bev :pointer)
(g :pointer))
(defcfun (bufferevent-remove-from-rate-limit-group
"bufferevent_remove_from_rate_limit_group")
:int
(bev :pointer)
(g :pointer))
(defcfun (bufferevent-set-max-single-read
"bufferevent_set_max_single_read")
:int
(bev :pointer)
(size :size))
(defcfun (bufferevent-set-max-single-write
"bufferevent_set_max_single_write")
:int
(bev :pointer)
(size :size))
(defcfun (bufferevent-get-max-single-read "bufferevent_get_max_single_read")
:ssize
(bev :pointer))
(defcfun (bufferevent-get-max-single-write "bufferevent_get_max_single_write")
:ssize
(bev :pointer))
(defcfun (bufferevent-get-read-limit "bufferevent_get_read_limit") :ssize
(bev :pointer))
(defcfun (bufferevent-get-write-limit "bufferevent_get_write_limit") :ssize
(bev :pointer))
(defcfun (bufferevent-get-max-to-read "bufferevent_get_max_to_read") :ssize
(bev :pointer))
(defcfun (bufferevent-get-max-to-write "bufferevent_get_max_to_write") :ssize
(bev :pointer))
(defcfun (bufferevent-get-token-bucket-cfg "bufferevent_get_token_bucket_cfg")
:pointer
(bev :pointer))
(defcfun (bufferevent-rate-limit-group-get-read-limit
"bufferevent_rate_limit_group_get_read_limit")
:ssize
(g :pointer))
(defcfun (bufferevent-rate-limit-group-get-write-limit
"bufferevent_rate_limit_group_get_write_limit")
:ssize
(g :pointer))
(defcfun (bufferevent-decrement-read-limit
"bufferevent_decrement_read_limit")
:int
(bev :pointer)
(decr :ssize))
(defcfun (bufferevent-decrement-write-limit
"bufferevent_decrement_write_limit")
:int
(bev :pointer)
(decr :ssize))
(defcfun (bufferevent-rate-limit-group-decrement-read
"bufferevent_rate_limit_group_decrement_read")
:int
(g :pointer)
(size :ssize))
(defcfun (bufferevent-rate-limit-group-decrement-write
"bufferevent_rate_limit_group_decrement_write")
:int
(g :pointer)
(size :ssize))
(defcfun (bufferevent-rate-limit-group-get-totals
"bufferevent_rate_limit_group_get_totals")
:void
(grp :pointer)
(total_read_out :pointer)
(total_write_out :pointer))
(defcfun (bufferevent-rate-limit-group-reset-totals
"bufferevent_rate_limit_group_reset_totals")
:void
(grp :pointer))
;; end event2/bufferevent.h
;; start event2/util.h
(defcfun (evutil-inet-ntop "evutil_inet_ntop") :string
(af :int)
(src :pointer)
(dst :string)
(size :size))
(defcfun (evutil-inet-pton "evutil_inet_pton") :int
(af :int)
(src :string)
(dst :pointer))
(defcfun (evutil-freeaddrinfo "evutil_freeaddrinfo") :void
(ai :pointer))
(defcfun (evutil-socketpair "evutil_socketpair") :int
(d :int)
(type :int)
(protocol :int)
(sv :pointer))
(defcfun (evutil-make-socket-nonblocking "evutil_make_socket_nonblocking")
:int
(sock :int))
(defcfun (evutil-make-listen-socket-reuseable
"evutil_make_listen_socket_reuseable")
:int
(sock :int))
(defcfun (evutil-make-listen-socket-reuseable-port
"evutil_make_listen_socket_reuseable_port")
:int
(sock :int))
(defcfun (evutil-make-listen-socket-ipv6only
"evutil_make_listen_socket_ipv6only")
:int
(sock :int))
(defcfun (evutil-make-socket-closeonexec "evutil_make_socket_closeonexec")
:int
(sock :int))
(defcfun (evutil-closesocket "evutil_closesocket") :int (sock :int))
(defcfun (evutil-make-tcp-listen-socket-deferred
"evutil_make_tcp_listen_socket_deferred")
:int
(sock :int))
(defcfun (evutil-parse-sockaddr-port "evutil_parse_sockaddr_port") :int
(str :string)
(out :pointer)
(outlen :pointer))
;; end event2/util.h
;; start event2/dns.h
(defconstant +EVDNS-BASE-DISABLE-WHEN-INACTIVE+ #x8000)
(defconstant +EVDNS-BASE-INITIALIZE-NAMESERVERS+ 1)
(defconstant +EVDNS-BASE-NAMESERVERS-NO-DEFAULT+ #x10000)
(defcfun (evdns-base-new "evdns_base_new") :pointer
(event_base :pointer)
(initialize_nameservers :int))
(defcfun (evdns-base-free "evdns_base_free") :void
(base :pointer)
(fail_requests :int))
(defcfun (evdns-base-clear-host-addresses "evdns_base_clear_host_addresses")
:void
(base :pointer))
(defcfun (evdns-err-to-string "evdns_err_to_string") :string
(err :int))
(defcfun (evdns-base-nameserver-add "evdns_base_nameserver_add") :int
(base :pointer)
(address :ulong))
(defcfun (evdns-base-count-nameservers "evdns_base_count_nameservers") :int
(base :pointer))
(defcfun (evdns-base-clear-nameservers-and-suspend
"evdns_base_clear_nameservers_and_suspend")
:int
(base :pointer))
(defcfun (evdns-base-resume "evdns_base_resume") :int (base :pointer))
(defcfun (evdns-base-nameserver-ip-add "evdns_base_nameserver_ip_add")
:int
(base :pointer)
(ip_as_string :string))
(defcfun (evdns-base-nameserver-sockaddr-add
"evdns_base_nameserver_sockaddr_add")
:int
(base :pointer)
(sa :pointer)
(len :size)
(flags :uint))
(defcfun (evdns-base-resolve-ipv4 "evdns_base_resolve_ipv4") :pointer
(base :pointer)
(name :string)
(flags :int)
(callback :pointer)
(ptr :pointer))
(defcfun (evdns-base-resolve-ipv6 "evdns_base_resolve_ipv6") :pointer
(base :pointer)
(name :string)
(flags :int)
(callback :pointer)
(ptr :pointer))
(defcfun (evdns-base-resolve-reverse "evdns_base_resolve_reverse")
:pointer
(base :pointer)
(in :pointer)
(flags :int)
(callback :pointer)
(ptr :pointer))
(defcfun (evdns-base-resolve-reverse-ipv6 "evdns_base_resolve_reverse_ipv6")
:pointer
(base :pointer)
(in :pointer)
(flags :int)
(callback :pointer)
(ptr :pointer))
(defcfun (evdns-cancel-request "evdns_cancel_request") :void
(base :pointer)
(req :pointer))
(defcfun (evdns-base-set-option "evdns_base_set_option") :int
(base :pointer)
(option :string)
(val :string))
(defcfun (evdns-base-resolv-conf-parse "evdns_base_resolv_conf_parse") :int
(base :pointer)
(flags :int)
(filename :string))
(defcfun (evdns-base-load-hosts "evdns_base_load_hosts") :int
(base :pointer)
(hosts_fname :string))
(defcfun (evdns-base-search-clear "evdns_base_search_clear") :void
(base :pointer))
(defcfun (evdns-base-search-add "evdns_base_search_add") :void
(base :pointer)
(domain :string))
(defcfun (evdns-base-search-ndots-set "evdns_base_search_ndots_set") :void
(base :pointer)
(ndots :int))
(defcfun (evdns-set-log-fn "evdns_set_log_fn") :void
(fn :pointer))
(defcfun (evdns-set-transaction-id-fn "evdns_set_transaction_id_fn") :void
(fn :pointer))
(defcfun (evdns-set-random-bytes-fn "evdns_set_random_bytes_fn") :void
(fn :pointer))
(defcfun (evdns-add-server-port-with-base "evdns_add_server_port_with_base")
:pointer
(base :pointer)
(socket :int)
(flags :int)
(callback :pointer)
(user_data :pointer))
(defcfun (evdns-close-server-port "evdns_close_server_port") :void
(port :pointer))
(defcfun (evdns-server-request-set-flags "evdns_server_request_set_flags")
:void
(req :pointer)
(flags :int))
(defcfun (evdns-server-request-add-reply "evdns_server_request_add_reply")
:int
(req :pointer)
(section :int)
(name :string)
(type :int)
(dns_class :int)
(ttl :int)
(datalen :int)
(is_name :int)
(data :pointer))
(defcfun (evdns-server-request-add-a-reply
"evdns_server_request_add_a_reply")
:int
(req :pointer)
(name :string)
(n :int)
(addrs :pointer)
(ttl :int))
(defcfun (evdns-server-request-add-aaaa-reply
"evdns_server_request_add_aaaa_reply")
:int
(req :pointer)
(name :string)
(n :int)
(addrs :pointer)
(ttl :int))
(defcfun (evdns-server-request-add-ptr-reply
"evdns_server_request_add_ptr_reply")
:int
(req :pointer)
(in :pointer)
(addrs :pointer)
(hostname :string)
(ttl :int))
(defcfun (evdns-server-request-add-cname-reply
"evdns_server_request_add_cname_reply")
:int
(req :pointer)
(name :string)
(cname :string)
(ttl :int))
(defcfun (evdns-server-request-respond "evdns_server_request_respond") :int
(req :pointer)
(err :int))
(defcfun (evdns-server-request-drop "evdns_server_request_drop") :int
(req :pointer))
(defcfun (evdns-server-request-get-requesting-addr
"evdns_server_request_get_requesting_addr")
:int
(req :pointer)
(sa :pointer)
(addr_len :int))
(defcfun (evdns-getaddrinfo "evdns_getaddrinfo") :pointer
(dns_base :pointer)
(nodename :string)
(servvname :string)
(hints_in :pointer)
(cb :pointer)
(arg :pointer))
(defcfun (evdns-getaddrinfo-cancel "evdns_getaddrinfo_cancel") :void
(req :pointer))
(defcfun (evdns-base-get-nameserver-addr "evdns_base_get_nameserver_addr")
:int
(base :pointer)
(idx :int)
(sa :pointer)
(len :size))
;; end event2/dns.h
;; start event2/http.h
(defcfun (evhttp-new "evhttp_new") :pointer
(base :pointer))
(defcfun (evhttp-bind-socket "evhttp_bind_socket") :int
(http :pointer)
(address :string)
(port :uint16))
(defcfun (evhttp-bind-socket-with-handle "evhttp_bind_socket_with_handle")
:pointer
(http :pointer)
(address :string)
(port :uint16))
(defcfun (evhttp-accept-socket "evhttp_accept_socket") :int
(http :pointer)
(fd :int))
(defcfun (evhttp-accept-socket-with-handle
"evhttp_accept_socket_with_handle")
:pointer
(http :pointer)
(fd :int))
(defcfun (evhttp-bind-listener "evhttp_bind_listener") :pointer
(http :pointer)
(listener :pointer))
(defcfun (evhttp-bound-socket-get-listener "evhttp_bound_socket_get_listener")
:pointer
(bound :pointer))
(defcfun (evhttp-foreach-bound-socket "evhttp_foreach_bound_socket") :void
(function :pointer)
(argument :pointer))
(defcfun (evhttp-del-accept-socket "evhttp_del_accept_socket") :void
(http :pointer)
(bound_socket :pointer))
(defcfun (evhttp-bound-socket-get-fd "evhttp_bound_socket_get_fd") :int
(bound_socket :pointer))
(defcfun (evhttp-free "evhttp_free") :void
(http :pointer))
(defcfun (evhttp-set-max-headers-size "evhttp_set_max_headers_size") :void
(http :pointer)
(max_headers_size :ssize))
(defcfun (evhttp-set-max-connections "evhttp_set_max_connections") :void
(http :pointer)
(cons :int))
(defcfun (evhttp-get-connection-count "evhttp_get_connection_count") :int
(http :pointer))
(defcfun (evhttp-set-max-body-size "evhttp_set_max_body_size") :void
(http :pointer)
(max_body_size :ssize))
(defcfun (evhttp-set-default-content-type "evhttp_set_default_content_type")
:void
(http :pointer)
(content_type :string))
(defcfun (evhttp-set-allowed-methods "evhttp_set_allowed_methods") :void
(http :pointer)
(methods :uint16))
(defcfun (evhttp-set-cb "evhttp_set_cb") :int
(http :pointer)
(path :string)
(cb :pointer)
(cb_arg :pointer))
(defcfun (evhttp-del-cb "evhttp_del_cb") :int
(http :pointer)
(path :pointer))
(defcfun (evhttp-set-gencb "evhttp_set_gencb") :void
(http :pointer)
(cb :pointer)
(arg :pointer))
(defcfun (evhttp-set-bevcb "evhttp_set_bevcb") :void
(http :pointer)
(cb :pointer)
(arg :pointer))
(defcfun (evhttp-add-virtual-host "evhttp_add_virtual_host") :int
(http :pointer)
(pattern :string)
(vhost :pointer))
(defcfun (evhttp-remove-virtual-host "evhttp_remove_virtual_host") :int
(http :pointer)
(vhost :pointer))
(defcfun (evhttp-add-server-alias "evhttp_add_server_alias") :int
(http :pointer)
(alias :string))
(defcfun (evhttp-remove-server-alias "evhttp_remove_server_alias") :int
(http :pointer)
(alias :string))
(defcfun (evhttp-set-timeout "evhttp_set_timeout") :void
(http :pointer)
(timeout_in_secs :int))
(defcfun (evhttp-set-timeout-tv "evhttp_set_timeout_tv") :void
(http :pointer)
(tv :pointer))
(defcfun (evhttp-set-read-timeout-tv "evhttp_set_read_timeout_tv") :void
(http :pointer)
(tv :pointer))
(defcfun (evhttp-set-write-timeout-tv "evhttp_set_write_timeout_tv") :void
(http :pointer)
(tv :pointer))
(defconstant +EVHTTP-SERVER-LINGERING-CLOSE+ #x0001)
(defcfun (evhttp-set-flags "evhttp_set_flags") :int
(http :pointer)
(flags :int))
(defcfun (evhttp-send-error "evhttp_send_error") :void
(req :pointer)
(err :int)
(reason :string))
(defcfun (evhttp-send-reply "evhttp_send_reply") :void
(req :pointer)
(code :int)
(reason :string)
(databuf :pointer))
(defcfun (evhttp-send-reply-start "evhttp_send_reply_start") :void
(req :pointer)
(code :int)
(reason :string))
(defcfun (evhttp-send-reply-chunk "evhttp_send_reply_chunk") :void
(req :pointer)
(databuf :pointer))
(defcfun (evhttp-send-reply-chunk-with-cb "evhttp_send_reply_chunk_with_cb")
:void
(cb :pointer)
(arg :pointer))
(defcfun (evhttp-send-reply-end "evhttp_send_reply_end") :void
(req :pointer))
(defconstant +EVHTTP-REQ-GET+ (ash 1 0))
(defconstant +EVHTTP-REQ-POST+ (ash 1 1))
(defconstant +EVHTTP-REQ-HEAD+ (ash 1 2))
(defconstant +EVHTTP-REQ-PUT+ (ash 1 3))
(defconstant +EVHTTP-REQ-DELETE+ (ash 1 4))
(defconstant +EVHTTP-REQ-OPTIONS+ (ash 1 5))
(defconstant +EVHTTP-REQ-TRACE+ (ash 1 6))
(defconstant +EVHTTP-REQ-CONNECT+ (ash 1 7))
(defconstant +EVHTTP-REQ-PATCH+ (ash 1 9))
(defcenum evhttp-request-kind
:EVHTTP-REQUEST
:EVHTTP-RESPONSE)
(defcfun (evhttp-connection-base-bufferevent-new
"evhttp_connection_base_bufferevent_new")
:pointer
(base :pointer)
(dnsbase :pointer)
(bev :pointer)
(address :string)
(port :uint16))
(defcfun (evhttp-connection-get-bufferevent
"evhttp_connection_get_bufferevent")
:pointer
(evcon :pointer))
(defcfun (evhttp-connection-get-server "evhttp_connection_get_server")
:pointer
(evcon :pointer))
(defcfun (evhttp-request-new "evhttp_request_new")
:pointer
(cb :pointer)
(arg :pointer))
(defcfun (evhttp-request-set-chunked-cb "evhttp_request_set_chunked_cb")
:void
(req :pointer)
(cb :pointer))
(defcfun (evhttp-request-set-header-cb "evhttp_request_set_header_cb") :void
(req :pointer)
(cb :pointer))
(defcenum evhttp-request-error
:EVREQ-HTTP-TIMEOUT
:EVREQ-HTTP-EOF
:EVREQ-HTTP-INVALID-HEADER
:EVREQ-HTTP-BUFFER-ERROR
:EVREQ-HTTP-REQUEST-CANCEL
:EVREQ-HTTP-DATA-TOO-LONG)
(defcfun (evhttp-request-set-error-cb "evhttp_request_set_error_cb") :void
(req :pointer)
(cb :pointer))
(defcfun (evhttp-request-set-on-complete_cb
"evhttp_request_set_on_complete_cb")
:void
(req :pointer)
(cb :pointer))
(defcfun (evhttp-request-free "evhttp_request_free") :void
(req :pointer))
(defcfun (evhttp-connection-base-new "evhttp_connection_base_new") :pointer
(base :pointer)
(dnsbase :pointer)
(address :string)
(port :uint16))
(defcfun (evhttp-connection-set-family "evhttp_connection_set_family") :void
(evcon :pointer)
(family :int))
(defconstant +EVHTTP-CON-REUSE-CONNECTED-ADDR+ #x0008)
(defconstant +EVHTTP-CON-READ-ON-WRITE-ERROR+ #x0010)
(defconstant +EVHTTP-CON-LINGERING-CLOSE+ #x0020)
(defconstant +EVHTTP-CON-PUBLIC-FLAGS-END+ #x100000)
(defcfun (evhttp-connection-set-flags "evhttp_connection_set_flags") :int
(evcon :pointer)
(flags :int))
(defcfun (evhttp-request-own "evhttp_request_own") :void (req :pointer))
(defcfun (evhttp-request-is-owned "evhttp_request_is_owned") :int (req :pointer))
(defcfun (evhttp-request-get-connection "evhttp_request_get_connection")
:pointer
(req :pointer))
(defcfun (evhttp-connection-get-base "evhttp_connection_get_base") :pointer
(req :pointer))
(defcfun (evhttp-connection-set-max-headers-size
"evhttp_connection_set_max_headers_size")
:void
(evcon :pointer)
(new_max_headers_size :ssize))
(defcfun (evhttp-connection-set-max-body-size
"evhttp_connection_set_max_body_size")
:void
(evcon :pointer)
(new_max_body_size :ssize))
(defcfun (evhttp-connection-free "evhttp_connection_free") :void
(evcon :pointer))
(defcfun (evhttp-connection-free-on-completion
"evhttp_connection_free_on_completion")
:void
(evcon :pointer))
(defcfun (evhttp-connection-set-local-address
"evhttp_connection_set_local_address")
:void
(evcon :pointer)
(address :string))
(defcfun (evhttp-connection-set-local-port
"evhttp_connection_set_local_port")
:void
(evcon :pointer)
(port :uint16))
(defcfun (evhttp-connection-set-timeout
"evhttp_connection_set_timeout")
:void
(evcon :pointer)
(timeout_in_secs :int))
(defcfun (evhttp-connection-set-timeout-tv
"evhttp_connection_set_timeout_tv")
:void
(evcon :pointer)
(tv :pointer))
(defcfun (evhttp-connection-set-connect-timeout-tv
"evhttp_connection_set_connect_timeout_tv")
:void
(evcon :pointer)
(tv :pointer))
(defcfun (evhttp-connection-set-read-timeout-tv
"evhttp_connection_set_read_timeout_tv")
:void
(evcon :pointer)
(tv :pointer))
(defcfun (evhttp-connection-set-write-timeout-tv
"evhttp_connection_set_write_timeout_tv")
:void
(evcon :pointer)
(tv :pointer))
(defcfun (evhttp-connection-set-initial-retry-tv
"evhttp_connection_set_initial_retry_tv")
:void
(evcon :pointer)
(tv :pointer))
(defcfun (evhttp-connection-set-retries "evhttp_connection_set_retries")
:void
(evcon :pointer)
(retry_max :int))
(defcfun (evhttp-connection-set-closecb "evhttp_connection_set_closecb")
:void
(evcon :pointer)
(cb :pointer)
(arg :pointer))
(defcfun (evhttp-connection-get-peer "evhttp_connection_get_peer")
:void
(evcon :pointer)
(address :pointer)
(port :pointer))
(defcfun (evhttp-connection-get-addr "evhttp_connection_get_addr") :pointer
(evcon :pointer))
(defcfun (evhttp-make-request "evhttp_make_request") :int
(evcon :pointer)
(req :pointer)
(type :int)
(uri :string))
(defcfun (evhttp-cancel-request "evhttp_cancel_request") :void
(req :pointer))
(defcfun (evhttp-request-get-uri "evhttp_request_get_uri") :string
(req :pointer))
(defcfun (evhttp-request-get-evhttp-uri "evhttp_request_get_evhttp_uri")
:pointer
(req :pointer))
(defcfun (evhttp-request-get-command "evhttp_request_get_command") :int
(req :pointer))
(defcfun (evhttp-request-get-response-code
"evhttp_request_get_response_code")
:int
(req :pointer))
(defcfun (evhttp-request-get-response-code-line
"evhttp_request_get_response_code_line")
:pointer
(req :pointer))
(defcfun (evhttp-request-get-input-headers
"*evhttp_request_get_input_headers")
:pointer
(req :pointer))
(defcfun (evhttp-request-get-output-headers
"evhttp_request_get_output_headers")
:pointer
(req :pointer))
(defcfun (evhttp-request-get-input-buffer
"evhttp_request_get_input_buffer")
:pointer
(req :pointer))
(defcfun (evhttp-request-get-output-buffer
"evhttp_request_get_output_buffer")
:pointer
(req :pointer))
(defcfun (evhttp-request-get-host "evhttp_request_get_host") :string
(req :pointer))
(defcfun (evhttp-find-header "evhttp_find_header") :string
(headers :pointer)
(key :string))
(defcfun (evhttp-remove-header "evhttp_remove_header") :int
(headers :pointer)
(key :pointer))
(defcfun (evhttp-add-header "evhttp_add_header") :int
(h :pointer)
(key :string)
(value :string))
(defcfun (evhttp-clear-headers "evhttp_clear_headers") :void
(headers :pointer))
(defcfun (strlen-ptr "strlen") :size
(s :pointer))
(defcfun (evhttp-encode-uri "evhttp_encode_uri") :pointer (str :string))
(defcfun (evhttp-uriencode "evhttp_uriencode") :pointer
(str :string)
(size :ssize)
(space_to_plus :int))
(defcfun (evhttp-decode-uri "evhttp_decode_uri") :pointer (uri :string))
(defcfun (evhttp-uridecode "evhttp_uridecode") :string
(uri :string)
(decode_plus :int)
(size_out :size))
(defcfun (evhttp-parse-query "evhttp_parse_query") :int
(uri :string)
(headers :pointer))
(defcfun (evhttp-parse-query-str "evhttp_parse_query_str") :int
(uri :pointer)
(headers :pointer))
(defcfun (evhttp-htmlescape "evhttp_htmlescape") :string
(html :string))
(defcfun (evhttp-uri-new "evhttp_uri_new") :pointer)
(defcfun (evhttp-uri-set-flags "evhttp_uri_set_flags") :void
(uri :pointer)
(flags :uint))
(defcfun (evhttp-uri-get-scheme "evhttp_uri_get_scheme") :string
(uri :pointer))
(defcfun (evhttp-uri-get-userinfo "evhttp_uri_get_userinfo") :string
(uri :pointer))
(defcfun (evhttp-uri-get-host "evhttp_uri_get_host") :string (uri :string))
(defcfun (evhttp-uri-get-port "evhttp_uri_get_port") :int (uri :string))
(defcfun (evhttp-uri-get-path "evhttp_uri_get_path") :string (uri :string))
(defcfun (evhttp-uri-get-query "evhttp_uri_get_query") :string (uri :string))
(defcfun (evhttp-uri-get-fragment "evhttp_uri_get_fragment") :string (uri :string))
(defcfun (evhttp-uri-set-scheme "evhttp_uri_set_scheme") :int
(uri :string) (scheme :string))
(defcfun (evhttp-uri-set-userinfo "evhttp_uri_set_userinfo") :int
(uri :string) (userinfo :string))
(defcfun (evhttp-uri-set-host "evhttp_uri_set_host") :int
(uri :string) (host :string))
(defcfun (evhttp-uri-set-port "evhttp_uri_set_port") :int
(uri :string) (port :int))
(defcfun (evhttp-uri-set-path "evhttp_uri_set_path") :int
(uri :string) (path :string))
(defcfun (evhttp-uri-set-query "evhttp_uri_set_query") :int
(uri :string) (query :string))
(defcfun (evhttp-uri-set-fragment "evhttp_uri_set_fragment") :int
(uri :string) (fragment :string))
(defcfun (evhttp-uri-parse-with-flags "evhttp_uri_parse_with_flags") :pointer
(source_uri :string)
(flags :uint))
(defconstant +EVHTTP-URI-MONCONFORMANT* #x01)
(defcfun (evhttp-uri-parse "evhttp_uri_parse") :pointer (source_uri :string))
(defcfun (evhttp-uri-free "evhttp_uri_free") :void (uri :pointer))
(defcfun (evhttp-uri-join "evhttp_uri_join") :string
(uri :pointer)
(buf :pointer)
(limit :size))
;; end event2/http.h
;; start event2/bufferevent_ssl.h
(defconstant +BUFFEREVENT-SSL-OPEN+ 0)
(defconstant +BUFFEREVENT-SSL-CONNECTING+ 1)
(defconstant +BUFFEREVENT-SSL-ACCEPTING+ 2)
(defcfun (bufferevent-openssl-filter-new "bufferevent_openssl_filter_new")
:pointer
(base :pointer)
(underlying :pointer)
(ssl :pointer)
(state :int)
(options :int))
(defcfun (bufferevent-openssl-socket-new "bufferevent_openssl_socket_new")
:pointer
(base :pointer)
(fd :int)
(ssl :pointer)
(state :int)
(options :int))
(defcfun (bufferevent-openssl-get-allow-dirty-shutdown
"bufferevent_openssl_get_allow_dirty_shutdown")
:int
(bev :pointer))
(defcfun (bufferevent-openssl-set-allow-dirty-shutdown
"bufferevent_openssl_set_allow_dirty_shutdown")
:void
(bev :pointer)
(allow_dirty_shutdown :int))
(defcfun (bufferevent_openssl_get_ssl "bufferevent_openssl_get_ssl")
:pointer
(bufev :pointer))
(defcfun (bufferevent-ssl-renegotiate "bufferevent_ssl_renegotiate") :int
(befev :pointer))
(defcfun (bufferevent-get-openssl-error "bufferevent_get_openssl_error") :long
(bev :pointer))
(defconstant +LEV-OPT-LEAVE-SOCKET-BLOCKING+ (ash 1 0))
(defconstant +LEV-OPT-CLOSE-ON-FREE+ (ash 1 1))
(defconstant +LEV-OPT-CLOSE-ON-EXEC+ (ash 1 2))
(defconstant +LEV-OPT-REUSEABLE+ (ash 1 3))
(defconstant +LEV-OPT-THREADSAFE+ (ash 1 4))
(defconstant +LEV-OPT-DISABLED+ (ash 1 5))
(defconstant +LEV-OPT-DEFERRED-ACCEPT+ (ash 1 6))
(defconstant +LEV-OPT-REUSEABLE-PORT+ (ash 1 7))
(defconstant +LEV-OPT-BIND-IPV6ONLY+ (ash 1 8))
(defcfun (evconnlistener-new-bind "evconnlistener_new_bind") :pointer
(base :pointer)
(cb :pointer)
(ptr :pointer)
(flags :uint)
(backlog :int)
(sa :pointer)
(socklen :int))
(defcfun (evconnlistener-new "evconnlistener_new") :pointer
(base :pointer)
(cb :pointer)
(ptr :pointer)
(flags :uint)
(backlog :int)
(fd :int))
(defcfun (evconnlistener-free "evconnlistener_free") :void
(lev :pointer))
(defcfun (evconnlistener-enable "evconnlistener_enable") :int
(lev :pointer))
(defcfun (evconnlistener-disable "evconnlistener_disable") :int
(lev :pointer))
(defcfun (evconnlistener-set-cb "evconnlistener_set_cb") :void
(lev :pointer)
(cb :pointer)
(arg :pointer))
(defcfun (evconnlistener-set-error-cb "evconnlistener_set_error_cb") :void
(lev :pointer)
(errorcb :pointer))
(defcfun (evws-new-session "evws_new_session") :pointer
(req :pointer)
(cb :pointer)
(arg :pointer)
(options :int))
(defcfun (evws-send "evws_send") :void
(evws :pointer)
(packet_str :pointer)
(str_len :size))
(defcfun (evws-close "evws_close") :void
(evws :pointer)
(reason :uint16))
(defcfun (evws-connection-set-closecb "evws_connection_set_closecb") :void
(evws :pointer)
(cb :pointer)
(arg :pointer))
(defcfun (evws-connection-free "evws_connection_free") :void
(evws :pointer))
| 45,469 | Common Lisp | .lisp | 1,411 | 29.579022 | 83 | 0.727196 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 81c7e454901e2ff1ac5404be71eaef60eda20c46377c64c1c547bc69c29ceb6e | 16,553 | [
-1
] |
16,554 | openssl.lisp | zltl_cc/src/openssl.lisp | (in-package :cc-openssl)
(define-foreign-library openssl_crypto
(:unix (:or "libcrypto.so"))
(t (:default "libcrypto")))
(define-foreign-library openssl_ssl
(:unix (:or "libssl.so"))
(t (:default "libssl")))
(use-foreign-library openssl_crypto)
(use-foreign-library openssl_ssl)
; int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
(defcfun (openssl-init-ssl "OPENSSL_init_ssl") :int
(opts :uint64)
(settings :pointer))
(OPENSSL-init-ssl 0 (null-pointer))
;; const SSL_METHOD *TLSv1_2_method(void))
(defcfun (tlsv1.2-method "TLSv1_2_method") :pointer)
;; SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);
(defcfun (ssl-ctx-new "SSL_CTX_new") :pointer
(meth :pointer))
;; SSL *SSL_new(SSL_CTX *ctx);
(defcfun (ssl-new "SSL_new") :pointer
(ctx :pointer))
;; void SSL_free(SSL *ssl);
(defcfun (ssl-free "SSL_free") :void
(ssl :pointer))
;; void SSL_CTX_free(SSL_CTX *);
(defcfun (ssl-ctx-free "SSL_CTX_free") :void
(ctx :pointer))
(defcvar "stderr" :pointer)
;; void ERR_print_errors_fp(FILE *fp);
(defcfun (err-print-errors-fp "ERR_print_errors_fp") :void
(fp :pointer))
(defun perror ()
(err-print-errors-fp stderr))
| 1,171 | Common Lisp | .lisp | 34 | 32.441176 | 77 | 0.701863 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 83f9fcfc2740b5d862c33bd338cb2a5ce6e6048bf0b27265034b01bdaaee5eb1 | 16,554 | [
-1
] |
16,555 | timeval.lisp | zltl_cc/src/timeval.lisp |
(in-package :cc-timeval)
;;; Define the TIMEVAL structure used by 'gettimeofday'. This assumes
;;; that 'time_t' is a 'long' --- it would be nice if CFFI could
;;; provide a proper :TIME-T type to help make this portable.
(defcstruct timeval
(tv-sec :long)
(tv-usec :long))
;;; Define the Lisp function %GETTIMEOFDAY to call the C function
;;; 'gettimeofday', passing a pointer to the TIMEVAL structure to fill
;;; in. The TZP parameter is deprecated and should be NULL --- we can
;;; enforce this by using our NULL-POINTER type defined above.
(defcfun ("gettimeofday" %gettimeofday) :int
(tp :pointer)
(tzp :pointer))
(defmacro with-c-timeval-value ((tv (sec micro)) &body body)
"Create timeval object tv, then set sec, micro to tv, call body."
`(with-foreign-object (,tv '(:struct timeval))
(if (not 'micro) (setf micro 0))
(setf (foreign-slot-value ,tv '(:struct timeval) 'tv-sec) ,sec)
(setf (foreign-slot-value ,tv '(:struct timeval) 'tv-usec) ,micro)
,@body))
(defmacro with-c-timeval-values ((tv timeout) &body body)
`(if ,timeout
(cc-timeval:with-c-timeval-value
(,tv ((car ,timeout) (car (cdr ,timeout))))
,@body)
(let ((,tv (null-pointer)))
,@body)))
(defun get-values (tv)
"Return second and microsecond for tv."
(with-foreign-slots ((tv-sec tv-usec) tv (:struct timeval))
(values tv-sec tv-usec)))
;;; Define a Lispy interface to 'gettimeofday' that returns the
;;; seconds and microseconds as multiple values.
(defun gettimeofday ()
(with-foreign-object (tv '(:struct timeval))
(let ((r (%gettimeofday tv (null-pointer))))
(if (< r 0) (error (cc-errno:str)))
(get-values tv))))
(defun to-timestamp (sec micro)
"Convert sec micro pair to local-time:timestamp."
(local-time:unix-to-timestamp sec :nsec (* 1000 micro)))
(defun from-timestamp (ts)
"Convert local-time:timestamp to sec and micro"
(values (local-time:timestamp-to-unix ts)
(/ (local-time:nsec-of ts) 1000)))
| 1,986 | Common Lisp | .lisp | 46 | 39.956522 | 71 | 0.686691 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 0917467daaf7913d105a0c441ae0438f8f6ece50aa2dd78545620d2877918ff7 | 16,555 | [
-1
] |
16,556 | cc.lisp | zltl_cc/src/cc.lisp | (in-package :cc)
;; Define your project functionality here...
(defun greet (&optional (name "[email protected]"))
(log:info "Hello ~a from ~a!~&" name "cc"))
(defun help ()
(format t "~&Usage:
cc [name]~&"))
(defun %main (argv)
"Parse CLI args."
(when (member "-h" argv :test #'equal)
;; To properly parse command line arguments, use a third-party library such as
;; clingon, unix-opts, defmain, adopt… when needed.
(help)
(uiop:quit))
(greet (or (first argv)
"dear lisp user")))
(defun main ()
"Entry point for the executable.
Reads command line arguments."
;; uiop:command-line-arguments returns a list of arguments (sans the script name).
;; We defer the work of parsing to %main because we call it also from the Roswell script.
(%main (uiop:command-line-arguments)))
| 839 | Common Lisp | .lisp | 22 | 34.409091 | 91 | 0.676143 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 195b45ecb1c4e89ce7796b68de7ee226dee70b3684ef7902c24a5ac246ea0467 | 16,556 | [
-1
] |
16,557 | dns.lisp | zltl_cc/src/dns.lisp | (in-package :cc-net)
(defstruct dns-task
;; (cb ip-list cb-args...)
cb
cb-args)
(defcstruct linux-addrinfo
(ai_flags :int)
(ai_family :int)
(ai_socktype :int)
(ai_protocol :int)
(ai_addrlen :size)
(ai_addr :pointer)
(ai_canonname :string)
(ai_next :pointer))
;; type evdns_getaddrinfo_cb.
(defcallback base-dns-callback :void
((result :int) (res :pointer) (arg :pointer))
(let ((inf res)
(ipset ())
(task (cc-event:event-table-get arg)))
(cc-event:event-table-del arg)
(foreign-free arg)
(loop while (not (null-pointer-p inf))
do
(with-foreign-slots
((ai_flags
ai_family
ai_socktype
ai_protocol
ai_addrlen
ai_addr
ai_canonname
ai_next) inf (:struct linux-addrinfo))
(let ((ip (cc-net:ip-from-c-sockaddr ai_addr)))
(setf ipset (adjoin ip ipset :test #'cc-net:ip-equal)))
(setf inf ai_next)))
(apply (dns-task-cb task) ipset (dns-task-cb-args task)))
(and res
(cc-libevent:evutil-freeaddrinfo res)))
(defmethod dns-lookup ((eb cc-event:base) hostname cb &rest cb-args)
"Resolve hostname to ip V4/V6
HOSTNAME: domain name
CB: callback function form as (cb result res-list cb-args...)
CB-ARGS: extra arguments of cb"
(let ((task (make-dns-task :cb cb :cb-args cb-args))
(aptr (foreign-alloc :char)))
(cc-event:event-table-set aptr task)
(with-foreign-string (name hostname)
(cc-libevent:evdns-getaddrinfo
(cc-event:base-dns-c eb)
name
(null-pointer)
(null-pointer)
(callback base-dns-callback)
aptr))))
| 1,598 | Common Lisp | .lisp | 55 | 24.436364 | 68 | 0.652288 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 2bc0b7a1be26d0e72d4a6377b002d6056240e42102a8e08c5b30c9429404a27e | 16,557 | [
-1
] |
16,558 | net.lisp | zltl_cc/src/net.lisp | (in-package :cc-net)
(defstruct bufev
;; result of bufferevent_new()
c
;; the base object
base
;; (read-cb bev cb-args...)
read-cb
;; (write-cb bev cb-args...)
write-cb
;; (event-cb bev what cb-args...)
event-cb
;; arguments of readcb, writecb, errorcb
cb-args
;; ssl
ssl
;; ssl-ctx
ssl-ctx
)
(defconstant +EV-TIMEOUT+ #x01)
(defconstant +EV-READ+ #x02)
(defconstant +EV-WRITE+ #x04)
(defconstant +EV-SIGNAL+ #x08)
(defconstant +EV-PERSIST+ #x10)
(defconstant +EV-ET+ #x20)
(defconstant +EV-FINALIZE+ #x40)
(defconstant +EV-CLOSED+ #x80)
(defconstant +BEV-OPT-CLOSE-ON-FREE+ #x01)
(defconstant +BEV-OPT-THREADSAFE+ #x02)
(defconstant +BEV-OPT-DEFER-CALLBACKS+ #x04)
(defconstant +BEV-OPT-UNLOCK-CALLBACKS+ #x08)
(defconstant +BEV-EVENT-READING+ #x01)
(defconstant +BEV-EVENT-WRITING+ #x02)
(defconstant +BEV-EVENT-EOF+ #x10)
(defconstant +BEV-EVENT-ERROR+ #x20)
(defconstant +BEV-EVENT-TIMEOUT+ #x40)
(defconstant +BEV-EVENT-CONNECTED+ #x80)
(defun bufev-socket-new (bev fd options)
"Create a new socket bev over an existing socket.
BEV: the base instance
FD: the file descriptor from which data is read and written to, or -1.
OPTIONS: zero or more +BEV-OPT-* flags
return an instance of struct bufev
"
(let* ((e (make-bufev :base bev))
(c (cc-libevent:bufferevent-socket-new (base-c bev) fd options)))
(if (null-pointer-p c)
(error (cc-error:oom "bufferevent-socket-new")))
(setf (bufev-c e) c)
(event-table-set c e)
e))
(defun bufev-tls-socket-new (bev fd options)
;; create SSL*
(let* ((method (cc-openssl:tlsv1.2-method))
(ctx (cc-openssl:ssl-ctx-new method))
(ssl nil))
(if (null-pointer-p ctx)
(progn (cc-openssl:perror)
(cc-error:oom "ssl-ctx-new")))
(setf ssl (cc-openssl:ssl-new ctx))
(if (null-pointer-p ssl)
(progn
(cc-openssl:perror)
(cc-error:oom "ssl-new")))
;; create bufferevent
(let* ((e (make-bufev :base bev))
(c (cc-libevent:bufferevent-openssl-socket-new
(base-c bev)
fd
ssl
1 ;; BUFFEREVENT_SSL_CONNECTING
options)))
(if (null-pointer-p c)
(error (cc-error:oom "bufferevent-openssl-socket-new")))
(setf (bufev-c e) c)
(event-table-set c e)
e)))
(defun bufev-new (bev options)
(bufev-socket-new bev -1 options))
(defun bufev-tls-new (bev options)
(bufev-tls-socket-new bev -1 options))
(defun bufev-free (e)
"Deallocate the bufev instance E."
(cc-libevent:bufferevent-free (bufev-c e))
(if (bufev-ssl e) (cc-openssl:ssl-free (bufev-ssl e)))
(if (bufev-ssl-ctx e) (cc-openssl:ssl-ctx-free (bufev-ssl-ctx e))))
(defcallback b-event-read-callback :void
((e-ptr :pointer) (ctx :pointer))
(let* ((e (event-table-get e-ptr))
(cb-args (bufev-cb-args e))
(read-cb (bufev-read-cb e)))
(if read-cb
(apply read-cb e cb-args))))
(defcallback b-event-write-callback :void
((e-ptr :pointer) (ctx :pointer))
(let* ((e (event-table-get e-ptr))
(cb-args (bufev-cb-args e))
(write-cb (bufev-write-cb e)))
(if write-cb
(apply write-cb e cb-args))))
(defcallback b-event-event-callback :void
((e-ptr :pointer) (what :short) (ctx :pointer))
(let* ((e (event-table-get e-ptr))
(cb-args (bufev-cb-args e))
(event-cb (bufev-event-cb e)))
(if event-cb
(apply event-cb e what cb-args))))
(defun bufev-setcb (e &optional &key read-cb write-cb event-cb cb-args)
"Changes th ecallbacks for bufev"
(setf (bufev-read-cb e) read-cb)
(setf (bufev-write-cb e) write-cb)
(setf (bufev-event-cb e) event-cb)
(setf (bufev-cb-args e) cb-args)
(cc-libevent:bufferevent-setcb
(bufev-c e)
(if read-cb (callback b-event-read-callback) (null-pointer))
(if write-cb (callback b-event-write-callback) (null-pointer))
(if event-cb (callback b-event-event-callback) (null-pointer))
(null-pointer))
e)
(defun bufev-tcp-connect (e hostname port)
"Resolve the hostname/ip in remote and connect to it.
E: bufev instance
HOSTNAME: address of remote server
PORT: port to connect to on the resolved address.
Recognized HOSTNAME formats are:
quant67.com
1.2.3.4
::1
[::1]
"
(if (= 0 (cffi:with-foreign-string (hname hostname)
(cc-libevent:bufferevent-socket-connect-hostname
(bufev-c e)
(base-dns-c (bufev-base e))
cc-net:+AF-INET+
hname
port)))
e
(error cc-error:cc-error :msg "bufferevent-socket-connect-hostname")))
(setf (fdefinition 'bufev-tls-connect) #'bufev-tcp-connect)
(defun bufev-tcp-connect-with-cb (eb
&key host port
read-cb write-cb event-cb
cb-args)
"Connect to host:port with callbacks.
read-cb: (read-cb e ...cb-args)
write-cb: (write-cb e ...cb-args)
event-cb: (event-cb e what ..cb-args)
You need to (bufev-free e) when finished"
(let ((e (bufev-socket-new eb -1 (logior +BEV-OPT-CLOSE-ON-FREE+
+BEV-OPT-THREADSAFE+))))
(bufev-setcb e :read-cb read-cb :write-cb write-cb :event-cb event-cb
:cb-args cb-args)
;; (bufev-enable e (logior *EV-READ* *EV-WRITE*))
(bufev-tcp-connect e host port)))
(defun bufev-tls-connect-with-cb (eb
&key
host
port
read-cb
write-cb
event-cb
cb-args)
"Connect to host:port with callbacks.
read-cb: (read-cb e ...cb-args)
write-cb: (write-cb e ...cb-args)
event-cb: (event-cb e what ..cb-args)
You need to (bufev-free e) when finished"
(let ((e (bufev-tls-socket-new eb -1 (logior +BEV-OPT-CLOSE-ON-FREE+))))
(bufev-setcb e :read-cb read-cb :write-cb write-cb :event-cb event-cb
:cb-args cb-args)
(bufev-tls-connect e host port)))
(defun bufev-set-timeout (e timeout-read timeout-write)
"Set the read and write timeout for a bufferevent
E: bufev instance
TIMEOUT-READ: '(second microsecond)
TIMEOUT-READ: '(second microsecond)
"
(cc-timeval:with-c-timeval-values (tv-read timeout-read)
(cc-timeval:with-c-timeval-values (tv-write timeout-write)
(cc-libevent:bufferevent-set-timeouts (bufev-c e)
tv-read
tv-write))))
(defun bufev-get-input (e)
"Return the input buffer."
(cc-libevent:bufferevent-get-input (bufev-c e)))
(defun bufev-get-output (e)
"Return the output buffer."
(cc-libevent:bufferevent-get-output (bufev-c e)))
(defun bufev-enable (e ev-type)
"Enable a buferevent
E: bufev
EV-TYPE: *EV-READ* | *EV-WRITE*
RETURN 0 if success, -1 error"
(cc-libevent:bufferevent-enable (bufev-c e) ev-type))
(defun bufev-write-string (e data-str)
"Write data string to bufev buffer."
(cffi:with-foreign-string ((data datalen) data-str)
(cc-libevent:bufferevent-write (bufev-c e)
data
datalen)))
(defun bufev-write (e data-vec)
"Write data string to bufev buffer."
(cffi:with-foreign-object (data :uint8 (length data-vec))
(let ((i 0))
(map nil
#'(lambda (x)
(setf (mem-ref data :uint8 i) x)
(setf i (+ 1 i)))
data-vec))
(cc-libevent:bufferevent-write (bufev-c e)
data
(length data-vec))))
(defun bufev-read (e len)
"Read len bytes of data from e"
(with-foreign-object (out :uint8 len)
(let ((r (cc-libevent:bufferevent-read (bufev-c e) out len)))
(if (<= r 0)
nil
(let ((vec (make-array r)))
(loop for i from 0 below r
do (setf (elt vec i) (cffi:mem-aref out :uint8 i)))
vec)))))
(defun buffer-new ()
"Allocate storage for a new C evbuffer."
(cc-libevent:evbuffer-new))
(defun buffer-free (ptr)
"Deallocate storage for a C evbuffer"
(cc-libevent:evbuffer-free ptr))
(defun buffer-add-string (ptr str)
"Append str to end of an C evbuffer"
(cffi:with-foreign-string ((data datalen) str)
(cc-libevent:evbuffer-add ptr data (- datalen 1))))
(defun buffer-add (ptr sequance)
"Append byte sequance to end of an C evbuffer."
(cffi:with-foreign-pointer (data (length sequence) size)
(let ((i 0))
(map nil
#'(lambda (x)
(setf (mem-ref data :uint8 i) x)
(setf i (+ 1 i)))
sequence))
(cc-libevent:evbuffer-add ptr data size)))
(defun buffer-drain (ptr len)
"Remote a specified number of bytes data form the beginning of an evbuffer"
(cc-libevent:evbuffer-drain ptr len))
(defun buffer-length (ptr)
"Return the total number of bytes stored in the C evbuffer"
(cc-libevent:evbuffer-get-length ptr))
(defstruct listener
c
base
;; (cb listener fd sockaddr ..cb-args)
cb
cb-args)
(defun listener-free (e)
"Free listener instance"
(cc-libevent:evconnlistener-free (listener-c e))
(event-table-del (listener-c e)))
(defcallback listener-event-callback :void
((eptr :pointer) (fd :int) (sock-c :pointer) (socklen :int) (arg :pointer))
(let* ((e (event-table-get eptr))
(cb-args (listener-cb-args e))
(cb (listener-cb e)))
(apply cb e fd (sockaddr-from-c sock-c) cb-args)))
(defun listener-new-bind (be sock &key cb cb-args)
"new listener"
(let ((e (make-listener))
(c (null-pointer)))
(with-sockaddr-c (sock sock-c sock-c-len)
(setf c (cc-libevent:evconnlistener-new-bind
(base-c be)
(callback listener-event-callback)
(null-pointer)
(logior cc-libevent:+LEV-OPT-CLOSE-ON-FREE+
;; cc-libevent:+LEV-OPT-THREADSAFE+
cc-libevent:+LEV-OPT-REUSEABLE+
cc-libevent:+LEV-OPT-REUSEABLE-PORT+)
-1
sock-c
sock-c-len)))
(setf (listener-c e) c)
(setf (listener-base e) be)
(setf (listener-cb e) cb)
(setf (listener-cb-args e) cb-args)
(event-table-set c e)
e))
(defun listener-new (be hostport &key cb cb-args)
"New listener"
(let ((e (make-listener))
(c (null-pointer)))
(with-sockaddr-c-from-string (hostport sock-c sock-c-len)
(setf c (cc-libevent:evconnlistener-new-bind
(base-c be)
(callback listener-event-callback)
(null-pointer)
(logior cc-libevent:+LEV-OPT-CLOSE-ON-FREE+
;; cc-libevent:*LEV-OPT-THREADSAFE*
cc-libevent:+LEV-OPT-REUSEABLE+
cc-libevent:+LEV-OPT-REUSEABLE-PORT+)
-1
sock-c
sock-c-len)))
(setf (listener-c e) c)
(setf (listener-base e) be)
(setf (listener-cb e) cb)
(setf (listener-cb-args e) cb-args)
(event-table-set c e)
e))
(defcstruct evbuffer-ptr
(pos :ssize)
(-internal-chain :pointer)
(-internal-size :size))
(defun buffer-nth (ptr n)
"Get the nth element of evbuffer. It may SLOW!"
(with-foreign-objects ((pos (:struct evbuffer-ptr))
(chr :uint8 1))
(cc-libevent:evbuffer-ptr-set ptr pos n 0)
(cc-libevent:evbuffer-copyout-from ptr pos chr 1)
(cffi:mem-aref chr :uint8 0)))
(defun buffer-remove (ptr len)
"Read data from evbuffer and drain the bytes read.
return the vector of removed bytes"
(let ((vec (make-array len :initial-element 0)))
(with-foreign-object (out :uint8 len)
(cc-libevent:evbuffer-remove ptr out len)
(loop for i from 0 below len
do (setf (elt vec i) (cffi:mem-aref out :uint8 i))))
vec))
(defun buffer-copyout (ptr len)
"Read data from an evbuffer, and leave the buffer unchanged."
(let ((vec (make-array len :initial-element 0)))
(with-foreign-object (out :uint8 len)
(cc-libevent:evbuffer-copyout ptr out len)
(loop for i from 0 below len
do (setf (elt vec i) (cffi:mem-aref out :uint8 i))))
vec))
(defun buffer-copyout-string (ptr len)
"Read data string from an evbuffer, and leave the buffer unchanged."
(with-foreign-object (str-c :char (1+ len))
(setf (mem-aref str-c :char len) 0)
(cc-libevent:evbuffer-copyout ptr str-c len)
(foreign-string-to-lisp str-c)))
(defun buffer-to-vec (ptr)
"Copy all data from buffer out to vector."
(buffer-copyout ptr (buffer-length ptr)))
(defun buffer-to-string (ptr)
"Copy all data from buffer out to string"
(buffer-copyout-string ptr (buffer-length ptr)))
(defun buffer-vec-to-string (vec)
(flexi-streams:octets-to-string vec :external-format :utf-8))
(defun buffer-string-to-vec (str)
(flexi-streams:string-to-octets str :external-format :utf-8))
| 12,081 | Common Lisp | .lisp | 354 | 29.847458 | 79 | 0.667324 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 8353fd2f6f5eddb42199af345a2b4a890887fae602f586ba7afb6270b95ce75e | 16,558 | [
-1
] |
16,559 | packages.lisp | zltl_cc/src/packages.lisp | (defpackage :cc
(:use :cl :common-lisp :cffi)
(:export :main
:case-expr))
(defpackage :cc-openssl
(:use :cl :common-lisp :cffi)
(:export
:tlsv1.2-method
:ssl-ctx-new
:ssl-new
:ssl-ctx-free
:ssl-free
:perror))
(defpackage :cc-libevent
(:use :cl :common-lisp :cffi)
(:export
:strlen-ptr
:+LEV-OPT-LEAVE-SOCKET-BLOCKING+
:+LEV-OPT-CLOSE-ON-FREE+
:+LEV-OPT-CLOSE-ON-EXEC+
:+LEV-OPT-REUSEABLE+
:+LEV-OPT-THREADSAFE+
:+LEV-OPT-DISABLED+
:+LEV-OPT-DEFERRED-ACCEPT+
:+LEV-OPT-REUSEABLE-PORT+
:+LEV-OPT-BIND-IPV6ONL+
:evconnlistener-new-bind
:evconnlistener-new
:evconnlistener-free
:evconnlistener-enable
:evconnlistener-disable
:evconnlistener-set-cb
:evconnlistener-set-error-cb
:event-enable-debug-mode
:event-debug-unassign
:event-base-new
:event-reinit
:event-base-dispatch
:event-base-get-method
:event-get-supported-methods
:event-gettime-monotonic
:+EVENT-BASE-COUNT-ACTIVE+
:+EVENT-BASE-COUNT-VIRTUAL+
:+EVENT-BASE-COUNT-ADDED+
:event-base-get-num-events
:event-base-get-max-events
:event-config-new
:event-config-free
:event-config-avoid-method
:+EV-FEATURE-ET+
:+EV-FEATURE-O1+
:+EV-FEATURE-FDS+
:+EV-FEATURE-CLOSE+
:+EVENT-BASE-FLAG-NOLOCK+
:+EVENT-BASE-FLAG-IGNORE-ENV+
:+EVENT-BASE-FLAG-STARTUP-IOCP+
:+EVENT-BASE-FLAG-NO-CACHE-TIME+
:+EVENT-BASE-FLAG-EPOLL-USE-CHANGELIST+
:+EVENT-BASE-FLAG-PRECISE-TIMER+
:event-base-get-features
:event-config-require-features
:event-config-set-flag
:event-config-set-num-cpus-hint
:event-config-set-max-dispatch-interval
:event-base-new-with-config
:event-base-free
:event-base-free-nofinalize
:+EVENT-LOG-DEBUG+
:+EVENT-LOG_MSG+
:+EVENT-LOG-WARN+
:+EVENT-LOG-ERR+
:event-set-log-callback
:event-set-fatal-callback
:+EVENT-DBG-ALL+
:+EVENT-DBG-NONE+
:event-enable-debug-logging
:event-base-set
:+EVLOOP-ONCE+
:+EVLOOP-NONBLOCK+
:+EVLOOP-NO-EXIT-ON-EMPTY+
:event-base-loop
:event-base-loopexit
:event-base-loopbreak
:event-base-loopcontinue
:event-base-got-exit
:event-base-got-break
:+EV-TIMEOUT+
:+EV-READ+
:+EV-WRITE+
:+EV-SIGNAL+
:+EV-PERSIST+
:+EV-ET+
:+EV-FINALIZE+
:+EV-CLOSED+
:event-self-cbarg
:event-new
:event-assign
:event-free
:event-finalize
:event-free-finalize
:event-base-once
:event-add
:event-remove-timer
:event-del
:event-del-noblock
:event-del-block
:event-active
:event-pending
:event-base-get-running-event
:event-initialized
:event-get-fd
:event-get-base
:event-get-events
:event-get-callback
:event-get-callback-arg
:event-get-priority
:event-get-assignment
:event-get-struct-event_size
:event-get-version
:event-get-version-number
:event-base-priority-init
:event-base-get-npriorities
:event-priority-set
:event-base-init-common-timeout
:event-set-mem-functions
:event-base-dump-events
:event-base-active-by-fd
:event-base-active-by-signal
:event-base-foreach-event
:event-base-gettimeofday-cached
:event-base-update-cache-time
:libevent-global-shutdown
;; threads
:+EVTHREAD-WRITE+
:+EVTHREAD-READ+
:+EVTHREAD-TRY+
:+EVTHREAD-LOCKTYPE-RECURSIVE+
:+EVTHREAD-LOCKTYPE-READWRIT+
:evthread-set-lock-callbacks
:evthread-set-condition-callbacks
:evthread-set-id-callback
:evthread-use-pthreads
:evthread-enable-lock-debugging
:evthread-make-base-notifiable
;; buffer
:evbuffer-iovec
:evbuffer-free
:evbuffer-new
:evbuffer-enable-locking
:evbuffer-lock
:evbuffer-unlock
:+EVBUFFER-FLAG-DRAINS-TO-FD+
:evbuffer-set-flags
:evbuffer-clear-flags
:evbuffer-get-length
:evbuffer-get-contiguous-space
:evbuffer-expand
:evbuffer-reserve-space
:evbuffer-commit-space
:evbuffer-add
:evbuffer-remove
:evbuffer-copyout
:evbuffer-copyout-from
:evbuffer-remove-buffer
:evbuffer-eol-style
:evbuffer-readln
:evbuffer-add-buffer
:evbuffer-add-buffer-reference
:evbuffer-add-reference
:evbuffer-add-file
:evbuffer-file-segment-new
:evbuffer-file-segment-free
:evbuffer-file-segment-add-cleanup-cb
:evbuffer-add-file-segment
:evbuffer-add-printf
:evbuffer-add-vprintf
:evbuffer-drain
:evbuffer-write
:evbuffer-write-atmost
:evbuffer-ptr
:evbuffer-read
:evbuffer-search
:evbuffer-search-range
:evbuffer-ptr-how
:evbuffer-ptr-set
:evbuffer-search-eol
:evbuffer-peek
:evbuffer-cb-info
:evbuffer-add-cb
:evbuffer-remove-cb-entry
:evbuffer-remove-cb
:evbuffer-cb-set-flags
:evbuffer-cb-clear-flags
:evbuffer-pullup
:evbuffer-prepend
:evbuffer-prepend-buffer
:evbuffer-freeze
:evbuffer-unfreeze
:evbuffer-defer-callbacks
:evbuffer-add-iovec
:+BEV-EVENT-READING+
:+BEV-EVENT-WRITING+
:+BEV-EVENT-EOF+
:+BEV-EVENT-ERROR+
:+BEV-EVENT-TIMEOUT+
:+BEV-EVENT-CONNECTED+
:+BEV-OPT-CLOSE-ON-FREE+
:+BEV-OPT-THREADSAFE+
:+BEV-OPT-DEFER-CALLBACKS+
:+BEV-OPT-UNLOCK-CALLBACKS+
:bufferevent-socket-new
:bufferevent-socket-connect
:bufferevent-socket-connect-hostname
:bufferevent-socket-get-dns-error
:bufferevent-base-set
:bufferevent-get-base
:bufferevent-priority-set
:bufferevent-get-priority
:bufferevent-free
:bufferevent-setcb
:bufferevent-getcb
:bufferevent-setfd
:bufferevent-getfd
:bufferevent-get-underlying
:bufferevent-write
:bufferevent-write-buffer
:bufferevent-read
:bufferevent-read-buffer
:bufferevent-get-input
:bufferevent-get-output
:bufferevent-enable
:bufferevent-disable
:bufferevent-get-enabled
:bufferevent-set-timeouts
:bufferevent-setwatermark
:bufferevent-getwatermark
:bufferevent-lock
:bufferevent-unlock
:bufferevent-incref
:bufferevent-decref
:+BEV-NORMAL+
:+BEV-FLUSH+
:+BEV-FINISHED+
:bufferevent-flush
:+BEV-TRIG-IGNORE-WATERMARKS+
:+BEV-TRIG-DEFER-CALLBACKS+
:bufferevent-trigger
:bufferevent-trigger-event
:+BEV-OK+
:+BEV-NEED-MORE+
:+BEV-ERROR+
:bufferevent-filter-new
:bufferevent-pair-new
:bufferevent-pair-get-partner
:ev-token-bucket-cfg-new
:ev-token-bucket-cfg-free
:bufferevent-set-rate-limit
:bufferevent-rate-limit-group
:bufferevent-rate-limit-group-set-cfg
:bufferevent-rate-limit-group-set-min-share
:bufferevent-rate-limit-group-free
:bufferevent-add-to-rate-limit-group
:bufferevent-remove-from-rate-limit-group
:bufferevent-set-max-single-read
:bufferevent-set-max-single-write
:bufferevent-get-max-single-read
:bufferevent-get-max-single-write
:bufferevent-get-read-limit
:bufferevent-get-write-limit
:bufferevent-get-max-to-read
:bufferevent-get-max-to-write
:bufferevent-get-token-bucket-cfg
:bufferevent-rate-limit-group-get-read-limit
:bufferevent-rate-limit-group-get-write-limit
:bufferevent-decrement-read-limit
:bufferevent-decrement-write-limit
:bufferevent-rate-limit-group-decrement-read
:bufferevent-rate-limit-group-decrement-write
:bufferevent-rate-limit-group-get-totals
:bufferevent-rate-limit-group-reset-totals
:evutil-inet-ntop
:evutil-inet-pton
:evutil-freeaddrinfo
:evutil-socketpair
:evutil-make-socket-nonblocking
:evutil-make-listen-socket-reuseable
:evutil-make-listen-socket-reuseable-port
:evutil-make-listen-socket-ipv6only
:evutil-make-socket-closeonexec
:evutil-closesocket
:evutil-make-tcp-listen-socket-deferred
:evutil-parse-sockaddr-port
:+EVDNS-BASE-DISABLE-WHEN-INACTIVE+
:+EVDNS-BASE-INITIALIZE-NAMESERVERS+
:+EVDNS-BASE-NAMESERVERS-NO-DEFAULT+
:evdns-base-new
:evdns-base-free
:evdns-base-clear-host-addresses
:evdns-err-to-string
:evdns-base-nameserver-add
:evdns-base-count-nameservers
:evdns-base-clear-nameservers-and-suspend
:evdns-base-resume
:evdns-base-nameserver-ip-add
:evdns-base-nameserver-sockaddr-add
:evdns-base-resolve-ipv4
:evdns-base-resolve-ipv6
:evdns-base-resolve-reverse
:evdns-base-resolve-reverse-ipv6
:evdns-cancel-request
:evdns-base-set-option
:evdns-base-resolv-conf-parse
:evdns-base-load-hosts
:evdns-base-search-clear
:evdns-base-search-add
:evdns-base-search-ndots-set
:evdns-set-log-fn
:evdns-set-transaction-id-fn
:evdns-set-random-bytes-fn
:evdns-add-server-port-with-base
:evdns-close-server-port
:evdns-server-request-set-flags
:evdns-server-request-add-reply
:evdns-server-request-add-a-reply
:evdns-server-request-add-aaaa-reply
:evdns-server-request-add-ptr-reply
:evdns-server-request-add-cname-reply
:evdns-server-request-respond
:evdns-server-request-drop
:evdns-server-request-get-requesting-addr
:evdns-getaddrinfo
:evdns-getaddrinfo-cancel
:evdns-base-get-nameserver-addr
:evhttp-new
:evhttp-bind-socket
:evhttp-bind-socket-with-handle
:evhttp-accept-socket
:evhttp-accept-socket-with-handle
:evhttp-bind-listener
:evhttp-bound-socket-get-listener
:evhttp-foreach-bound-socket
:evhttp-del-accept-socket
:evhttp-bound-socket-get-fd
:evhttp-free
:evhttp-set-max-headers-size
:evhttp-set-max-body-size
:evhttp-set-max-connections
:evhttp-get-connection-count
:evhttp-set-default-content-type
:evhttp-set-allowed-methods
:evhttp-set-cb
:evhttp-del-cb
:evhttp-set-gencb
:evhttp-set-bevcb
:evhttp-add-virtual-host
:evhttp-remove-virtual-host
:evhttp-add-server-alias
:evhttp-remove-server-alias
:evhttp-set-timeout
:evhttp-set-timeout-tv
:evhttp-set-read-timeout-tv
:evhttp-set-write-timeout-tv
:+EVHTTP-SERVER-LINGERING-CLOSE+
:evhttp-set-flags
:evhttp-send-error
:evhttp-send-reply
:evhttp-send-reply-start
:evhttp-send-reply-chunk
:evhttp-send-reply-chunk-with-cb
:evhttp-send-reply-end
:+EVHTTP-REQ-GET+
:+EVHTTP-REQ-POST+
:+EVHTTP-REQ-HEAD+
:+EVHTTP-REQ-PUT+
:+EVHTTP-REQ-DELETE+
:+EVHTTP-REQ-OPTIONS+
:+EVHTTP-REQ-TRACE+
:+EVHTTP-REQ-CONNECT+
:+EVHTTP-REQ-PATCH+
:evhttp-connection-base-bufferevent-new
:evhttp-connection-get-bufferevent
:evhttp-connection-get-server
:evhttp-request-new
:evhttp-request-set-chunked-cb
:evhttp-request-set-header-cb
:evhttp-request-set-error-cb
:evhttp-request-set-on-complete-cb
:evhttp-request-free
:evhttp-connection-base-new
:evhttp-connection-set-family
:+EVHTTP-CON-REUSE-CONNECTED-ADDR+
:+EVHTTP-CON-READ-ON-WRITE-ERROR+
:+EVHTTP-CON-LINGERING-CLOSE+
:+EVHTTP-CON-PUBLIC-FLAGS-END
:evhttp-connection-set-flags
:evhttp-request-own
:evhttp-request-is-owned
:evhttp-request-get-connection
:evhttp-connection-get-base
:evhttp-connection-set-max-headers-size
:evhttp-connection-set-max-body-size
:evhttp-connection-free
:evhttp-connection-free-on-completion
:evhttp-connection-set-local-address
:evhttp-connection-set-local-port
:evhttp-connection-set-timeout
:evhttp-connection-set-timeout-tv
:evhttp-connection-set-initial-retry-tv
:evhttp-connection-set-retries
:evhttp-connection-set-closecb
:evhttp-connection-get-peer
:evhttp-connection-get-addr
:evhttp-make-request
:evhttp-cancel-request
:evhttp-request-get-uri
:evhttp-request-get-evhttp-uri
:evhttp-request-get-command
:evhttp-request-get-response-code
:evhttp-request-get-response-code-line
:evhttp-request-get-input-headers
:evhttp-request-get-output-headers
:evhttp-request-get-input-buffer
:evhttp-request-get-output-buffer
:evhttp-request-get-host
:evhttp-find-header
:evhttp-remove-header
:evhttp-add-header
:evhttp-clear-headers
:evhttp-encode-uri
:evhttp-uriencode
:evhttp-decode-uri
:evhttp-uridecode
:evhttp-parse-query
:evhttp-parse-query-str
:evhttp-htmlescape
:evhttp-connection-set-connect-timeout-tv
:evhttp-connection-set-read-timeout-tv
:evhttp-connection-set-write-timeout-tv
:evhttp-connection-set-initial-retry-tv
:evhttp-uri-new
:evhttp-uri-set-flags
:evhttp-uri-get-scheme
:evhttp-uri-get-userinfo
:evhttp-uri-get-host
:evhttp-uri-get-port
:evhttp-uri-get-path
:evhttp-uri-get-query
:evhttp-uri-get-fragment
:evhttp-uri-set-scheme
:evhttp-uri-set-userinfo
:evhttp-uri-set-host
:evhttp-uri-set-port
:evhttp-uri-set-path
:evhttp-uri-set-query
:evhttp-uri-set-fragment
:evhttp-uri-parse-with-flags
:+EVHTTP-URI-MONCONFORMANT
:evhttp-uri-parse
:evhttp-uri-free
:evhttp-uri-join
:+BUFFEREVENT-SSL-OPEN+
:+BUFFEREVENT-SSL-CONNECTING+
:+BUFFEREVENT-SSL-ACCEPTING+
:bufferevent-openssl-filter-new
:bufferevent-openssl-socket-new
:bufferevent-openssl-get-allow-dirty-shutdown
:bufferevent-openssl-set-allow-dirty-shutdown
:bufferevent_openssl_get_ssl
:bufferevent-ssl-renegotiate
:bufferevent-get-openssl-error
:evws-new-session
:evws-send
:evws-close
:evws-connection-set-closecb
:evws-connection-free))
(defpackage :cc-timeval
(:use :cl :common-lisp :cffi)
(:export
:gettimeofday
:timeval
:get-values
:with-c-timeval-value
:with-c-timeval-values
:to-timestamp
:from-timestamp))
(defpackage :cc-log
(:use :cl :local-time :log4cl))
(defpackage :cc-conf
(:nicknames :conf)
(:use :cl)
(:export
:*default-conf*
:conf
:name
:try-files
:from-env
:env-prefix
:get-value
:load-yaml
:+load-yaml
:+get-value
:parse-duration
:parse-float))
(defpackage :cc-errno
(:nicknames :errno)
(:use :cl :cffi)
(:export :str :code))
(defpackage :cc-util
(:nicknames :util)
(:use :cl :cffi)
(:export :make-pointer-eql-able))
(defpackage :cc-error
(:nicknames :error)
(:use :cl)
(:export
:cc-error
:invalid-duration-string
:oom
:already-start
:bad-argument
:conflict))
(defpackage :cc-event
(:nicknames :event)
(:use :cl :cffi)
(:export
:event-table-get
:event-table-set
:event-table-del
:event
:event-c
:event-base
:event-cb
:event-cb-arg-list
:event-fd
:event-types
:event-new
:event-free
:event-add
:event-del
:base
:base-c
:base-ev
:base-id
:base-defer-task-queue
:base-lock
:base-dns-c
:base-init
:base-deinit
:base-loop-start
:base-loop-stop
:base-loop-started-p
:with-base-loop
:defer-task
:defer-task-cb
:defer-task-cb-arg
:defer-submit
:timer-submit
))
(defpackage :cc-net
(:nicknames :net)
(:use :cl :cffi :cc-event)
(:export
:+AF-INET+
:+AF-INET6+
:+V4+
:+V6+
:ip
:ip-len
:ip-family
:ip-addr
:ip-to-string
:ip-from-string
:ip-from-c-sockaddr
:ip-from-c-addr
:ipv4-address-p
:ipv6-address-p
:ip-address-p
:ip-equal
:with-sockaddr-c
:+sock-addr-len+
:sockaddr
:sockaddr-ip
:sockaddr-port
:sockaddr-from-c
:sockaddr-to-string
:sockaddr-from-string
:dns-lookup
:+EV-TIMEOUT+
:+EV-READ+
:+EV-WRITE+
:+EV-SIGNAL+
:+EV-PERSIST+
:+EV-ET+
:+EV-FINALIZE+
:+EV-CLOSED+
:+BEV-EVENT-READING+
:+BEV-EVENT-WRITING+
:+BEV-EVENT-EOF+
:+BEV-EVENT-ERROR+
:+BEV-EVENT-TIMEOUT+
:+BEV-EVENT-CONNECTED+
:+BEV-OPT-CLOSE-ON-FREE+
:+BEV-OPT-THREADSAFE+
:+BEV-OPT-DEFER-CALLBACKS+
:+BEV-OPT-UNLOCK-CALLBACKS+
:bufev
:bufev-c
:bufev-socket-new
:bufev-tls-socket-new
:bufev-new
:bufev-tls-new
:bufev-free
:bufev-tcp-connect
:bufev-tcp-connect-with-cb
:bufev-tls-connect
:bufev-tls-connect-with-cb
:bufev-setcb
:bufev-enable
:bufev-write
:bufev-write-string
:bufev-read
:bufev-set-timeout
:bufev-get-input
:bufev-get-output
:buffer-new
:buffer-free
:buffer-add-string
:buffer-add
:buffer-drain
:buffer-length
:buffer-nth
:buffer-remove
:buffer-copyout
:buffer-copyout-string
:buffer-to-vec
:buffer-to-string
:buffer-vec-to-string
:buffer-string-to-vec
:listener
:listener-c
:listener-base
:listener-cb
:listener-cb-args
:listener-free
:listener-new
:listener-new-bind
))
(defpackage :cc-net/http
(:nicknames :cc-http :http :net/http)
(:use :cl :cffi :cc-event)
(:export
:+continue+
:+switch-protocols+
:+processing+
:+earlyhints+
:+ok+
:+created+
:+accepted+
:+nonauthoritative+
:+nocontent+
:+moveperm+
:+movetemp+
:+notmodified+
:+badrequest+
:+unauthorized+
:+paymentrequired+
:+forbidden+
:+notfound+
:+badmethod+
:+entitytoolarge+
:+expectationfailed+
:+internal+
:+notimplemented+
:+badgateway+
:+servunavail+
;;; requests
:+get+
:+post+
:+head+
:+put+
:+delete+
:+options+
:+trace+
:+connect+
:+patch+
:+propfind+
:+proppatch+
:+mkcol+
:+lock+
:+unlock+
:+copy+
:+move+
:+request+
:+response+
:+timeout+
:+eof+
:+invalid-header+
:+buffer-error+
:+request-cancel+
:+data-too-long+
:http-conn
:http-conn-c
:http-conn-base
:http-conn-url
:http-conn-cheme
:http-conn-host
:http-conn-port
:http-conn-uri
:http-conn-new
:http-conn-free
:http-conn-set-max-header-size
:http-conn-set-max-body-size
:http-conn-set-connect-timeout
:http-conn-set-read-timeout
:http-conn-set-write-timeout
:http-conn-set-initial-retry-timeout
:http-conn-set-retries
:http-conn-set-closecb
:make-keyvals
:keyvals-field
:keyvals-get
:keyvals-gets
:keyvals-set
:keyvals-sets
:keyvals-add
:evkeyvalq-to-hash-table
:evkeyvalq-from-hash-table
:request
:request-c
:request-cb
:request-cb-args
:request-new
:request-free
:request-do
:request-get-response-code
:request-set-chunk-cb
:request-set-header-cb
:request-set-error-cb
:request-set-complete-cb
:request-param
:request-get-input-headers
:request-get-output-headers
:request-set-input-headers
:request-set-output-headers
:request-input-headers
:request-output-headers
:request-get-input-buffer
:request-get-output-buffer
:server-new
:server-set-error-cb
:server-free
:server-bind
:server-bind-listener
:server-set-cb
:server-set-max-header-size
:server-set-max-body-size
:server-set-max-connections
:server-get-connection-count
:server-set-default-content-type
:server-set-allowed-methods
:server-set-timeout
:server-set-read-timeout
:server-set-write-timeout
:request-reply-error
:request-reply
:request-reply-start
:request-reply-chunk
:request-reply-end
:request-reply-string
:ws
:ws-new
:ws-send
:ws-close
:ws-free
:mux
:mux-root
:mux-node
:mux-new
:mux-get
:mux-post
:mux-put
:mux-delete
:mux-default
:mux-call
:mux-handler
:mux-serve
:mux-dfs-print
))
| 19,046 | Common Lisp | .lisp | 788 | 20.083756 | 48 | 0.710325 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 6c1e513364306b839ca6ddc8012c6114673a80e02498966a42c29e23e73b1d09 | 16,559 | [
-1
] |
16,560 | test-cc-conf.lisp | zltl_cc/tests/test-cc-conf.lisp |
(in-package :cc-tests)
(def-suite conf
:description "test cc-conf package")
(in-suite conf)
(setf (cc-conf:try-files cc-conf:*default-conf*)
(list "./tests/test-config.yaml"
"no-exists-file-path-xxxxx")
(cc-conf:name cc-conf:*default-conf*) "TEST"
(cc-conf:from-env cc-conf:*default-conf*) t
(cc-conf:env-prefix cc-conf:*default-conf*) "CC_TEST")
(cc-conf:+load-yaml)
(test test-conf
(not (null (cc-conf:+load-yaml)))
(is (null (cc-conf:+get-value "not.exists.name.x.y.z.kj")))
(is (= 213 (cc-conf:+get-value "A")))
(not (null (cc-conf:+get-value "B.d")))
(is (string= (cc-conf:+get-value "B.d.exc") "this isstring"))
(is (= 233.123 (cc-conf:+get-value "B.d.flv")))
(is (= 5040 (cc-conf:parse-duration (cc-conf:+get-value "B.d.dura"))))
(is (= 56789
(progn
(setf (uiop:getenv "CC_TEST_XYZ_IJK") "56789")
(cc-conf:+get-value "xYz.Ijk"))))
(is (= 5.6789
(progn
(setf (uiop:getenv "CC_TEST_XYZ_OPQ") "5.6789")
(cc-conf:+get-value "xYz.opQ")))))
| 1,076 | Common Lisp | .lisp | 27 | 33.888889 | 76 | 0.585249 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 548f4458d2f3e1d83a78d7447bd630181b6aff15dcbff020c195c9f1884fff8a | 16,560 | [
-1
] |
16,561 | test-cc-event.lisp | zltl_cc/tests/test-cc-event.lisp | (in-package :cc-tests)
;; Define your project tests here...
(ql:quickload "cc")
(def-suite eventest
:description "Test event loop")
(in-suite eventest)
(defun wait-base-start (eb)
(loop while (not (cc-event:base-loop-started-p eb))
do
(sleep 0.1)))
(defun base-create-init ()
"Test cc-event:base create init functions"
(let ((eb (make-instance 'cc-event:base))
(st-thread nil))
(cc-event:base-init eb)
(setf st-thread
(bt:make-thread
(lambda ()
(wait-base-start eb)
(log:debug "stop thread")
(cc-event:base-loop-stop eb)
(log:debug "stop thread exit"))))
(log:debug "start main")
(cc-event:base-loop-start eb)
(log:debug "stop main")
(cc-event:base-deinit eb)
(bt:join-thread st-thread)
(log:debug "Joined"))
1)
(defun defer-task-test (n)
"test cc-event defer task"
(let ((eb (make-instance 'cc-event:base))
(thread nil)
(lock (bt:make-lock))
(run-flag 0))
(cc-event:base-init eb)
(setf thread
(bt:make-thread
(lambda ()
(wait-base-start eb)
(log:debug "loop started")
(loop repeat n
do
(cc-event:defer-submit
eb
(lambda (arg1 arg2 arg3)
(bt:with-lock-held (lock)
(setf run-flag (+ run-flag 1))))
1 2 3))
(loop while (bt:with-lock-held (lock) (> n run-flag))
do (sleep 0.1))
(log:debug "stoping loop")
(cc-event:base-loop-stop eb))))
(log:debug "starting loop")
(cc-event:base-loop-start eb)
(cc-event:base-deinit eb)
(log:debug "loop stoped")
(bt:join-thread thread)
(log:debug "Joined")
run-flag))
(defun timer-test (cnt)
"test cc-event defer task"
(let ((eb (make-instance 'cc-event:base))
(thread nil)
(lock (bt:make-lock))
(timer-run-flag 0))
(cc-event:base-init eb)
(log:info "submit eb-c: ~a" (cc-event:base-c eb))
(log:debug "trace loop started: ~a"
(cc-event:base-loop-started-p eb))
(setf thread
(bt:make-thread
(lambda ()
(log:debug "in lambda eb-c: ~a"
(cc-event:base-c eb))
(wait-base-start eb)
(log:debug "loop started: ~a"
(cc-event:base-loop-started-p eb))
(loop for i from 0 upto (- cnt 1)
do
(sleep 0.1)
(log:info "in loop eb-c=~a" (cc-event:base-c eb))
(log:info "submit ~a at ~a ---"
i (local-time:now))
(cc-event:timer-submit
eb
'(1 0)
(lambda (i j k)
(let ((f (bt:with-lock-held (lock)
(log:info "callback ~a at ~a ~a ~a" i (local-time:now) j k)
(setf timer-run-flag (+ timer-run-flag 1)))))))
i 0 0))
(loop while (> cnt (bt:with-lock-held (lock) timer-run-flag))
do
(sleep 0.1))
(cc-event:base-loop-stop eb))))
(log:debug "starting loop")
(cc-event:base-loop-start eb)
(cc-event:base-deinit eb)
(log:debug "loop stoped")
(bt:join-thread thread)
(log:debug "Joined")
timer-run-flag))
(defun resolve-test (host)
(let ((eb (make-instance 'cc-event:base))
(thread nil)
(lock (bt:make-lock))
(cb-flag nil))
(cc-event:base-init eb)
(setf thread
(bt:make-thread
(lambda ()
(log:debug "in lambda eb-c: ~a"
(cc-event:base-c eb))
(wait-base-start eb)
(log:debug "loop started: ~a"
(cc-event:base-loop-started-p eb))
(cc-net:dns-lookup
eb host
(lambda (iplist a b c d)
(bt:with-lock-held (lock) (setf cb-flag t))
(dolist (ip iplist)
(log:info "get ip: ~a" (cc-net:ip-to-string ip))))
1 2 3 4)
(loop while (not (bt:with-lock-held (lock) cb-flag))
do
(sleep 0.1))
(cc-event:base-loop-stop eb))))
(log:debug "starting loop")
(cc-event:base-loop-start eb)
(cc-event:base-deinit eb)
(log:debug "loop stoped")
(bt:join-thread thread)
(log:debug "Joined"))
1)
;; (resolve-test "ip6-allnodes")
(defun tcp-connect-test (n)
"test cc-event tcp task"
(cc-event:with-base-loop (eb)
(cc-net:bufev-tcp-connect-with-cb
eb :host "quant67.com" :port 80
:read-cb
(lambda (e)
(log:info "read-cb")
(let* ((x (cc-net:bufev-read e 10000)))
(log:info "read size ~a" (length x))
;; (log:info "reading ~&~a " (cc-net:buffer-vec-to-string x))
(cc-net:bufev-free e)
(cc-event:base-loop-stop eb)))
:write-cb
(lambda (e)
(log:info "write-cb")
(cc-net:bufev-enable e cc-net:+EV-READ+))
:event-cb
(lambda (e what)
(log:info "event-cb ~X" what)
(if (equal what cc-net:+BEV-EVENT-CONNECTED+)
(progn
(log:info "connected")
(cc-net:bufev-write-string
e
"GET / HTTP/1.1
Host: quant67.com
")
(cc-net:bufev-enable e
cc-net:+EV-READ+)))))
)
1)
(defun with-loop-test ()
(cc-event:with-base-loop (eb)
(log:warn "base loop started")
(cc-event:base-loop-stop eb))
1)
(defun tls-connect-test ()
"test cc-event tcp task"
(cc-event:with-base-loop (eb)
(cc-net:bufev-tls-connect-with-cb
eb :host "quant67.com" :port 443
:read-cb
(lambda (e)
(log:info "read-cb")
(let* ((x (cc-net:bufev-read e 10000)))
(log:info "read size ~a" (length x))
;; (log:info "reading ~&~a " (cc-net:buffer-vec-to-string x))
(cc-net:bufev-free e)
(cc-event:base-loop-stop eb)))
:write-cb
(lambda (e)
(log:info "write-cb")
(cc-net:bufev-enable e cc-net:+EV-READ+))
:event-cb
(lambda (e what)
(log:info "event-cb ~X" what)
(if (equal what cc-net:+BEV-EVENT-CONNECTED+)
(progn
(log:info "connected")
(cc-net:bufev-write-string
e
"GET / HTTP/1.1
Host: quant67.com
")
(cc-net:bufev-enable e
cc-net:+EV-READ+)))))
)
1)
(defun tcp-listen-test (n)
"test cc-event tcp task"
(defconstant PORT 8888)
(cc-event:with-base-loop (eb)
;; listen
(let ((sockstr (concatenate 'string
"[::]:"
(write-to-string PORT))))
(cc-net:listener-new
eb sockstr
:cb
(lambda (lev fd sock)
(log:info "listener -cb ---")
(let ((econ nil))
(setf econ (cc-net:bufev-socket-new
eb fd cc-net:+BEV-OPT-CLOSE-ON-FREE+))
(cc-net:bufev-setcb
econ
:read-cb
(lambda (e)
(log:info "s/read-cb")
(let* ((x (cc-net:bufev-read e 10000)))
(log:info "s/echoing: ~a" (cc-net:buffer-vec-to-string x))
(cc-net:bufev-write e x)))
:write-cb
(lambda (e)
(log:info "s/write-cb"))
:event-cb
(lambda (e what)
(log:info "s/event-cb what=~a" what)
(if (/= 0 (logand what cc-net:+BEV-EVENT-EOF+))
(progn
(log:info "s/close...")
(cc-net:bufev-free e)
;; free listener
(log:info "s/free lev")
(cc-net:listener-free lev)
(log:info "s/stop loop")
(cc-event:base-loop-stop eb)))))
(cc-net:bufev-enable econ (logior cc-net:+EV-READ+
cc-net:+EV-WRITE+)))))
;; client connect
(cc-event:defer-submit eb
(lambda ()
(cc-net:bufev-tcp-connect-with-cb
eb :host "127.0.0.1" :port PORT
:read-cb
(lambda (e)
(log:info "c/reac-cb")
(let ((x (cc-net:bufev-read e 10000)))
(log:info "c/read ~a ~&c/closing..." (cc-net:buffer-vec-to-string x)))
(cc-net:bufev-free e))
:write-cb
(lambda (e)
(log:info "c/write-cb"))
:event-cb
(lambda (e what)
(log:info "c/event-cb ~X" what)
(cc-net:bufev-write-string e "hello")
(cc-net:bufev-enable e
(logior cc-net:+EV-WRITE+
cc-net:+EV-READ+))))))))
1)
(defun http-client-test ()
"test cc-event http task"
(cc-event:with-base-loop (eb)
(let ((hcon (cc-http:http-conn-new eb "http://quant67.com:80"))
(r nil))
(setf r (cc-http:request-new
:cb
(lambda (req)
(log:info "request done: ~a"
(http:request-get-response-code req))
(http:request-free r)
(cc-event:base-loop-stop eb))))
(cc-http:request-do hcon r http:+get+)))
1)
(defun http-server-test ()
(cc-event:with-base-loop (eb)
(let ((s (http:server-new eb)))
(http:server-bind s
(cc-net:sockaddr-from-string "0.0.0.0:8899"))
(http:server-set-default-content-type s "text/html")
(http:server-set-cb s
:cb
(lambda (req)
(log:info "requesting...")
(let ((buf (net:buffer-new)))
(net:buffer-add-string buf "OK HTTP SERVER")
(http:request-reply req
http:+ok+
buf)
(net:buffer-free buf)
(log:info "response..."))))
(event:defer-submit
eb
(lambda ()
(let ((hcon (cc-http:http-conn-new eb "http://localhost:8899"))
(r nil))
(log:info "before new")
(setf r (cc-http:request-new
:cb
(lambda (req)
(log:info "request done: ~a"
(http:request-get-response-code req))
(http:request-free r)
(http:server-free s)
(cc-event:base-loop-stop eb))))
(log:info "after new")
(cc-http:request-do hcon r http:+get+))))))
1)
(defun http-mux-test ()
(cc-event:with-base-loop (eb)
(let ((s (http:server-new eb))
(mux (http:mux-new)))
;; mux
(http:mux-get mux "/"
(lambda (req)
(log:info "/ => lllllllll")
(http:request-reply-error req http:+ok+)))
;; server
(http:server-bind s
(cc-net:sockaddr-from-string "0.0.0.0:8899"))
(http:server-set-default-content-type s "text/html")
(http:server-set-cb s
:cb
(http:mux-serve mux))
))
1)
;; (http-mux-test)
(test event
(is (= 1 (base-create-init)))
(is (= 100 (defer-task-test 100)))
(is (= 3 (timer-test 3)))
(is (= 1 (resolve-test "quant67.com")))
(is (= 1 (with-loop-test)))
(is (= 1 (tcp-connect-test 1)))
(is (= 1 (tls-connect-test)))
(is (= 1 (tcp-listen-test 1)))
(is (= 1 (http-client-test)))
(is (= 1 (http-server-test))))
| 9,998 | Common Lisp | .lisp | 346 | 22.968208 | 77 | 0.577899 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 7dfd4e8ec69ecf50e7841d2d45c8bb7efc6c748ed0ec97b6cb588318d2deac64 | 16,561 | [
-1
] |
16,562 | test-cc-timeval.lisp | zltl_cc/tests/test-cc-timeval.lisp | (in-package :cc-tests)
(def-suite testtimeval
:description "timeval test")
(in-suite testtimeval)
(defun gettimeofday-sample ()
(progn
(let ((tv (cc-timeval:gettimeofday)))
(log:info "gettimeofday -> ~a" tv))
1))
(defun get-sec ()
(multiple-value-bind (sec micro)
(cc-timeval:gettimeofday)
(log:info "sec=~a usec=~a" sec micro)
sec))
(defun conv-timeval ()
(multiple-value-bind (sec micro)
(cc-timeval:gettimeofday)
(cc-timeval:with-c-timeval-value (tv (sec micro))
(multiple-value-bind (tv-sec tv-usec) (cc-timeval:get-values tv)
(log:info "tv-sec=~a tv-usec=~a" tv-sec tv-usec)
(and (equal sec tv-sec)
(equal micro tv-usec))))))
(test get
(is (= 1 (gettimeofday-sample)))
(is (> (get-sec) 0)))
(test conv
(is (conv-timeval)))
| 811 | Common Lisp | .lisp | 27 | 25.962963 | 70 | 0.647362 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | f8d374a731cd1c27328ab2b366d312200c9cc45bfc5cda1b6779a19bc68f2cb5 | 16,562 | [
-1
] |
16,563 | test-cc.lisp | zltl_cc/tests/test-cc.lisp | (in-package :cc-tests)
;; Define your project tests here...
(ql:quickload "cc")
(def-suite testmain
:description "test suite 1")
(in-suite testmain)
(test test1
(is (= (+ 1 2)
3)))
| 202 | Common Lisp | .lisp | 9 | 19.111111 | 36 | 0.647059 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 6af03116402e3862913ec4d326b0712313be631b5957525b941527c630866d84 | 16,563 | [
-1
] |
16,564 | packages.lisp | zltl_cc/tests/packages.lisp | (in-package :asdf-user)
(defpackage :cc-tests
(:use
:common-lisp
:fiveam
:log4cl
:cffi))
(in-package :cc-tests)
| 127 | Common Lisp | .lisp | 8 | 13 | 23 | 0.669492 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 7dfe65f7f92f230b30d1c4d900eb74931be7417bdf23cf0829622414df0838c9 | 16,564 | [
-1
] |
16,565 | test-cc-ip.lisp | zltl_cc/tests/test-cc-ip.lisp | (in-package :cc-tests)
(def-suite ip
:description "test cc-net package")
(in-suite ip)
(test ip-test
(is (cc-net:ip-equal (cc-net:ip-from-string "1.2.3.4")
(cc-net:ip-from-string "1.2.3.4")))
(is (if (cc-net:ip-address-p "1.2.3.4") t))
(is (if (cc-net:ip-address-p "2001:0db8:85a3:0000:0000:8a2e:0370:7334") t))
(is (equal "1.2.3.4" (cc-net:ip-to-string (cc-net:ip-from-string "1.2.3.4"))))
(is (if (cc-net:ipv4-address-p "1.2.3.4") t))
(is (not (cc-net:ipv4-address-p "1.2.3.4.5")))
(is (if (cc-net:ipv6-address-p "2001:0db8:85a3:0000:0000:8a2e:0370:7334") t))
(is (cc-net:ip-equal (cc-net:ip-from-string "2001:0db8:85a3:0000:0000:8a2e:0370:7334")
(cc-net:ip-from-string "2001:0db8:85a3:0000:0000:8a2e:0370:7334")))
(is (= 4 (cc-net:ip-len (cc-net:ip-from-string "1.2.3.4"))))
(is (= 16 (cc-net:ip-len (cc-net:ip-from-string "2001:0db8:85a3:0000:0000:8a2e:0370:7334"))))
)
| 962 | Common Lisp | .lisp | 18 | 47.555556 | 103 | 0.604478 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | fa920b57e646111e5a6ca3516b76065d33a6f1483b06d1cc31c2aeebe5c22bc2 | 16,565 | [
-1
] |
16,566 | cc.asd | zltl_cc/cc.asd | (in-package :asdf-user)
(defsystem "cc"
:author "liaotonglang <[email protected]@mail.com>"
:version "0.0.1"
:license "GPL-3.0"
:description ""
:homepage ""
:bug-tracker ""
:source-control (:git "[email protected]:zltl/cc.git")
;; Dependencies.
:depends-on (:cffi
:cl-autowrap/libffi
:local-time
:log4cl
:uiop
:cl-yaml
:cl-ppcre
:alexandria
:parse-float
:bt-semaphore
:lparallel
:for
:flexi-streams
:trivial-backtrace)
;; Project stucture.
:serial t
:components ((:module "src"
:serial t
:components ((:file "packages")
(:file "cc")
(:file "libevent")
(:file "timeval")
(:file "log")
(:file "conf")
(:file "util")
(:file "error")
(:file "errno")
(:file "event")
(:file "dns")
(:file "ip")
(:file "net")
(:file "openssl")
(:file "http"))))
;; Build a binary:
;; don't change this line.
:build-operation "program-op"
;; binary name: adapt.
:build-pathname "cc"
;; entry point: here "main" is an exported symbol. Otherwise, use a double ::
:entry-point "cc:main")
| 1,311 | Common Lisp | .asd | 50 | 18.26 | 79 | 0.514718 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 5cd3d7f5ae3c7612ae28f7b1800b20f8a7f4c41ed9121afdb2fbd1eca17a7433 | 16,566 | [
-1
] |
16,567 | cc-tests.asd | zltl_cc/cc-tests.asd | (in-package :asdf-user)
(defsystem "cc-tests"
:description "Test suite for the cc system"
:author "[email protected] <[email protected]@mail.com>"
:version "0.0.1"
:depends-on (:cc
:fiveam
:log4cl
:cffi
:uiop)
:license "BSD"
:serial t
:components ((:module "tests"
:serial t
:components ((:file "packages")
(:file "test-cc")
(:file "test-cc-conf")
(:file "test-cc-timeval")
(:file "test-cc-event")
(:file "test-cc-ip"))))
;; The following would not return the right exit code on error, but still 0.
;; :perform (test-op (op _) (symbol-call :fiveam :run-all-tests))
)
| 758 | Common Lisp | .asd | 23 | 24.086957 | 78 | 0.53951 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | b6b3e2a53af424acea13fe7d350db00b257fecd2748e0d0dfce0f899bf77c888 | 16,567 | [
-1
] |
16,568 | cc-examples.asd | zltl_cc/cc-examples.asd | (in-package :asdf-user)
(defsystem "cc-examples"
:description "Examples for the cc system"
:author "[email protected] <[email protected]@mail.com>"
:version "0.0.1"
:depends-on (:cc
:log4cl
:cffi
:uiop
:spinneret
:cl-json)
:license "BSD"
:serial t
:components ((:module "examples"
:serial t
:components ((:file "packages")
(:file "http-simple-server")))))
| 505 | Common Lisp | .asd | 17 | 20.529412 | 69 | 0.536885 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | b8452ef555f42eb9adebab0add12710073cce04ea4eb2955b41b415ca595cd90 | 16,568 | [
-1
] |
16,571 | Makefile | zltl_cc/Makefile | LISP ?= sbcl
.PHONY: run build test clean example
all: test
run:
$(LISP) --load run.lisp
build:
$(LISP) --non-interactive \
--load cc.asd \
--eval '(ql:quickload :cc)' \
--eval '(asdf:make :cc)'
test:
$(LISP) --non-interactive \
--load run-tests.lisp
example:
$(LISP) --non-interactive \
--load run-example.lisp
clean:
rm -rf cc
| 351 | Common Lisp | .l | 18 | 17.277778 | 36 | 0.665644 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 15727376751bee9a175345791c0acbf97e20c91617c9f4f6474ee513a8d626b3 | 16,571 | [
-1
] |
16,573 | .travis.yml | zltl_cc/.travis.yml | language: lisp
sudo: required
env:
matrix:
- LISP=abcl # Armed Bear Common Lisp
- LISP=allegro # Allegro Common Lisp
- LISP=ccl # Clozure Common Lisp
- LISP=clisp # CLISP
- LISP=sbcl # Steel Bank Common Lisp
matrix:
allow_failures:
- env: LISP=allegro
- env: LISP=clisp
install:
# Install CL Travis Handler
- curl https://raw.githubusercontent.com/luismbo/cl-travis/master/install.sh | bash
script:
# Run the cc tests using lisp-unit
cl -e '(ql:quickload :cc-tests)
(unless (cc-tests:run)
(uiop:quit 1))'
| 631 | Common Lisp | .l | 21 | 23.857143 | 87 | 0.613223 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 112bc376c137e6d45a827de35453659046c2713159160d98dfec5b64d2c12d6b | 16,573 | [
-1
] |
16,595 | test-config.yaml | zltl_cc/tests/test-config.yaml | A: 213
B:
C:
- lc
- l3
d:
exc: "this isstring"
icx: 87
flv: 233.123
dura: 1h24m
| 110 | Common Lisp | .l | 10 | 7 | 24 | 0.5 | zltl/cc | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | d3f2cd8e4b6ce9a23747e2fc1fb17cdd5dd7cebe914b29093d6ab8f4eb56a46d | 16,595 | [
-1
] |
16,612 | documentation.lisp | JMC-design_nsane/documentation.lisp | (in-package :nsane)
(defun document (type doc-strings)
(dolist (doc-string doc-strings)
(destructuring-bind (thing . doc) doc-string
(case type
(:functions (setf (documentation (find-symbol (symbol-name thing)) 'function) (format nil doc)))
(:package (setf (documentation (find-package (symbol-name thing)) t) (format nil doc)))))))
(document
:package
'((nsane .
"Common Lisp implementation of the SANE network protocol~%~
This package is NOT meant to be :USE'd This is not a frontend. It is an implementation ~
of the protocol in Common Lisp so anybody can write a frontend with it. There is one ~
additional function besides the protocol, RETRIEVE-SCAN, that will retrieve and return a ~
scan as a vector of (unsigned-byte 8).~%~
NSANE:*SOCKET* needs to be bound to a socket returned by NSANE:INIT before any other ~
protocol functions are used.~%~
Functions follow the naming convention of the protocol with SANE_NET_ dropped from the ~
function and then kebobbed, e.g. SANE_NET_GET_OPTION_DESCRIPTORS becomes ~
NSANE:GET-OPTION-DESCRIPTORS.~%~
The protocol description is available at https://sane-project.gitlab.io/standard/net.html")))
(document
:functions
'((init .
"Establishes a connection to a SANE network daemon. HOST, PORT, and NAME can be specified ~
by keywords, Defaults to localhost:6566. NAME should be a unique name restricted to ascii ~
characters, defaults to \"nsane\". Returns multiple values, a socket to be bound to ~
NSANE:*SOCKET*, a status code, and the version of network daemon. ")
(get-devices .
"Returns a list of detected devices. Due to poor specification, may barf on more than one ~
device. Raise an issue if this happens.")
(open .
"Takes a DEVICE struct as returned by GET-DEVICES and returns a handle to refer to the device.")
(close .
"Takes a HANDLE and releases the connection to the device. Does not close the socket ~
connection to the SANE daemon.")
(get-option-descriptors .
"Returns a vector of NSANE:OPTION structs. An options position in the vector is used to ~
identify the option in NSANE:CONTROL-OPTION.")
(control-option .
"Takes a HANDLE returned by NSANE:OPEN, an OPTION, represented by the position of the ~
option in the vector returned by NSANE:GET-OPTION-PARAMETERS, an ACTION of either ~
:GET :SET :AUTO, TYPE and SIZE as returned by GET-OPTION-PARAMETERS, and optionally ~
new VALUE for the OPTION. ")
(get-parameters .
"Takes a HANDLE and returns a SCAN struct with the information necessary to interpret ~
the flat vector returned by RETRIEVE-SCAN.")
(start .
"Starts scanning on the device referred to by the supplied HANDLE and returns a list ~
of STATUS, PORT, BYTE-ORDER, RESOURCE. PORT is where your scan resides(on same host ~
provided to NSANE:INIT) and what is passed to RETRIEVE-SCAN. BYTE-ORDER is either ~
:LITTLE-ENDIAN or :BIG-ENDIAN. If RESOURCE is not an empty string it will point to a ~
resource that needs to be authorized using NSANE:AUTHORIZE.")
(cancel .
"Takes a HANDLE and attempts to cancel any in progress scans.")
(authorize .
"Takes a RESOURCE provided by any function that requires authorization, as well as USER ~
and PASSWORD strings to authorize access to the scanner.")
(exit .
"Closes the connection to the SANE network daemon and closes the socket.")
(retrieve-scan .
"Takes a PORT returned by NSANE:START and optional HOST (defaults to 127.0.0.1 and should ~
be same host as passed to NSANE:INIT), and returns a vector of ub8s to be interpreted as ~
specified by NSANE:GET-PARAMETERS.")))
| 3,840 | Common Lisp | .lisp | 64 | 53.5 | 102 | 0.709824 | JMC-design/nsane | 4 | 0 | 0 | LGPL-2.1 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 3d510256e8770efc8e5a7a5c3dd80106ef8c4b046a7564d83829d00a0048813c | 16,612 | [
-1
] |
16,613 | nsane.lisp | JMC-design_nsane/nsane.lisp | (defpackage #:nsane
(:use :cl)
(:shadow cl:write-string
cl:open
cl:close)
(:export #:*socket*
;; device
#:device
#:device-name
#:device-vendor
#:device-model
#:device-type
;; option
#:option-name
#:option-title
#:option-description
#:option-type
#:option-unit
#:option-size
#:option-capabilities
#:option-constraint-type
#:option-constraint
;;scan format
#:scan-last-frame-p
#:scan-bytes-per-line
#:scan-pixels-per-line
#:scan-lines
#:scan-depth
;; protocol
#:init
#:get-devices
#:open
#:close
#:get-option-descriptors
#:control-option
#:get-parameters
#:start
#:cancel
#:authorize
#:exit
;;convenience
#:retrieve-scan))
(in-package #:nsane)
(defvar *socket*)
;;remove prepended status? don't copy api and use description?
(defparameter +status-codes+
#(:status-good
:status-unsuported
:status-cancelled
:status-device-busy
:status-inval
:status-eof
:status-jammed
:status-no-docs
:status-cover-open
:status-io-error
:status-no-mem
:status-access-denied))
(defparameter +value-type+
#(:boolean
:integer
:fixed
:string
:button
:group))
(defparameter +value-unit+
#(:none
:pixel
:bit
:mm
:dpi
:percent
:microsecond))
(defparameter +capabilities+
#(:soft-select
:hard-select
:soft-detect
:emulated
:automatic
:inactive
:advanced))
(defparameter +format+
#(:gray
:rgb
:red
:green
:blue))
(defparameter +info+
#(:inexact
:reload-options
:reload-parameters))
;;;; Returned structures
(defstruct (device (:constructor device (name vendor model type)))
name
vendor
model
type)
(defstruct (option (:constructor option-descriptor
(name title description type unit size capabilities constraint-type constraint)))
name
title
description
type
unit
size
capabilities
constraint-type
constraint)
(defstruct (scan (:constructor parameters (format last-frame-p bytes-per-line pixels-per-line lines depth)))
format
last-frame-p
bytes-per-line
pixels-per-line
lines
depth)
;;;; Accessors
(defun read-word (stream)
(+ (ash (read-byte stream) 24)
(ash (read-byte stream) 16)
(ash (read-byte stream) 8)
(read-byte stream)))
(defun write-word (word stream)
(write-byte (ldb (byte 8 24) word) stream)
(write-byte (ldb (byte 8 16) word) stream)
(write-byte (ldb (byte 8 8) word) stream)
(write-byte (ldb (byte 8 0) word) stream))
(defun read-fixed (stream)
(let ((fixed (read-word stream)))
(+ (ldb (byte 16 0) fixed) (/ (ldb (byte 16 16) fixed) #xFFFF))))
(defun write-fixed (real stream)
(multiple-value-bind (int decimal) (truncate real)
(write-word (logior int (ash (round (* decimal #xFFFF )) 16)) stream)))
(defun sane-string (string)
(let* ((length (1+ (length string)))
(array (make-array (+ 4 length) :initial-contents `(0 0 0 ,length ,@(map 'list #'char-code string) 0)
:element-type '(unsigned-byte 8))))
array))
(defun read-string (stream)
(let* ((length (read-word stream))
(array (make-array length :element-type '(unsigned-byte 8))))
(read-sequence array stream)
(map 'string #'code-char (remove 0 array))))
(defun write-string (string stream)
(write-sequence (sane-string string) stream))
(defun read-boolean (stream)
(if (zerop (read-word stream)) nil t))
(defun write-boolean (bool stream)
(write-word (if bool 1 0) stream))
(defun read-byte-order (stream)
(case (read-word stream)
(#x1234 :little-endian)
(#x4321 :big-endian)
(t :unknown-format)))
(defun decode-mask (mask mask-vector)
(loop :for i :from 0 :below (integer-length mask)
:when (= 1 (ldb (byte 1 i) mask))
:collect (aref mask-vector i)))
(defun read-device (stream)
(make-device
:name (read-string stream)
:vendor (read-string stream)
:model (read-string stream)
:type (read-string stream)))
(defun read-option-descriptor (stream)
(let* ((name (read-string stream))
(title (read-string stream))
(description (read-string stream))
(type (aref +value-type+ (read-word stream)))
(unit (aref +value-unit+ (read-word stream)))
(size (read-word stream))
(cap (decode-mask (read-word stream) +capabilities+))
(constraint-type (read-word stream))
(constraint (case constraint-type
(0 nil)
(1 (list (read-word stream)(read-word stream)(read-word stream) (read-word stream))) ;get rid of last word?
(2 (loop :repeat (read-word stream) :collect (read-word stream)))
(3 (loop :repeat (read-word stream) :collect (read-string stream))))))
(option-descriptor name title description type unit size cap constraint-type constraint)))
(defun read-parameters (stream)
(let ((null (read-word stream))
(format (aref +format+ (read-word stream)))
(last (read-boolean stream))
(bytes (read-word stream))
(pixels (read-word stream))
(lines (read-word stream))
(depth (read-word stream)))
(declare (ignore null))
(parameters format last bytes pixels lines depth)))
(defun retrieve-scan (port &optional (host #(127 0 0 1)))
(usocket:with-client-socket (socket stream host port :element-type '(unsigned-byte 8))
(apply #'concatenate '(vector (unsigned-byte 8))
(loop :for length := (read-word stream)
:until (= length #xFFFFFFFF)
:for temp := (make-array length :element-type '(unsigned-byte))
:for read-length := (read-sequence temp stream)
:collect temp))))
;;;; Protocol https://sane-project.gitlab.io/standard/net.html
(defun init (&key (host #(127 0 0 1)) (port 6566) (name "nsane"))
(let* ((opcode 0)
(version #(1 0 0 3))
(socket (usocket:socket-connect host port :element-type '(unsigned-byte 8)))
(stream (usocket:socket-stream socket)))
(write-word opcode stream)
(write-sequence version stream)
(write-sequence (sane-string name) stream)
(force-output stream)
(values socket
(aref +status-codes+ (read-word stream))
(reverse (list (+ (ash (read-byte stream) 8)
(read-byte stream))
(read-byte stream)
(read-byte stream))))))
(defun get-devices ()
(let ((opcode 1)
(stream (usocket:socket-stream *socket*)))
(write-word opcode stream)
(force-output stream)
(let* ((status (aref +status-codes+ (read-word stream)))
(is-null (read-word stream))
(pointer (read-word stream)))
(declare (ignore pointer))
(if (= 1 is-null)
:no-devices
(values (loop :for device := (read-device stream)
:for next := (read-word stream)
:collect device
:until (= next 1))
status)))))
(defun open (device &optional (socket *socket*))
(let ((opcode 2)
(stream (usocket:socket-stream socket)))
(write-word opcode stream)
(write-sequence (sane-string (device-name device)) stream)
(force-output stream)
(let ((status (read-word stream))
(handle (read-word stream))
(resource (read-string stream)))
(values handle
(aref +status-codes+ status)
resource))))
(defun close (handle &optional (socket *socket*))
(let ((opcode 3)
(stream (usocket:socket-stream socket)))
(write-word opcode stream)
(write-word handle stream)
(force-output stream)
(read-word stream)))
(defun get-option-descriptors (handle)
(let ((opcode 4)
(stream (usocket:socket-stream *socket*)))
(write-word opcode stream)
(write-word handle stream)
(force-output stream)
(let ((length (read-word stream))
(spacer (read-word stream)))
(apply #'vector (loop :repeat length :for x :from 1 :collect (u:fp (read-option-descriptor stream))
:do (unless (= length x) (read-word stream)))))))
;; size is in bytes not words
(defun control-option (handle option action type size &optional (value 0))
(let ((opcode 5)
(stream (usocket:socket-stream *socket*)))
(declare (type (member :get :set :auto) action))
(write-word opcode stream)
(write-word handle stream)
(write-word option stream)
(write-word (case action (:get 0) (:set 1) (:auto 2)) stream)
(write-word (position type +value-type+) stream)
(write-word size stream)
(unless (eql type :string)
(write-word 1 stream))
(case type
(:boolean (write-boolean value stream))
(:integer (write-word value stream))
(:fixed (write-fixed value stream))
(:string (write-string value stream))
(:button (error "raise an issue")))
(force-output stream)
(let* ((status (aref +status-codes+ (read-word stream)))
(info (decode-mask (read-word stream) +info+))
(type (aref +value-type+ (read-word stream)))
(size (read-word stream))
(pointer (unless (eql type :string)
(read-word stream)))
(value (case type
(:boolean (read-boolean stream))
(:integer (read-word stream))
(:fixed (read-fixed stream))
(:string (read-string stream))
(:button (error "raise an issue")))) ; ? don't have a scanner with a button to see what happens
(resource (read-string stream)))
(declare (ignore pointer))
(list status info type size value resource))))
(defun get-parameters (handle)
(let ((opcode 6)
(stream (usocket:socket-stream *socket*)))
(write-word opcode stream)
(write-word handle stream)
(force-output stream)
(read-parameters stream)))
(defun start (handle)
(let ((opcode 7)
(stream (usocket:socket-stream *socket*)))
(write-word opcode stream)
(write-word handle stream)
(force-output stream)
(let ((status (aref +status-codes+ (read-word stream)))
(port (read-word stream))
(byte-order (read-byte-order stream))
(resource (read-string stream)))
(list status port byte-order resource))))
(defun cancel (handle)
(let ((opcode 8)
(stream (usocket:socket-stream *socket*)))
(write-word opcode stream)
(write-word handle stream)
(force-output stream)
; (read-word stream) ;api says dummy word is sent, but doesn't seem to be the case
))
;;untested, unkownn if need to read dummy word or same issue as CANCEL
(defun authorize (resource user password)
(let ((opcode 9)
(stream (usocket:socket-stream *socket*)))
(write-word opcode stream)
(write-string resource stream)
(write-string user stream)
(write-string password stream)
(force-output stream)))
(defun exit (&optional (socket *socket*))
(let ((opcode 10)
(stream (usocket:socket-stream socket)))
(write-word opcode stream)
(force-output stream)
(usocket:socket-close socket)))
| 10,574 | Common Lisp | .lisp | 333 | 27.60961 | 110 | 0.67088 | JMC-design/nsane | 4 | 0 | 0 | LGPL-2.1 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 383e265069a0b24edea14c07ff1bbb337ea08730c8b9512dff7a0a7eca0cdfec | 16,613 | [
-1
] |
16,614 | nsane.asd | JMC-design_nsane/nsane.asd | (in-package :asdf-user)
(defsystem "nsane"
:description "sane network protocl"
:version "0.0.1"
:licence "LGPL"
:author "Johannes Martinez Calzada"
:depends-on ("usocket")
:components ((:file "nsane")))
| 215 | Common Lisp | .asd | 8 | 24.375 | 37 | 0.700483 | JMC-design/nsane | 4 | 0 | 0 | LGPL-2.1 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 90e627e34d3a853265eba30d173b7f8f4d68b1cedd31c7f3eefd55e885f32f7c | 16,614 | [
-1
] |
16,632 | package.lisp | wsgac_cl-moss/package.lisp | ;;;; package.lisp
;;;;
;;;; Copyright (C) 2017 Wojciech Gac <[email protected]>
;;;;
;;;; This file is part of CL-MOSS.
;;;;
;;;; CL-MOSS 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.
;;;;
;;;; CL-MOSS 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 CL-MOSS. If not, see <http://www.gnu.org/licenses/>.
;;;;
(defpackage #:cl-moss
(:use #:cl))
| 830 | Common Lisp | .lisp | 21 | 38.380952 | 73 | 0.705446 | wsgac/cl-moss | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 16a840523d7380910d154a155c577afa6939ad5734fd82027cefdfde8e7c069b | 16,632 | [
-1
] |
16,633 | util.lisp | wsgac_cl-moss/util.lisp | ;;;; util.lisp
;;;;
;;;; Copyright (C) 2017 Wojciech Gac <[email protected]>
;;;;
;;;; This file is part of CL-MOSS.
;;;;
;;;; CL-MOSS 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.
;;;;
;;;; CL-MOSS 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 CL-MOSS. If not, see <http://www.gnu.org/licenses/>.
;;;;
(in-package #:cl-moss)
;;; "util" goes here. Hacks and glory await!
(defun make-keyword (x)
(let ((keyword (load-time-value (find-package :keyword))))
(etypecase x
(keyword x)
(symbol (intern (symbol-name x) keyword))
(string (intern (string-upcase x) keyword))
(cons (mapcar #'make-keyword x))
(vector (mapcar #'make-keyword (coerce x 'list))))))
| 1,180 | Common Lisp | .lisp | 29 | 38.344828 | 73 | 0.683798 | wsgac/cl-moss | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 1d7fd1585952449d3e112282214777adff55da745f7144f47708720e783c8f80 | 16,633 | [
-1
] |
16,634 | cl-moss.asd | wsgac_cl-moss/cl-moss.asd | ;;;; cl-moss.asd
;;;;
;;;; Copyright (C) 2017 Wojciech Gac <[email protected]>
;;;;
;;;; This file is part of CL-MOSS.
;;;;
;;;; CL-MOSS 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.
;;;;
;;;; CL-MOSS 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 CL-MOSS. If not, see <http://www.gnu.org/licenses/>.
;;;;
(asdf:defsystem #:cl-moss
:description "Common Lisp submission mechanism for Stanford's MOSS system"
:author "Wojciech S. Gac <[email protected]>"
:license "GPLv3"
:depends-on (#:usocket)
:serial t
:components ((:file "package")
(:file "util")
(:file "cl-moss")))
| 1,105 | Common Lisp | .asd | 28 | 36.928571 | 76 | 0.687732 | wsgac/cl-moss | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | bc754806358906634ebcf8860ee20c12434e035af8b89ed57e0c826fbe734f81 | 16,634 | [
-1
] |
16,653 | lookup.lisp | glv2_cl-monero-explorer/src/lookup.lisp | ;;;; This file is part of monero-explorer
;;;; Copyright 2019 Guillaume LE VAILLANT
;;;; Distributed under the GNU GPL v3 or later.
;;;; See the file LICENSE for terms of use and distribution.
(defpackage :monero-explorer-common
(:use :cl)
(:import-from :monero-tools
#:deserialize-transaction-prefix)
(:import-from :monero-daemon-rpc
#:get-block
#:get-transactions)
(:import-from :monero-utils
#:bytes->hex-string
#:geta
#:hex-string->bytes)
(:export #:lookup-block
#:lookup-transaction))
(in-package :monero-explorer-common)
(defun lookup-block (id)
(let* ((result (get-block id))
(block-header (geta result :block-header)))
(when block-header
(list :block
(geta block-header :block-size)
(geta block-header :hash)
(geta block-header :height)
(geta block-header :major-version)
(geta block-header :minor-version)
(geta block-header :nonce)
(geta block-header :prev-hash)
(geta block-header :reward)
(geta block-header :timestamp)
(geta block-header :miner-tx-hash)
(geta result :tx-hashes)))))
(defun lookup-transaction (id)
(let* ((result (get-transactions (list id) :prune t))
(transaction (car (geta result :txs))))
(when transaction
(let* ((hex (geta transaction :pruned-as-hex))
(bin (hex-string->bytes hex))
(prefix (deserialize-transaction-prefix bin 0)))
(list :transaction
(geta transaction :block-height)
(geta transaction :block-timestamp)
(geta transaction :double-spend-seen)
(geta transaction :in-pool)
(geta prefix :version)
(geta prefix :unlock-time)
(remove nil
(map 'list
(lambda (input)
(let ((k (geta input :key)))
(when k
(list (geta k :amount)
(coerce (geta k :key-offsets) 'list)
(bytes->hex-string (geta k :key-image))))))
(geta prefix :inputs)))
(map 'list
(lambda (output)
(list (geta output :amount)
(bytes->hex-string (geta (geta output :target) :key))))
(geta prefix :outputs))
(let* ((extra (mapcar #'car (geta prefix :extra)))
(transaction-public-key (geta extra :transaction-public-key))
(additional-public-keys (geta extra :additional-public-keys))
(nonce (geta extra :nonce))
(payment-id (geta nonce :payment-id))
(encrypted-payment-id (geta nonce :encrypted-payment-id)))
(list (bytes->hex-string transaction-public-key)
(map 'list #'bytes->hex-string additional-public-keys)
(if payment-id
(bytes->hex-string payment-id)
(bytes->hex-string encrypted-payment-id)))))))))
| 3,315 | Common Lisp | .lisp | 73 | 30.616438 | 82 | 0.516687 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 59947337b4a22731811ecbf94397cb846f2f348494de70b68b76c16c206842bb | 16,653 | [
-1
] |
16,654 | monero-explorer-nodgui.asd | glv2_cl-monero-explorer/monero-explorer-nodgui.asd | ;;;; This file is part of monero-explorer
;;;; Copyright 2019 Guillaume LE VAILLANT
;;;; Distributed under the GNU GPL v3 or later.
;;;; See the file LICENSE for terms of use and distribution.
(cl:in-package :asdf-user)
#+(and sbcl sb-core-compression)
(defmethod perform ((o program-op) (c system))
(uiop:dump-image (output-file o c) :executable t :compression t))
(defsystem "monero-explorer-nodgui"
:name "monero-explorer-nodgui"
:description "Blockchain explorer for the Monero crypto-currency (nodgui GUI)"
:version "0.1"
:author "Guillaume LE VAILLANT"
:license "GPL-3"
:depends-on ("monero-explorer-common"
"monero-rpc"
"nodgui")
:build-operation "program-op"
:build-pathname "monero-explorer-nodgui"
:entry-point "monero-explorer-nodgui:gui"
:components ((:module "src"
:components ((:file "gui-nodgui")))))
| 888 | Common Lisp | .asd | 22 | 36.090909 | 80 | 0.698376 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 51900708bef2ea122a81bf86ddc44d19f5e50b03696c3043a8422126bd5da56a | 16,654 | [
-1
] |
16,655 | monero-explorer-qt.asd | glv2_cl-monero-explorer/monero-explorer-qt.asd | ;;;; This file is part of monero-explorer
;;;; Copyright 2019 Guillaume LE VAILLANT
;;;; Distributed under the GNU GPL v3 or later.
;;;; See the file LICENSE for terms of use and distribution.
(cl:in-package :asdf-user)
(defsystem "monero-explorer-qt"
:name "monero-explorer-qt"
:description "Blockchain explorer for the Monero crypto-currency (Qt GUI)"
:version "0.1"
:author "Guillaume LE VAILLANT"
:license "GPL-3"
:defsystem-depends-on ("qtools")
:depends-on ("monero-explorer-common"
"monero-rpc"
"qtcore"
"qtgui"
"qtools")
:build-operation "qt-program-op"
:build-pathname "monero-explorer-qt"
:entry-point "monero-explorer-qt:gui"
:components ((:module "src"
:components ((:file "gui-qt")))))
| 800 | Common Lisp | .asd | 22 | 30.772727 | 76 | 0.658065 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | bc66acd7ccfd784d76b51d934f9f35d735eaf979cbad85d2709dd508d24a6c33 | 16,655 | [
-1
] |
16,656 | monero-explorer-mcclim.asd | glv2_cl-monero-explorer/monero-explorer-mcclim.asd | ;;;; This file is part of monero-explorer
;;;; Copyright 2019 Guillaume LE VAILLANT
;;;; Distributed under the GNU GPL v3 or later.
;;;; See the file LICENSE for terms of use and distribution.
(cl:in-package :asdf-user)
#+(and sbcl sb-core-compression)
(defmethod perform ((o program-op) (c system))
(uiop:dump-image (output-file o c) :executable t :compression t))
(defsystem "monero-explorer-mcclim"
:name "monero-explorer-mcclim"
:description "Blockchain explorer for the Monero crypto-currency (McCLIM GUI)"
:version "0.1"
:author "Guillaume LE VAILLANT"
:license "GPL-3"
:depends-on ("mcclim"
"monero-explorer-common"
"monero-rpc")
:build-operation "program-op"
:build-pathname "monero-explorer-mcclim"
:entry-point "monero-explorer-mcclim:gui"
:components ((:module "src"
:components ((:file "gui-mcclim")))))
| 888 | Common Lisp | .asd | 22 | 36.090909 | 80 | 0.698376 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | afffa192b3a1eefe95f8c30383419ce20d1539ac3e47e57ece98be875738501d | 16,656 | [
-1
] |
16,657 | monero-explorer-common.asd | glv2_cl-monero-explorer/monero-explorer-common.asd | ;;;; This file is part of monero-explorer
;;;; Copyright 2019 Guillaume LE VAILLANT
;;;; Distributed under the GNU GPL v3 or later.
;;;; See the file LICENSE for terms of use and distribution.
(cl:in-package :asdf-user)
(defsystem "monero-explorer-common"
:name "monero-explorer-common"
:description "Blockchain explorer for the Monero crypto-currency"
:version "0.1"
:author "Guillaume LE VAILLANT"
:license "GPL-3"
:depends-on ("monero-tools"
"monero-rpc"
"monero-utils")
:components ((:module "src"
:components ((:file "lookup")))))
| 599 | Common Lisp | .asd | 16 | 32.5 | 67 | 0.675862 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 70a2cc5c291b768c142fd4a4e36193921b9a1cd4560d76b682915f82f2a8370e | 16,657 | [
-1
] |
16,658 | monero-explorer-ltk.asd | glv2_cl-monero-explorer/monero-explorer-ltk.asd | ;;;; This file is part of monero-explorer
;;;; Copyright 2019 Guillaume LE VAILLANT
;;;; Distributed under the GNU GPL v3 or later.
;;;; See the file LICENSE for terms of use and distribution.
(cl:in-package :asdf-user)
#+(and sbcl sb-core-compression)
(defmethod perform ((o program-op) (c system))
(uiop:dump-image (output-file o c) :executable t :compression t))
(defsystem "monero-explorer-ltk"
:name "monero-explorer-ltk"
:description "Blockchain explorer for the Monero crypto-currency (LTK GUI)"
:version "0.1"
:author "Guillaume LE VAILLANT"
:license "GPL-3"
:depends-on ("ltk"
"monero-explorer-common"
"monero-rpc")
:build-operation "program-op"
:build-pathname "monero-explorer-ltk"
:entry-point "monero-explorer-ltk:gui"
:components ((:module "src"
:components ((:file "gui-ltk")))))
| 867 | Common Lisp | .asd | 22 | 35.136364 | 77 | 0.690844 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | c11dec9be15aaa078b63c80dea1b47b67bb0dc4f1c8ae1601d37d9843100b80a | 16,658 | [
-1
] |
16,659 | monero-explorer-gtk.asd | glv2_cl-monero-explorer/monero-explorer-gtk.asd | ;;;; This file is part of monero-explorer
;;;; Copyright 2019 Guillaume LE VAILLANT
;;;; Distributed under the GNU GPL v3 or later.
;;;; See the file LICENSE for terms of use and distribution.
(cl:in-package :asdf-user)
#+(and sbcl sb-core-compression)
(defmethod perform ((o program-op) (c system))
(uiop:dump-image (output-file o c) :executable t :compression t))
(defsystem "monero-explorer-gtk"
:name "monero-explorer-gtk"
:description "Blockchain explorer for the Monero crypto-currency (GTK GUI)"
:version "0.1"
:author "Guillaume LE VAILLANT"
:license "GPL-3"
:depends-on ("cl-cffi-gtk"
"monero-explorer-common"
"monero-rpc")
:build-operation "program-op"
:build-pathname "monero-explorer-gtk"
:entry-point "monero-explorer-gtk:gui"
:components ((:module "src"
:components ((:file "gui-gtk")))))
| 875 | Common Lisp | .asd | 22 | 35.5 | 77 | 0.691402 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | f33f647ed85165f42ea895780c007b59e6f8c619c92dea44d325bf3b1fe9ccff | 16,659 | [
-1
] |
16,663 | Makefile | glv2_cl-monero-explorer/Makefile | LISP ?= sbcl
all: bin/monero-explorer-gtk bin/monero-explorer-ltk bin/monero-explorer-mcclim bin/monero-explorer-nodgui bin/monero-explorer-qt
bin/monero-explorer-gtk: monero-explorer-gtk.asd src/lookup.lisp src/gui-gtk.lisp
mkdir -p "bin"
${LISP} --eval "(asdf:make \"monero-explorer-gtk\")" --eval "(uiop:quit)"
mv "monero-explorer-gtk" "bin/"
bin/monero-explorer-ltk: monero-explorer-ltk.asd src/lookup.lisp src/gui-ltk.lisp
mkdir -p "bin"
${LISP} --eval "(asdf:make \"monero-explorer-ltk\")" --eval "(uiop:quit)"
mv "monero-explorer-ltk" "bin/"
bin/monero-explorer-mcclim: monero-explorer-mcclim.asd src/lookup.lisp src/gui-mcclim.lisp
mkdir -p "bin"
${LISP} --eval "(asdf:make \"monero-explorer-mcclim\")" --eval "(uiop:quit)"
mv "monero-explorer-mcclim" "bin/"
bin/monero-explorer-nodgui: monero-explorer-nodgui.asd src/lookup.lisp src/gui-nodgui.lisp
mkdir -p "bin"
${LISP} --eval "(asdf:make \"monero-explorer-nodgui\")" --eval "(uiop:quit)"
mv "monero-explorer-nodgui" "bin/"
bin/monero-explorer-qt: monero-explorer-qt.asd src/lookup.lisp src/gui-qt.lisp
mkdir -p "bin"
${LISP} --eval "(asdf:make \"monero-explorer-qt\")" --eval "(uiop:quit)"
| 1,172 | Common Lisp | .l | 21 | 53.857143 | 129 | 0.724891 | glv2/cl-monero-explorer | 4 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | c57921b31e6cd3bac7208d5ea06b33759ea4fa8747d01622b5477d8f4c2e9c7b | 16,663 | [
-1
] |
16,684 | package.lisp | yoelmatveyev_marthue/package.lisp | (defpackage :cl-marthue
(:use :common-lisp)
(:export make-marthue-program
marthue-program-code
marthue-program-block
marthue-program-dir
marthue-program-mode
marthue-program-counter
marthue-program-step
marthue-program-stack
marthue-program-halted
marthue-program-line
marthue-program-newline
msearch
marthue-reset
marthue-run
load-thue-program
load-markov-program
run
load-run
load-program
))
(in-package :cl-marthue)
| 502 | Common Lisp | .lisp | 23 | 17.217391 | 31 | 0.72479 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | a1f849bb05f32ddce875cd74bb99cf0540f436e50d2841c3b9c740bc11c10c0f | 16,684 | [
-1
] |
16,685 | marthue.lisp | yoelmatveyev_marthue/marthue.lisp | ;; The main structure that stores the Marthue program and its state
(defstruct marthue-program
code
block
dir
mode
counter
block-counter
step
stack
halted
line
newline)
;; Substring replacement (from the Common Lisp Cookbook)
(defun replace-all (string part replacement &key (test #'char=))
(with-output-to-string (out)
(loop with part-length = (length part)
for old-pos = 0 then (+ pos part-length)
for pos = (search part string
:start2 old-pos
:test test)
do (write-string string out
:start old-pos
:end (or pos (length string)))
when pos do (write-string replacement out)
while pos)))
;; Forward, backward and random substring search
(defun msearch (l1 l2 &optional (dir 1))
(let (found p)
(case dir
(1 (search l1 l2))
(-1 (search l1 l2 :from-end t))
(otherwise
(loop for x from 0 to (- (length l2) (length l1)) do
(setf p (search l1 l2 :start2 x))
(if p
(progn (push p found) (setq x p))
(return)))
(if found (nth (random (length found)) found) nil)))))
;; Determing the search direction
(defun rule-dir (dir rand rule)
(let (d
(b (member :B rule))
(f (member :F rule)))
(setf d (if dir dir
(if rand 0 1)))
(if (and b f) 0
(if b -1
(if f 1
d)))))
;; Auxiliary function for stepping through a program block
(defun block-step (rules line &key dir rand debug)
(let* ((l (length rules))
(n nil) (r (random l)) s1 s2 rule p d c v s dr)
(if rand
(case (random 2)
(0 (loop for x from r to (+ r l -1) do
(setf
rule (elt rules (mod x l))
d (rule-dir dir rand rule)
n (msearch (car rule) line d))
(when n (setf c (mod x l)) (return n))))
(1 (loop for x from r downto (- r l +1) do
(setf
rule (elt rules (mod x l))
d (rule-dir dir rand rule)
n (msearch (car rule) line d))
(when n (setf c (mod x l)) (return n)))))
(loop for x from 0 to (1- l) do
(setf
rule (elt rules x)
d (rule-dir dir rand rule)
n (msearch (car rule) line d))
(when n (setf c x) (return n))))
(when n
(setf s1 (subseq line 0 n)
s2 (subseq line (+ n (length (car rule))))
p (cadr rule))
(when (member :O rule)
(format t "~a" (cadr rule))
(setf p nil))
(when (member :I rule)
(if (zerop dir)
(setf dr (1- (* 2 (random 2))))
(setf dr dir))
(if (or (and (member :F rule)(member :B rule)) (member :X rule))
(setf dr (1- (* 2 (random 2))))
(if (member :F rule)
(setf dr 1)
(if (member :B rule)
(setf dr -1))))
(setf p
(case dr
(-1 (concatenate 'string (read-line) p))
(1 (concatenate 'string p (read-line))))))
(setf line (concatenate 'string s1 p s2)))
(if debug (progn
(format t "~%Dir:~a Random:~a Rule:~a" d rand c)
(print rule)
(format t "~%~a~%" line)))
(setf s
(remove nil (list (if (find :N rule) :N)
(if (find :R rule) :R)
(find-if-not #'constantp rule))))
(if (and n s)
(setf v s)
(setf v (if n nil '(:N))))
(values line v c)))
;; Is the block Markov-line or Thue-like?
(defun block-mode (block)
(if (member :T (car block)) t))
;; What's the default search direction of the block?
(defun block-dir (block)
(let* ((a (if (block-mode block) 0 1))
(c (car block))
(b (member :B c))
(f (member :F c)))
(if (and b f) 0
(if b -1
(if f 1
a)))))
;; Resetting the program
(defun marthue-reset (pr &key code line)
(when code
(setf (marthue-program-code pr) code))
(when line
(setf (marthue-program-line pr) line))
(setf (marthue-program-stack pr) nil
(marthue-program-step pr) 0
(marthue-program-block pr) 0
(marthue-program-counter pr) 0
(marthue-program-halted pr ) nil
(marthue-program-dir pr ) (block-dir
(elt (marthue-program-code pr)
(marthue-program-block pr)))
(marthue-program-newline pr ) (marthue-program-line pr)
(marthue-program-mode pr)
(block-mode
(elt (marthue-program-code pr)
(marthue-program-block pr))))
t)
;; Auxiliary function for termination conditions and jumping between blocks
(defun marthue-update (pr status &key debug)
(let* (
(block (marthue-program-block pr))
(newblock block)
(blength (length (marthue-program-code pr)))
lbl term)
(when (and (listp status) (find :N status))
(incf newblock)
(setf term t))
(if (and (listp status) (find-if-not #'constantp status))
(if (find :R status)
(let (c n (l (car (last status))))
(if l
(if (marthue-program-stack pr)
(loop for x from 0 to (1- (length (marthue-program-stack pr))) do
(setf n (nth x (marthue-program-stack pr)))
(when (find l (car (elt (marthue-program-code pr) n))
:test #'string=)
(if (/= n block)
(progn (setf
(marthue-program-stack pr)
(subseq (marthue-program-stack pr) x)
c (car (marthue-program-stack pr))
newblock (if (numberp c) c blength))
(pop (marthue-program-stack pr)))
(if (marthue-program-stack pr)
(setf newblock (pop (marthue-program-stack pr)))
(unless (find :N status)
(setf newblock blength))))
(return)))
(unless (find :N status)
(setf newblock blength)))
(if (marthue-program-stack pr)
(setf newblock (pop (marthue-program-stack pr)))
(unless (find :N status) (setf newblock blength)))))
(let ((l (car (last status))))
(loop for x from 0 to (1- blength) do
(if (find l (car (elt (marthue-program-code pr) x)) :test #'string=)
(push x lbl)))
(when lbl
(setf newblock (elt lbl (random (length lbl))))
(if (and (/= block newblock) (not term))
(push block (marthue-program-stack pr))))
(unless lbl
(setf newblock blength)))))
(if debug
(format t "~%Status change:~a Block:~a Next block:~a Stack:~a~%"
status block newblock (marthue-program-stack pr)))
(if (< newblock blength)
(setf
(marthue-program-step pr) 0
(marthue-program-block pr) newblock
(marthue-program-dir pr ) (block-dir
(elt (marthue-program-code pr)
(marthue-program-block pr)))
(marthue-program-mode pr) (block-mode
(elt (marthue-program-code pr)
(marthue-program-block pr))))
(setf (marthue-program-halted pr) t))
nil))
;; The main engine
(defun marthue-run (pr &key (steps -1) debug fulldebug line reset (warn t))
(let* ((halted (marthue-program-halted pr))
blk mode dir rules (status nil))
(unless steps (setf steps -1))
(when halted
(when warn
(format t "~%Program was terminated. Reset it?")
(when (y-or-n-p)
(marthue-reset pr)
(format t "Try to run it again!~%")))
(unless warn
(marthue-reset pr)))
(when reset
(marthue-reset pr))
(if line
(setf (marthue-program-line pr) line
(marthue-program-newline pr) line))
(loop while (and (/= steps 0)(null halted)) do
(loop while (and (/= steps 0)(null status)) do
(setf blk (marthue-program-block pr)
rules (cadr (elt (marthue-program-code pr) blk))
mode (block-mode (elt (marthue-program-code pr) blk))
dir (block-dir (elt (marthue-program-code pr) blk)))
(multiple-value-bind (l v c)
(block-step rules
(marthue-program-newline pr)
:rand mode :dir dir :debug fulldebug)
(setf (marthue-program-newline pr) l
(marthue-program-step pr) c
status v)
(incf (marthue-program-counter pr))
(decf steps)))
(if status (setf status (marthue-update pr status :debug (or debug fulldebug))
halted (marthue-program-halted pr)))
(if (zerop steps)
(return (marthue-program-newline pr))))
(marthue-program-newline pr)))
;; Convert a Thue program into a Marthue structure
(defun load-thue-program (file &key line)
(let (p r l res (c (make-array 1 :adjustable t)))
(with-open-file (stream file)
(setf p (loop for l = (read-line stream nil)
while l
collect (string-trim " " l))))
(setf p (remove "" p :test #'equal)
p (remove "::=" p)
p (remove "#::=" p :test (lambda (x y) (eql 0 (search x y))))
r (subseq p 0 (- (length p) 2))
l (nth (1- (length p)) p)
r (mapcar (lambda (x)
(let* ((n (search "::=" x))
(s (subseq x (+ n 3)))
(h (list (subseq x 0 n) s)))
(if (equal s ":::")
(setf h (append h '(:I))
(cadr h) ""))
(if (and (>= (length s) 1)(equal (subseq s 0 1) "~"))
(setf h (append h '(:O))
(cadr h) (subseq x (+ n 4))))
h))
r))
(setf
(aref c 0) (list '(:T) (coerce r 'vector))
res (make-marthue-program)
(marthue-program-code res) c
(marthue-program-line res) (if line line (remove-backslash l)))
(marthue-reset res)
res))
;; Convert a Markov algorithm into a Marthue structure
(defun load-markov-program (file &key line)
(let (p r l res last (c (make-array 1 :adjustable t)))
(with-open-file (stream file)
(setf p (loop for l = (read-line stream nil)
while l
collect l)))
(setf last (last p)
p (remove "" p :test
(lambda (x y)
(or (eql x y) (eql nil (search "->" y)))))
p (append p last)
r (subseq p 0 (- (length p) 1))
l (nth (1- (length p)) p)
r (mapcar (lambda (x)
(let* (h
(n (search "->" x))
(s (subseq x (+ n 2))))
(if (and
(not (equal s ""))
(equal (subseq s 0 1) "."))
(setf h (list (subseq x 0 n) (subseq s 1) :N))
(setf h (list (subseq x 0 n) s)))
h))
r))
(setf
(aref c 0) (list '(:M) (coerce r 'vector))
res (make-marthue-program)
(marthue-program-code res) c
(marthue-program-line res) (if line line (remove-backslash l)))
(marthue-reset res)
res))
;; Auxiliary function for splitting the Marthue code into blocks
(defun split-code (l delimiter1 delimiter2)
(let (pr bl)
(loop for x from 0 to (length l) do
(when (and (search delimiter1 (nth x l))
(not (search delimiter2 (nth x l))))
(loop for y from (1+ x) to (length l)
do
(if (or (search delimiter2 (nth y l)))
(push (nth y l) bl)
(progn
(push (list (nth x l)(reverse bl)) pr)
(setf bl nil x (1- y))
(return))))))
(reverse pr)))
;; Remove extra spaces before the opcode
(defun remove-extra-spaces (s)
(let ((a (search "::" s)))
(if a
(concatenate 'string
(remove-duplicates
(subseq s 0 a)
:test (lambda (x y)
(and (eql x y)(eql x #\Space))))
(subseq s a))
s)))
;; Getting label/opcode information from a string
(defun string-opcode (s &key (opcode nil))
(let (lbl type sc)
(setf s (remove-extra-spaces s)
sc (search "::" s))
(if sc
(progn (unless opcode (setf s (subseq s 0 sc)))
(setf type (subseq s 0 (search " " s))
lbl (search " " s :from-end t)
lbl (if lbl (make-symbol (string-upcase (subseq s (1+ lbl)))) nil)
type (if type type s)
type (remove nil
(remove-duplicates
(list (if (search "M" type) :M)
(if (search "T" type) :T)
(if (search "B" type) :B)
(if (search "F" type) :F)
(if (search "X" type) :B)
(if (search "X" type) :F)
(if (search "I" type) :I)
(if (search "O" type) :O)
(if (search "N" type) :N)
(if (search "R" type) :R)
(if (search "C" type) :C)))))
(remove nil (append type (list lbl))))
nil)))
;; Yes, that's ugly :-)
(defun remove-backslash (s)
(replace-all
(replace-all
(replace-all
(replace-all
(replace-all
s
"\\-" "-")
"\\:" ":")
"\\>" ">")
"\\\." ".")
"\\\n" (string #\newline)))
;; Convert a replacement rule to Lisp
(defun rule-to-lisp (x)
(let (n s)
(if (setf n (search "->." x))
(setf s (subseq x (+ n 3)))
(setf n (search "->" x)
s (subseq x (+ n 2))))
(list
(remove-backslash (subseq x 0 (search "->" x)))
(remove-backslash s))))
;; Convert a Marthue algorithm from a file
(defun load-marthue-program (file &key line)
(let (p l res)
(with-open-file (stream file)
(setf p (loop for l = (read-line stream nil)
while l
collect l)))
(setf l (nth (1- (length p)) p))
(if (or (search "::" l)(search "->" l))
(setf l "")
(setf p (subseq p 0 (- (length p) 1))))
(setf p (split-code
(remove-if-not (lambda (x)
(and (or (search "::" x)(search "->" x))
(not (eql 0 (search "#::" x))))) p) "::" "->")
p (mapcar (lambda (x)
(let ((m (string-opcode (car x))))
(list (if m m '(:M))
(mapcar (lambda (y)
(let ((z (search "::" y)))
(append
(rule-to-lisp (if z (subseq y (+ z 2)) y))
(if (search "->." y) (list :N))
(string-opcode y))))
(cadr x)))))
p)
p (remove nil p :test (lambda (x y) (eql x (cadr y)))))
(setf res (make-marthue-program)
(marthue-program-code res) p
(marthue-program-line res) (if line line (if l (remove-backslash l) "")))
(marthue-reset res)
res))
;; Load a Marthue program as Lisp code
(defun load-lisp-marthue (prg)
(let
((st (make-marthue-program))
code line)
(if (stringp prg)
(with-open-file (in prg)
(setf code (loop for x = (read in nil)
until (null x) collect x)
line (cadr code)
code (car code)))
(setf code prg))
(setf (marthue-program-code st) code
(marthue-program-line st) line)
(marthue-reset st)
st))
(defmacro load-run (program file &key path type line steps debug fulldebug)
`(progn
(defparameter ,program
(case ,type
(markov
(load-markov-program
(concatenate 'string
',(if path path "") "/" ,file ".m") :line ,line))
(thue
(load-thue-program
(concatenate 'string
',(if path path "") "/" ,file ".t") :line ,line))
(marthue
(load-marthue-program
(concatenate 'string
',(if path path "") "/" ,file ".mrt") :line ,line))
(otherwise
(load-marthue-program
(concatenate 'string
',(if path path "") "/" ,file ".mrt") :line ,line))))
(marthue-run ,program :steps ,steps :debug ,debug :fulldebug ,fulldebug :line ,line)))
(defmacro load-program (program file &key path type line)
`(defparameter ,program
(case ,type
(markov
(load-markov-program
(concatenate 'string
',(if path path "") "/" ,file ".m") :line ,line))
(thue
(load-thue-program
(concatenate 'string
',(if path path "") "/" ,file ".t") :line ,line))
(marthue
(load-marthue-program
(concatenate 'string
',(if path path "") "/" ,file ".mrt") :line ,line))
(otherwise
(load-marthue-program
(concatenate 'string
',(if path path "") "/" ,file ".mrt") :line ,line)))))
(setf (symbol-function 'run) #'marthue-run)
| 14,858 | Common Lisp | .lisp | 467 | 26.513919 | 91 | 0.585803 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 845946ac2e038f1b839d953dd6b44e48a81ae44002efc7a6a0952acff11e48bc | 16,685 | [
-1
] |
16,686 | roman.mt.lisp | yoelmatveyev_marthue/examples/marthue/roman.mt.lisp | ;; Convert series of * to Roman numerals
#(((:M a) #(("" "Input series of * like **** ****** *******....
" :O :C b)))
((:M b) #(("" "_" :I :T)))
((:M) #(("*" "I") ("IIIII" "V") ("IIII" "IV") ("VV" "X") ("VIV" "IX")
("XXXXX" "L") ("XXXX" "XL") ("LL" "C") ("LXL" "XC") ("CCCCC" "D")
("CCCC" "CD") ("DD" "M") ("DCD" "CM") ("" "_" :T)))
; Print the result
((:M) #(("_M" "_*M") ("_D" "_*D") ("_C" "_*C") ("_L" "_*L") ("_X" "_*X")
("_V" "_*V") ("_I" "_*I") ("_ " "_* ")("*M" "M" :O)
("*D" "D" :O) ("*C" "C" :O) ("*L" "L" :O) ("*X" "X" :O)
("*V" "V" :O) ("*I" "I" :O) ("* " " " :O) (" " "")))
((:M)#(("_" "
Try again? (y/n)
" :O)("" "_" :T)))
; Going back, if the answers is "y"
((:M)#(("_" "" :I) ("y" "" :R a) ("n" "" :R end))))
| 770 | Common Lisp | .lisp | 17 | 41.588235 | 73 | 0.290495 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | ce2346bb054af3b21b16e2eed9eb49f8f60f35d8001d8ea3097c67ff1b9d588e | 16,686 | [
-1
] |
16,687 | dec.mt.lisp | yoelmatveyev_marthue/examples/marthue/dec.mt.lisp | ;; Input a binary number, decrement it and print out the result
#(((:M) #(("" "Input a binary number:" :O :T)))
((:M) #(("" "" :I :T)))
((:M) #(("" "_" :T)))
((:M :B) #(("" "_" :T)))
((:T) #(("0_" "0--") ("1_" "0") ("10--" "01") ("00--" "0--1") ("_1--" "@")("_0--" "1") ("_0" "")))
((:M) #(("_1" "_*1")("_0" "_*0")("*1" "1" :O) ("*0" "0" :O)("_" ""))))
| 354 | Common Lisp | .lisp | 7 | 49.428571 | 98 | 0.306358 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 75f7fa4b7acb2da1ee35ef5fc8129f340be9be7cb86d5fed2ea45435c0586eba | 16,687 | [
-1
] |
16,688 | marthue.asd | yoelmatveyev_marthue/marthue.asd | (defsystem :marthue
:name "Marthue"
:version "0.0.1"
:maintainer "Yoel Matveyev"
:author "Yoel Matveyev"
:licence "GNU General Public License v3.0"
:description "Esoteric programming language based on string replacement"
:long-description "A virtual machine for an esoteric programming language, which extends both semi-Thue systems and Markov algorithms"
:components ((:file "package")
(:file "marthue")))
| 433 | Common Lisp | .asd | 10 | 39.7 | 136 | 0.748815 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 7da1e383f7a9558fc892188c1fe296a25f85abeed7f9cbcad86f08c9e2c97cad | 16,688 | [
-1
] |
16,692 | calculator.m | yoelmatveyev_marthue/examples/markov/calculator.m | # Source: http://huh-muh.blogspot.com/2013/06/blog-post_16.html
// Пример: простейший калькулятор
// (сложение, вычитание, умножение натуральных чисел)
// Алфавит: 1234567890+-*abcdefghioxyz^@$#?
// переводим числа из унарной в десятичную систему (часть 2)
z^->za
o^->a
a^->b
b^->c
c^->d
d^->e
e^->f
f^->g
g^->h
h^->i
i^->^o
za->1z
zb->2z
zc->3z
zd->4z
ze->5z
zf->6z
zg->7z
zh->8z
zi->9z
zo->0z
z->.
// переводим числа из десятичной в унарную систему счисления
1->0$
2->1$
3->2$
4->3$
5->4$
6->5$
7->6$
8->7$
9->8$
$0->0$$$$$$$$$$
0->
// умножаем числа в унарной системе счисления
x$->$?x
x?->?
x->
?$->$?
$$*$->$*x$
$*$->$
*$$->*$
*$->
?->$
// преобразуем отрицательные числа в унарной системе счисления
-$->#
#$->##
// убираем плюсы
$+#->+
#+$->+
+->
// сокращаем пары
#$->
$#->
// переводим положительные числа из унарной в десятичную систему (часть 1)
^$->^^
$->y^
y->zo
// переводим отрицательные числа из унарной в десятичную систему (часть 1)
^#->^^
#->@^
@->-zo
2*2
| 1,390 | Common Lisp | .l | 68 | 13.323529 | 74 | 0.635762 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 0c595c077aa92833d7251fcc228997d009e3f6b9679207e8e3a26c84bb5d22f1 | 16,692 | [
-1
] |
16,693 | digitalr.t | yoelmatveyev_marthue/examples/thue/digitalr.t | #::= digital root calculator
#::= written by Keymaker
#::= use digits (0123456789) to input your non-negative integer
b::=:::
0::=
1::=!
2::=!!
3::=!!!
4::=!!!!
5::=!!!!!
6::=!!!!!!
7::=!!!!!!!
8::=!!!!!!!!
9::=!!!!!!!!!
!!!!!!!!!!::=!
a!!!!!!!!!c::=~9
a!!!!!!!!c::=~8
a!!!!!!!c::=~7
a!!!!!!c::=~6
a!!!!!c::=~5
a!!!!c::=~4
a!!!c::=~3
a!!c::=~2
a!c::=~1
ac::=~0
..::=~
::=
.abc.
| 378 | Common Lisp | .l | 28 | 12.5 | 63 | 0.371429 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 84d11fca4c69c622ccf2675b710204225a9fe93a072719510de10d1ba4ec1edc | 16,693 | [
-1
] |
16,694 | digital_root.mrt | yoelmatveyev_marthue/examples/marthue/digital_root.mrt | # Digital root calculator by a Thue algorithm
# Written by Keymaker
# Ported to Marthue by Yoel Matveyev
::
O::->.Enter a natural decimal number:
::
->..abc.
T::
I::b->
0->
1->!
2->!!
3->!!!
4->!!!!
5->!!!!!
6->!!!!!!
7->!!!!!!!
8->!!!!!!!!
9->!!!!!!!!!
!!!!!!!!!!->!
O::a!!!!!!!!!c->9
O::a!!!!!!!!c->8
O::a!!!!!!!c->7
O::a!!!!!!c->6
O::a!!!!!c->5
O::a!!!!c->4
O::a!!!c->3
O::a!!c->2
O::a!c->1
O::ac->0
O::..->
| 411 | Common Lisp | .l | 31 | 12.258065 | 45 | 0.439474 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | 3454dce4a04434ffe93bbb562e5c3f3eda1696805b56ed02884b6e3d65e95f8f | 16,694 | [
-1
] |
16,697 | calculator.mrt | yoelmatveyev_marthue/examples/marthue/calculator.mrt | # A basic calculator supporting addition, subtraction and multiplication of natural numbers
# Found here: http://huh-muh.blogspot.com/2013/06/blog-post_16.html
# Ported to Marthue by Yoel Matveyev
::
IO::->.Введите арифметическое выражение (например, 10*2+14*12+7):
::
// Пример: простейший калькулятор
// (сложение, вычитание, умножение натуральных чисел)
// Алфавит: 1234567890+-*abcdefghioxyz^@$#?
// переводим числа из унарной в десятичную систему (часть 2)
z^->za
o^->a
a^->b
b^->c
c^->d
d^->e
e^->f
f^->g
g^->h
h^->i
i^->^o
za->1z
zb->2z
zc->3z
zd->4z
ze->5z
zf->6z
zg->7z
zh->8z
zi->9z
zo->0z
z->.
// переводим числа из десятичной в унарную систему счисления
1->0$
2->1$
3->2$
4->3$
5->4$
6->5$
7->6$
8->7$
9->8$
$0->0$$$$$$$$$$
0->
// умножаем числа в унарной системе счисления
x$->$?x
x?->?
x->
?$->$?
$$*$->$*x$
$*$->$
*$$->*$
*$->
?->$
// преобразуем отрицательные числа в унарной системе счисления
-$->#
#$->##
// убираем плюсы
$+#->+
#+$->+
+->
// сокращаем пары
#$->
$#->
// переводим положительные числа из унарной в десятичную систему (часть 1)
^$->^^
$->y^
y->zo
// переводим отрицательные числа из унарной в десятичную систему (часть 1)
^#->^^
#->@^
@->-zo
| 1,630 | Common Lisp | .l | 72 | 15.319444 | 91 | 0.663645 | yoelmatveyev/marthue | 4 | 0 | 1 | GPL-3.0 | 9/19/2024, 11:27:30 AM (Europe/Amsterdam) | d97d67825adc7ed9cb1302767a31d050c462f0dc4c9a88178b789b210b8a8500 | 16,697 | [
-1
] |
16,712 | packages.lisp | lepisma_plotly-cl/packages.lisp | ;;;; package.lisp
(defpackage #:plotly-cl
(:use #:cl)
(:export #:pl-plot
#:pl-scatter
#:pl-line
#:pl-fn))
| 144 | Common Lisp | .lisp | 7 | 14.142857 | 23 | 0.477941 | lepisma/plotly-cl | 3 | 3 | 1 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | d9ae99766179339fba2bc12ef6d1be0d9121514bd18abd4687c8444479a51e2a | 16,712 | [
-1
] |
16,713 | wrappers.lisp | lepisma_plotly-cl/wrappers.lisp | ;;;; User end wrappers around main plotly function
(in-package #:plotly-cl)
(defun pl-line (x y &key layout)
"Single line plot"
(let ((trace `((:x . ,x) (:y . ,y))))
(pl-plot (list trace) :layout layout)))
(defun pl-scatter (x y &key layout)
"Single scatter plot"
(let ((trace `((:x . ,x) (:y . ,y) (:mode . "markers") (:type . "scatter"))))
(pl-plot (list trace) :layout layout)))
(defun pl-fn (fn &key (low 0) (high 1) (points 1000) layout)
"Plot the function in the given range"
(let* ((x (loop for i from 1 to points
collect (+ low (* i (/ (- high low) points)))))
(y (mapcar fn x)))
(pl-line x y :layout layout)))
| 674 | Common Lisp | .lisp | 16 | 37.6875 | 79 | 0.584098 | lepisma/plotly-cl | 3 | 3 | 1 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 25b7335025bd5a583138ce59db7c9b527058853d67737caec25eed3710fd9899 | 16,713 | [
-1
] |
16,714 | plotly-cl.asd | lepisma_plotly-cl/plotly-cl.asd | ;;;; plotly.lisp.asd
(asdf:defsystem #:plotly-cl
:description "Lisp to plotly.js"
:author "Abhinav Tushar <[email protected]>"
:license "GPLv3"
:depends-on (#:parenscript
#:cl-who
#:cl-json
#:cl-css
#:cl-interpol
#:uiop)
:serial t
:components ((:file "packages")
(:file "core")
(:file "wrappers")))
| 420 | Common Lisp | .asd | 15 | 19.133333 | 49 | 0.512376 | lepisma/plotly-cl | 3 | 3 | 1 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 23373f76a83dd7e2b97844c7780a4bc99da05189344483438f6e86f0dec7b414 | 16,714 | [
-1
] |
16,735 | vesicapiscis.lsp | liuteriadautore_AutoLISP/vesicapiscis.lsp | (defun c:LT-VesicaByStartEnd ()
; Construct a Vesica Piscis from the start and end point at the maximum width
(setq
vpq1 (getpoint "Set the first quadrant point")
vpq2 (getpoint "Set the second quadrant point")
)
; draw the vesica
(drawvesicapiscis vpq1 vpq2)
)
(defun c:LT-VesicaByStartCenter ()
(setq
vpq1 (getpoint "Set the first quadrant point")
vpc (getpoint "Set the center point")
)
; find the second quadrant point
(setq vpq2x(- (car vpq1) (* (- (car vpq1) (car vpc)) 2)))
(setq vpq2y(- (cadr vpq1) (* (- (cadr vpq1) (cadr vpc)) 2)))
(setq vpq2 (list vpq2x vpq2y))
; draw the vesica
(drawvesicapiscis vpq1 vpq2)
)
(defun c:LT-VesicaByCenterEnd ()
; Constuct a Vesica Piscis from the center and the end point, at the maximum width
(setq
vpc (getpoint "Set the center point")
vpq1 (getpoint "Set the second quadrant point")
)
; find the second quadrant point
(setq vpq2x(- (car vpq1) (* (- (car vpq1) (car vpc)) 2)))
(setq vpq2y(- (cadr vpq1) (* (- (cadr vpq1) (cadr vpc)) 2)))
(setq vpq2 (list vpq2x vpq2y))
; draw the vesica
(drawvesicapiscis vpq1 vpq2)
)
;;; Internal Functions
(defun DrawVesicaPiscis (vpq1 vpq2)
; define the first center point, at one third between the two defined points
(setq x1(/ (- (car vpq2) (car vpq1)) 3.00))
(setq y1(/ (- (cadr vpq2) (cadr vpq1)) 3.00))
(setq vpc1 (list (+ (car vpq1) x1) (+ (cadr vpq1) y1)))
; define the second center point, at two thirds between the two defined points
(setq x2(/ (- (car vpq1) (car vpq2)) 3.00))
(setq y2(/ (- (cadr vpq1) (cadr vpq2)) 3.00))
(setq vpc2 (list (+ (car vpq2) x2) (+ (cadr vpq2) y2)))
; draw the vesica
(command "circle" vpc1 vpq1)
(command "circle" vpc2 vpq2)
) | 1,785 | Common Lisp | .l | 48 | 33.354167 | 84 | 0.661027 | liuteriadautore/AutoLISP | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | f27f90cf4bb33ef530d3641fb1515c5b773773b2cf2685c750de9a7915d6286e | 16,735 | [
-1
] |
16,736 | startup.lsp | liuteriadautore_AutoLISP/startup.lsp | ; This file is loaded at the startup of CorelCAD
(load "divisions")
(load "vesicapiscis") | 90 | Common Lisp | .l | 3 | 29 | 48 | 0.770115 | liuteriadautore/AutoLISP | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | b05327154e02d31b02b6db3ab379c5ccd69e0e73afe5ca0247e0670d4f961682 | 16,736 | [
-1
] |
16,737 | divisions.lsp | liuteriadautore_AutoLISP/divisions.lsp | ;; Draw a straight line from the mid point of a straight line
(defun c:LT-LineFromMidPoint()
(setq p1(getpoint "\n Pick First Point of the reference line")
p2(getpoint "\n Pick Second Point of the reference line")
p3(getpoint "\n Define the end point of the new line")
)
(setq x(/ (- (car p2) (car p1)) 2.00))
(setq y(/ (- (cadr p2) (cadr p1)) 2.00))
(setq midpoint(list (+ (car p1) x) (+ (cadr p1) y)))
(command "line" p3 midpoint "")
)
;; Draw a straight line from the mid point of a straight line
(defun c:LT-LineFromThirdPoint()
(setq p1(getpoint "\n Pick First Point of the reference line")
p2(getpoint "\n Pick Second Point of the reference line")
p3(getpoint "\n Define the end point of the new line")
)
(setq x(/ (- (car p2) (car p1)) 3.00))
(setq y(/ (- (cadr p2) (cadr p1)) 3.00))
(setq thirdpoint(list (+ (car p1) x) (+ (cadr p1) y)))
(command "line" p3 thirdpoint "")
)
;; Draw a straight line from the point at the golden section of a straight line
(defun c:LT-LineFromGoldenSection()
(setq p1(getpoint "\n Pick First Point of the reference line")
p2(getpoint "\n Pick Second Point of the reference line")
p3(getpoint "\n Define the end point of the new line")
)
(setq x(* (- (car p2) (car p1)) 0.618))
(setq y(* (- (cadr p2) (cadr p1)) 0.618))
(setq goldenpoint(list (+ (car p1) x) (+ (cadr p1) y)))
(command "line" p3 goldenpoint "")
) | 1,499 | Common Lisp | .l | 33 | 40.030303 | 79 | 0.617065 | liuteriadautore/AutoLISP | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | e169d1aa26885bb918bb3ee847ab2fbae1e41d65690b9ef0d14ec282ce2fab0c | 16,737 | [
-1
] |
16,738 | LineFromGolden.svg | liuteriadautore_AutoLISP/icons/dark/LineFromGolden.svg | <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="32.0px"
height="32.0px"
viewBox="0 0 32.0 32.0"
version="1.1"
id="SVGRoot">
<defs
id="defs10" />
<metadata
id="metadata13">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
style="fill:none;stroke:#cccccc;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="M 2,5 23,17"
id="path28" />
<path
style="fill:none;stroke:#999999;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="M 30,11 9,30"
id="path30" />
</g>
</svg>
| 1,173 | Common Lisp | .l | 38 | 25.421053 | 157 | 0.622907 | liuteriadautore/AutoLISP | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 9030e943ad41addad8b2d5d49b102b0ccc58a72c531ad4895200134a74e4bf26 | 16,738 | [
-1
] |
16,739 | LineFromGolden.svg | liuteriadautore_AutoLISP/icons/light/LineFromGolden.svg | <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32.0px"
height="32.0px"
viewBox="0 0 32.0 32.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="LineFromGolden.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview2071"
showgrid="false"
inkscape:zoom="13.75"
inkscape:cx="16"
inkscape:cy="16"
inkscape:current-layer="SVGRoot" />
<defs
id="defs10" />
<metadata
id="metadata13">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
style="fill:none;stroke:#00cccc;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 2,5 23,17"
id="path28" />
<path
style="fill:none;stroke:#999999;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 30,11 9,30"
id="path30" />
</g>
</svg>
| 1,858 | Common Lisp | .l | 59 | 26.033898 | 157 | 0.64925 | liuteriadautore/AutoLISP | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 930c7713c201f666bab831b52142a4bc47af28cbbc3cc2163dc77b6ca496b405 | 16,739 | [
-1
] |
16,757 | hyperspec.lisp | fisxoj_hyperspec/src/hyperspec.lisp | (defpackage :hyperspec
(:use #:cl #:alexandria)
(:export #:lookup)
(:documentation "Package for looking up hyperspec urls by symbol. The only exposed function is :function:`hyperspec:lookup`."))
(in-package #:hyperspec)
(defparameter *hyperspec-root* "http://www.lispworks.com/reference/HyperSpec/"
"The root of the Common Lisp HyperSpec URL.
If you copy the HyperSpec to your local system, set this variable to
something like ``file://usr/local/doc/HyperSpec/``.")
(defparameter *symbols* (make-hash-table :test 'equal)
"Maps symbol names to relative urls in the hyperspec.")
(defun clean-symbol (symbol)
"Takes a symbol or string and returns a downcased string of the symbol if it's in the common-lisp package."
(when (uiop:find-symbol* symbol :common-lisp nil)
(etypecase symbol
(symbol (string-downcase (symbol-name symbol)))
;; If its a string, try to remove the package
(string (string-downcase (if-let (colon-position (position #\: symbol :from-end t))
(subseq symbol colon-position)
symbol))))))
(defun lookup (symbol)
"Look up a symbol in the COMMON-LISP package and return a url to the appropriate hyperspec page. Returns ``nil`` if the symbol isn't found."
(when-let ((cl-symbol (clean-symbol symbol)))
(format nil "~aBody/~a" *hyperspec-root* (gethash cl-symbol *symbols*))))
(mapc (lambda (entry)
(setf (gethash (car entry) *symbols*) (cadr entry)))
'(("&allow-other-keys" "03_da.htm")
("&aux" "03_da.htm")
("&body" "03_dd.htm")
("&environment" "03_dd.htm")
("&key" "03_da.htm")
("&optional" "03_da.htm")
("&rest" "03_da.htm")
("&whole" "03_dd.htm")
("*" "a_st.htm")
("**" "v__stst_.htm")
("***" "v__stst_.htm")
("*break-on-signals*" "v_break_.htm")
("*compile-file-pathname*" "v_cmp_fi.htm")
("*compile-file-truename*" "v_cmp_fi.htm")
("*compile-print*" "v_cmp_pr.htm")
("*compile-verbose*" "v_cmp_pr.htm")
("*debug-io*" "v_debug_.htm")
("*debugger-hook*" "v_debugg.htm")
("*default-pathname-defaults*" "v_defaul.htm")
("*error-output*" "v_debug_.htm")
("*features*" "v_featur.htm")
("*gensym-counter*" "v_gensym.htm")
("*load-pathname*" "v_ld_pns.htm")
("*load-print*" "v_ld_prs.htm")
("*load-truename*" "v_ld_pns.htm")
("*load-verbose*" "v_ld_prs.htm")
("*macroexpand-hook*" "v_mexp_h.htm")
("*modules*" "v_module.htm")
("*package*" "v_pkg.htm")
("*print-array*" "v_pr_ar.htm")
("*print-base*" "v_pr_bas.htm")
("*print-case*" "v_pr_cas.htm")
("*print-circle*" "v_pr_cir.htm")
("*print-escape*" "v_pr_esc.htm")
("*print-gensym*" "v_pr_gen.htm")
("*print-length*" "v_pr_lev.htm")
("*print-level*" "v_pr_lev.htm")
("*print-lines*" "v_pr_lin.htm")
("*print-miser-width*" "v_pr_mis.htm")
("*print-pprint-dispatch*" "v_pr_ppr.htm")
("*print-pretty*" "v_pr_pre.htm")
("*print-radix*" "v_pr_bas.htm")
("*print-readably*" "v_pr_rda.htm")
("*print-right-margin*" "v_pr_rig.htm")
("*query-io*" "v_debug_.htm")
("*random-state*" "v_rnd_st.htm")
("*read-base*" "v_rd_bas.htm")
("*read-default-float-format*" "v_rd_def.htm")
("*read-eval*" "v_rd_eva.htm")
("*read-suppress*" "v_rd_sup.htm")
("*readtable*" "v_rdtabl.htm")
("*standard-input*" "v_debug_.htm")
("*standard-output*" "v_debug_.htm")
("*terminal-io*" "v_termin.htm")
("*trace-output*" "v_debug_.htm")
("+" "a_pl.htm")
("++" "v_pl_plp.htm")
("+++" "v_pl_plp.htm")
("-" "a__.htm")
("/" "a_sl.htm")
("//" "v_sl_sls.htm")
("///" "v_sl_sls.htm")
("/=" "f_eq_sle.htm")
("1+" "f_1pl_1_.htm")
("1-" "f_1pl_1_.htm")
("<" "f_eq_sle.htm")
("<=" "f_eq_sle.htm")
("=" "f_eq_sle.htm")
(">" "f_eq_sle.htm")
(">=" "f_eq_sle.htm")
("abort" "a_abort.htm")
("abs" "f_abs.htm")
("acons" "f_acons.htm")
("acos" "f_asin_.htm")
("acosh" "f_sinh_.htm")
("add-method" "f_add_me.htm")
("adjoin" "f_adjoin.htm")
("adjust-array" "f_adjust.htm")
("adjustable-array-p" "f_adju_1.htm")
("allocate-instance" "f_alloca.htm")
("alpha-char-p" "f_alpha_.htm")
("alphanumericp" "f_alphan.htm")
("and" "a_and.htm")
("append" "f_append.htm")
("apply" "f_apply.htm")
("apropos" "f_apropo.htm")
("apropos-list" "f_apropo.htm")
("aref" "f_aref.htm")
("arithmetic-error" "e_arithm.htm")
("arithmetic-error-operands" "f_arithm.htm")
("arithmetic-error-operation" "f_arithm.htm")
("array" "t_array.htm")
("array-dimension" "f_ar_dim.htm")
("array-dimension-limit" "v_ar_dim.htm")
("array-dimensions" "f_ar_d_1.htm")
("array-displacement" "f_ar_dis.htm")
("array-element-type" "f_ar_ele.htm")
("array-has-fill-pointer-p" "f_ar_has.htm")
("array-in-bounds-p" "f_ar_in_.htm")
("array-rank" "f_ar_ran.htm")
("array-rank-limit" "v_ar_ran.htm")
("array-row-major-index" "f_ar_row.htm")
("array-total-size" "f_ar_tot.htm")
("array-total-size-limit" "v_ar_tot.htm")
("arrayp" "f_arrayp.htm")
("ash" "f_ash.htm")
("asin" "f_asin_.htm")
("asinh" "f_sinh_.htm")
("assert" "m_assert.htm")
("assoc" "f_assocc.htm")
("assoc-if" "f_assocc.htm")
("assoc-if-not" "f_assocc.htm")
("atan" "f_asin_.htm")
("atanh" "f_sinh_.htm")
("atom" "a_atom.htm")
("base-char" "t_base_c.htm")
("base-string" "t_base_s.htm")
("bignum" "t_bignum.htm")
("bit" "a_bit.htm")
("bit-and" "f_bt_and.htm")
("bit-andc1" "f_bt_and.htm")
("bit-andc2" "f_bt_and.htm")
("bit-eqv" "f_bt_and.htm")
("bit-ior" "f_bt_and.htm")
("bit-nand" "f_bt_and.htm")
("bit-nor" "f_bt_and.htm")
("bit-not" "f_bt_and.htm")
("bit-orc1" "f_bt_and.htm")
("bit-orc2" "f_bt_and.htm")
("bit-vector" "t_bt_vec.htm")
("bit-vector-p" "f_bt_vec.htm")
("bit-xor" "f_bt_and.htm")
("block" "s_block.htm")
("boole" "f_boole.htm")
("boole-1" "v_b_1_b.htm")
("boole-2" "v_b_1_b.htm")
("boole-and" "v_b_1_b.htm")
("boole-andc1" "v_b_1_b.htm")
("boole-andc2" "v_b_1_b.htm")
("boole-c1" "v_b_1_b.htm")
("boole-c2" "v_b_1_b.htm")
("boole-clr" "v_b_1_b.htm")
("boole-eqv" "v_b_1_b.htm")
("boole-ior" "v_b_1_b.htm")
("boole-nand" "v_b_1_b.htm")
("boole-nor" "v_b_1_b.htm")
("boole-orc1" "v_b_1_b.htm")
("boole-orc2" "v_b_1_b.htm")
("boole-set" "v_b_1_b.htm")
("boole-xor" "v_b_1_b.htm")
("boolean" "t_ban.htm")
("both-case-p" "f_upper_.htm")
("boundp" "f_boundp.htm")
("break" "f_break.htm")
("broadcast-stream" "t_broadc.htm")
("broadcast-stream-streams" "f_broadc.htm")
("built-in-class" "t_built_.htm")
("butlast" "f_butlas.htm")
("byte" "f_by_by.htm")
("byte-position" "f_by_by.htm")
("byte-size" "f_by_by.htm")
("caaaar" "f_car_c.htm")
("caaadr" "f_car_c.htm")
("caaar" "f_car_c.htm")
("caadar" "f_car_c.htm")
("caaddr" "f_car_c.htm")
("caadr" "f_car_c.htm")
("caar" "f_car_c.htm")
("cadaar" "f_car_c.htm")
("cadadr" "f_car_c.htm")
("cadar" "f_car_c.htm")
("caddar" "f_car_c.htm")
("cadddr" "f_car_c.htm")
("caddr" "f_car_c.htm")
("cadr" "f_car_c.htm")
("call-arguments-limit" "v_call_a.htm")
("call-method" "m_call_m.htm")
("call-next-method" "f_call_n.htm")
("car" "f_car_c.htm")
("case" "m_case_.htm")
("catch" "s_catch.htm")
("ccase" "m_case_.htm")
("cdaaar" "f_car_c.htm")
("cdaadr" "f_car_c.htm")
("cdaar" "f_car_c.htm")
("cdadar" "f_car_c.htm")
("cdaddr" "f_car_c.htm")
("cdadr" "f_car_c.htm")
("cdar" "f_car_c.htm")
("cddaar" "f_car_c.htm")
("cddadr" "f_car_c.htm")
("cddar" "f_car_c.htm")
("cdddar" "f_car_c.htm")
("cddddr" "f_car_c.htm")
("cdddr" "f_car_c.htm")
("cddr" "f_car_c.htm")
("cdr" "f_car_c.htm")
("ceiling" "f_floorc.htm")
("cell-error" "e_cell_e.htm")
("cell-error-name" "f_cell_e.htm")
("cerror" "f_cerror.htm")
("change-class" "f_chg_cl.htm")
("char" "f_char_.htm")
("char-code" "f_char_c.htm")
("char-code-limit" "v_char_c.htm")
("char-downcase" "f_char_u.htm")
("char-equal" "f_chareq.htm")
("char-greaterp" "f_chareq.htm")
("char-int" "f_char_i.htm")
("char-lessp" "f_chareq.htm")
("char-name" "f_char_n.htm")
("char-not-equal" "f_chareq.htm")
("char-not-greaterp" "f_chareq.htm")
("char-not-lessp" "f_chareq.htm")
("char-upcase" "f_char_u.htm")
("char/=" "f_chareq.htm")
("char<" "f_chareq.htm")
("char<=" "f_chareq.htm")
("char=" "f_chareq.htm")
("char>" "f_chareq.htm")
("char>=" "f_chareq.htm")
("character" "a_ch.htm")
("characterp" "f_chp.htm")
("check-type" "m_check_.htm")
("cis" "f_cis.htm")
("class" "t_class.htm")
("class-name" "f_class_.htm")
("class-of" "f_clas_1.htm")
("clear-input" "f_clear_.htm")
("clear-output" "f_finish.htm")
("close" "f_close.htm")
("clrhash" "f_clrhas.htm")
("code-char" "f_code_c.htm")
("coerce" "f_coerce.htm")
("compilation-speed" "d_optimi.htm")
("compile" "f_cmp.htm")
("compile-file" "f_cmp_fi.htm")
("compile-file-pathname" "f_cmp__1.htm")
("compiled-function" "t_cmpd_f.htm")
("compiled-function-p" "f_cmpd_f.htm")
("compiler-macro" "f_docume.htm")
("compiler-macro-function" "f_cmp_ma.htm")
("complement" "f_comple.htm")
("complex" "a_comple.htm")
("complexp" "f_comp_3.htm")
("compute-applicable-methods" "f_comput.htm")
("compute-restarts" "f_comp_1.htm")
("concatenate" "f_concat.htm")
("concatenated-stream" "t_concat.htm")
("concatenated-stream-streams" "f_conc_1.htm")
("cond" "m_cond.htm")
("condition" "e_cnd.htm")
("conjugate" "f_conjug.htm")
("cons" "a_cons.htm")
("consp" "f_consp.htm")
("constantly" "f_cons_1.htm")
("constantp" "f_consta.htm")
("continue" "a_contin.htm")
("control-error" "e_contro.htm")
("copy-alist" "f_cp_ali.htm")
("copy-list" "f_cp_lis.htm")
("copy-pprint-dispatch" "f_cp_ppr.htm")
("copy-readtable" "f_cp_rdt.htm")
("copy-seq" "f_cp_seq.htm")
("copy-structure" "f_cp_stu.htm")
("copy-symbol" "f_cp_sym.htm")
("copy-tree" "f_cp_tre.htm")
("cos" "f_sin_c.htm")
("cosh" "f_sinh_.htm")
("count" "f_countc.htm")
("count-if" "f_countc.htm")
("count-if-not" "f_countc.htm")
("ctypecase" "m_tpcase.htm")
("debug" "d_optimi.htm")
("decf" "m_incf_.htm")
("declaim" "m_declai.htm")
("declaration" "d_declar.htm")
("declare" "s_declar.htm")
("decode-float" "f_dec_fl.htm")
("decode-universal-time" "f_dec_un.htm")
("defclass" "m_defcla.htm")
("defconstant" "m_defcon.htm")
("defgeneric" "m_defgen.htm")
("define-compiler-macro" "m_define.htm")
("define-condition" "m_defi_5.htm")
("define-method-combination" "m_defi_4.htm")
("define-modify-macro" "m_defi_2.htm")
("define-setf-expander" "m_defi_3.htm")
("define-symbol-macro" "m_defi_1.htm")
("defmacro" "m_defmac.htm")
("defmethod" "m_defmet.htm")
("defpackage" "m_defpkg.htm")
("defparameter" "m_defpar.htm")
("defsetf" "m_defset.htm")
("defstruct" "m_defstr.htm")
("deftype" "m_deftp.htm")
("defun" "m_defun.htm")
("defvar" "m_defpar.htm")
("delete" "f_rm_rm.htm")
("delete-duplicates" "f_rm_dup.htm")
("delete-file" "f_del_fi.htm")
("delete-if" "f_rm_rm.htm")
("delete-if-not" "f_rm_rm.htm")
("delete-package" "f_del_pk.htm")
("denominator" "f_numera.htm")
("deposit-field" "f_deposi.htm")
("describe" "f_descri.htm")
("describe-object" "f_desc_1.htm")
("destructuring-bind" "m_destru.htm")
("digit-char" "f_digit_.htm")
("digit-char-p" "f_digi_1.htm")
("directory" "f_dir.htm")
("directory-namestring" "f_namest.htm")
("disassemble" "f_disass.htm")
("division-by-zero" "e_divisi.htm")
("do" "m_do_do.htm")
("do*" "m_do_do.htm")
("do-all-symbols" "m_do_sym.htm")
("do-external-symbols" "m_do_sym.htm")
("do-symbols" "m_do_sym.htm")
("documentation" "f_docume.htm")
("dolist" "m_dolist.htm")
("dotimes" "m_dotime.htm")
("double-float" "t_short_.htm")
("double-float-epsilon" "v_short_.htm")
("double-float-negative-epsilon" "v_short_.htm")
("dpb" "f_dpb.htm")
("dribble" "f_dribbl.htm")
("dynamic-extent" "d_dynami.htm")
("ecase" "m_case_.htm")
("echo-stream" "t_echo_s.htm")
("echo-stream-input-stream" "f_echo_s.htm")
("echo-stream-output-stream" "f_echo_s.htm")
("ed" "f_ed.htm")
("eighth" "f_firstc.htm")
("elt" "f_elt.htm")
("encode-universal-time" "f_encode.htm")
("end-of-file" "e_end_of.htm")
("endp" "f_endp.htm")
("enough-namestring" "f_namest.htm")
("ensure-directories-exist" "f_ensu_1.htm")
("ensure-generic-function" "f_ensure.htm")
("eq" "f_eq.htm")
("eql" "a_eql.htm")
("equal" "f_equal.htm")
("equalp" "f_equalp.htm")
("error" "a_error.htm")
("etypecase" "m_tpcase.htm")
("eval" "f_eval.htm")
("eval-when" "s_eval_w.htm")
("evenp" "f_evenpc.htm")
("every" "f_everyc.htm")
("exp" "f_exp_e.htm")
("export" "f_export.htm")
("expt" "f_exp_e.htm")
("extended-char" "t_extend.htm")
("fboundp" "f_fbound.htm")
("fceiling" "f_floorc.htm")
("fdefinition" "f_fdefin.htm")
("ffloor" "f_floorc.htm")
("fifth" "f_firstc.htm")
("file-author" "f_file_a.htm")
("file-error" "e_file_e.htm")
("file-error-pathname" "f_file_e.htm")
("file-length" "f_file_l.htm")
("file-namestring" "f_namest.htm")
("file-position" "f_file_p.htm")
("file-stream" "t_file_s.htm")
("file-string-length" "f_file_s.htm")
("file-write-date" "f_file_w.htm")
("fill" "f_fill.htm")
("fill-pointer" "f_fill_p.htm")
("find" "f_find_.htm")
("find-all-symbols" "f_find_a.htm")
("find-class" "f_find_c.htm")
("find-if" "f_find_.htm")
("find-if-not" "f_find_.htm")
("find-method" "f_find_m.htm")
("find-package" "f_find_p.htm")
("find-restart" "f_find_r.htm")
("find-symbol" "f_find_s.htm")
("finish-output" "f_finish.htm")
("first" "f_firstc.htm")
("fixnum" "t_fixnum.htm")
("flet" "s_flet_.htm")
("float" "a_float.htm")
("float-digits" "f_dec_fl.htm")
("float-precision" "f_dec_fl.htm")
("float-radix" "f_dec_fl.htm")
("float-sign" "f_dec_fl.htm")
("floating-point-inexact" "e_floa_1.htm")
("floating-point-invalid-operation" "e_floati.htm")
("floating-point-overflow" "e_floa_2.htm")
("floating-point-underflow" "e_floa_3.htm")
("floatp" "f_floatp.htm")
("floor" "f_floorc.htm")
("fmakunbound" "f_fmakun.htm")
("force-output" "f_finish.htm")
("format" "f_format.htm")
("formatter" "m_format.htm")
("fourth" "f_firstc.htm")
("fresh-line" "f_terpri.htm")
("fround" "f_floorc.htm")
("ftruncate" "f_floorc.htm")
("ftype" "d_ftype.htm")
("funcall" "f_funcal.htm")
("function" "a_fn.htm")
("function-keywords" "f_fn_kwd.htm")
("function-lambda-expression" "f_fn_lam.htm")
("functionp" "f_fnp.htm")
("gcd" "f_gcd.htm")
("generic-function" "t_generi.htm")
("gensym" "f_gensym.htm")
("gentemp" "f_gentem.htm")
("get" "f_get.htm")
("get-decoded-time" "f_get_un.htm")
("get-dispatch-macro-character" "f_set__1.htm")
("get-internal-real-time" "f_get_in.htm")
("get-internal-run-time" "f_get__1.htm")
("get-macro-character" "f_set_ma.htm")
("get-output-stream-string" "f_get_ou.htm")
("get-properties" "f_get_pr.htm")
("get-setf-expansion" "f_get_se.htm")
("get-universal-time" "f_get_un.htm")
("getf" "f_getf.htm")
("gethash" "f_gethas.htm")
("go" "s_go.htm")
("graphic-char-p" "f_graphi.htm")
("handler-bind" "m_handle.htm")
("handler-case" "m_hand_1.htm")
("hash-table" "t_hash_t.htm")
("hash-table-count" "f_hash_1.htm")
("hash-table-p" "f_hash_t.htm")
("hash-table-rehash-size" "f_hash_2.htm")
("hash-table-rehash-threshold" "f_hash_3.htm")
("hash-table-size" "f_hash_4.htm")
("hash-table-test" "f_hash_5.htm")
("host-namestring" "f_namest.htm")
("identity" "f_identi.htm")
("if" "s_if.htm")
("ignorable" "d_ignore.htm")
("ignore" "d_ignore.htm")
("ignore-errors" "m_ignore.htm")
("imagpart" "f_realpa.htm")
("import" "f_import.htm")
("in-package" "m_in_pkg.htm")
("incf" "m_incf_.htm")
("initialize-instance" "f_init_i.htm")
("inline" "d_inline.htm")
("input-stream-p" "f_in_stm.htm")
("inspect" "f_inspec.htm")
("integer" "t_intege.htm")
("integer-decode-float" "f_dec_fl.htm")
("integer-length" "f_intege.htm")
("integerp" "f_inte_1.htm")
("interactive-stream-p" "f_intera.htm")
("intern" "f_intern.htm")
("internal-time-units-per-second" "v_intern.htm")
("intersection" "f_isec_.htm")
("invalid-method-error" "f_invali.htm")
("invoke-debugger" "f_invoke.htm")
("invoke-restart" "f_invo_1.htm")
("invoke-restart-interactively" "f_invo_2.htm")
("isqrt" "f_sqrt_.htm")
("keyword" "t_kwd.htm")
("keywordp" "f_kwdp.htm")
("labels" "s_flet_.htm")
("lambda" "a_lambda.htm")
("lambda-list-keywords" "v_lambda.htm")
("lambda-parameters-limit" "v_lamb_1.htm")
("last" "f_last.htm")
("lcm" "f_lcm.htm")
("ldb" "f_ldb.htm")
("ldb-test" "f_ldb_te.htm")
("ldiff" "f_ldiffc.htm")
("least-negative-double-float" "v_most_1.htm")
("least-negative-long-float" "v_most_1.htm")
("least-negative-normalized-double-float" "v_most_1.htm")
("least-negative-normalized-long-float" "v_most_1.htm")
("least-negative-normalized-short-float" "v_most_1.htm")
("least-negative-normalized-single-float" "v_most_1.htm")
("least-negative-short-float" "v_most_1.htm")
("least-negative-single-float" "v_most_1.htm")
("least-positive-double-float" "v_most_1.htm")
("least-positive-long-float" "v_most_1.htm")
("least-positive-normalized-double-float" "v_most_1.htm")
("least-positive-normalized-long-float" "v_most_1.htm")
("least-positive-normalized-short-float" "v_most_1.htm")
("least-positive-normalized-single-float" "v_most_1.htm")
("least-positive-short-float" "v_most_1.htm")
("least-positive-single-float" "v_most_1.htm")
("length" "f_length.htm")
("let" "s_let_l.htm")
("let*" "s_let_l.htm")
("lisp-implementation-type" "f_lisp_i.htm")
("lisp-implementation-version" "f_lisp_i.htm")
("list" "a_list.htm")
("list*" "f_list_.htm")
("list-all-packages" "f_list_a.htm")
("list-length" "f_list_l.htm")
("listen" "f_listen.htm")
("listp" "f_listp.htm")
("load" "f_load.htm")
("load-logical-pathname-translations" "f_ld_log.htm")
("load-time-value" "s_ld_tim.htm")
("locally" "s_locall.htm")
("log" "f_log.htm")
("logand" "f_logand.htm")
("logandc1" "f_logand.htm")
("logandc2" "f_logand.htm")
("logbitp" "f_logbtp.htm")
("logcount" "f_logcou.htm")
("logeqv" "f_logand.htm")
("logical-pathname" "a_logica.htm")
("logical-pathname-translations" "f_logica.htm")
("logior" "f_logand.htm")
("lognand" "f_logand.htm")
("lognor" "f_logand.htm")
("lognot" "f_logand.htm")
("logorc1" "f_logand.htm")
("logorc2" "f_logand.htm")
("logtest" "f_logtes.htm")
("logxor" "f_logand.htm")
("long-float" "t_short_.htm")
("long-float-epsilon" "v_short_.htm")
("long-float-negative-epsilon" "v_short_.htm")
("long-site-name" "f_short_.htm")
("loop" "m_loop.htm")
("loop-finish" "m_loop_f.htm")
("lower-case-p" "f_upper_.htm")
("machine-instance" "f_mach_i.htm")
("machine-type" "f_mach_t.htm")
("machine-version" "f_mach_v.htm")
("macro-function" "f_macro_.htm")
("macroexpand" "f_mexp_.htm")
("macroexpand-1" "f_mexp_.htm")
("macrolet" "s_flet_.htm")
("make-array" "f_mk_ar.htm")
("make-broadcast-stream" "f_mk_bro.htm")
("make-concatenated-stream" "f_mk_con.htm")
("make-condition" "f_mk_cnd.htm")
("make-dispatch-macro-character" "f_mk_dis.htm")
("make-echo-stream" "f_mk_ech.htm")
("make-hash-table" "f_mk_has.htm")
("make-instance" "f_mk_ins.htm")
("make-instances-obsolete" "f_mk_i_1.htm")
("make-list" "f_mk_lis.htm")
("make-load-form" "f_mk_ld_.htm")
("make-load-form-saving-slots" "f_mk_l_1.htm")
("make-method" "m_call_m.htm")
("make-package" "f_mk_pkg.htm")
("make-pathname" "f_mk_pn.htm")
("make-random-state" "f_mk_rnd.htm")
("make-sequence" "f_mk_seq.htm")
("make-string" "f_mk_stg.htm")
("make-string-input-stream" "f_mk_s_1.htm")
("make-string-output-stream" "f_mk_s_2.htm")
("make-symbol" "f_mk_sym.htm")
("make-synonym-stream" "f_mk_syn.htm")
("make-two-way-stream" "f_mk_two.htm")
("makunbound" "f_makunb.htm")
("map" "f_map.htm")
("map-into" "f_map_in.htm")
("mapc" "f_mapc_.htm")
("mapcan" "f_mapc_.htm")
("mapcar" "f_mapc_.htm")
("mapcon" "f_mapc_.htm")
("maphash" "f_maphas.htm")
("mapl" "f_mapc_.htm")
("maplist" "f_mapc_.htm")
("mask-field" "f_mask_f.htm")
("max" "f_max_m.htm")
("member" "a_member.htm")
("member-if" "f_mem_m.htm")
("member-if-not" "f_mem_m.htm")
("merge" "f_merge.htm")
("merge-pathnames" "f_merge_.htm")
("method" "t_method.htm")
("method-combination" "a_method.htm")
("method-combination-error" "f_meth_1.htm")
("method-qualifiers" "f_method.htm")
("min" "f_max_m.htm")
("minusp" "f_minusp.htm")
("mismatch" "f_mismat.htm")
("mod" "a_mod.htm")
("most-negative-double-float" "v_most_1.htm")
("most-negative-fixnum" "v_most_p.htm")
("most-negative-long-float" "v_most_1.htm")
("most-negative-short-float" "v_most_1.htm")
("most-negative-single-float" "v_most_1.htm")
("most-positive-double-float" "v_most_1.htm")
("most-positive-fixnum" "v_most_p.htm")
("most-positive-long-float" "v_most_1.htm")
("most-positive-short-float" "v_most_1.htm")
("most-positive-single-float" "v_most_1.htm")
("muffle-warning" "a_muffle.htm")
("multiple-value-bind" "m_multip.htm")
("multiple-value-call" "s_multip.htm")
("multiple-value-list" "m_mult_1.htm")
("multiple-value-prog1" "s_mult_1.htm")
("multiple-value-setq" "m_mult_2.htm")
("multiple-values-limit" "v_multip.htm")
("name-char" "f_name_c.htm")
("namestring" "f_namest.htm")
("nbutlast" "f_butlas.htm")
("nconc" "f_nconc.htm")
("next-method-p" "f_next_m.htm")
("nil" "a_nil.htm")
("nintersection" "f_isec_.htm")
("ninth" "f_firstc.htm")
("no-applicable-method" "f_no_app.htm")
("no-next-method" "f_no_nex.htm")
("not" "a_not.htm")
("notany" "f_everyc.htm")
("notevery" "f_everyc.htm")
("notinline" "d_inline.htm")
("nreconc" "f_revapp.htm")
("nreverse" "f_revers.htm")
("nset-difference" "f_set_di.htm")
("nset-exclusive-or" "f_set_ex.htm")
("nstring-capitalize" "f_stg_up.htm")
("nstring-downcase" "f_stg_up.htm")
("nstring-upcase" "f_stg_up.htm")
("nsublis" "f_sublis.htm")
("nsubst" "f_substc.htm")
("nsubst-if" "f_substc.htm")
("nsubst-if-not" "f_substc.htm")
("nsubstitute" "f_sbs_s.htm")
("nsubstitute-if" "f_sbs_s.htm")
("nsubstitute-if-not" "f_sbs_s.htm")
("nth" "f_nth.htm")
("nth-value" "m_nth_va.htm")
("nthcdr" "f_nthcdr.htm")
("null" "a_null.htm")
("number" "t_number.htm")
("numberp" "f_nump.htm")
("numerator" "f_numera.htm")
("nunion" "f_unionc.htm")
("oddp" "f_evenpc.htm")
("open" "f_open.htm")
("open-stream-p" "f_open_s.htm")
("optimize" "d_optimi.htm")
("or" "a_or.htm")
("otherwise" "m_case_.htm")
("output-stream-p" "f_in_stm.htm")
("package" "t_pkg.htm")
("package-error" "e_pkg_er.htm")
("package-error-package" "f_pkg_er.htm")
("package-name" "f_pkg_na.htm")
("package-nicknames" "f_pkg_ni.htm")
("package-shadowing-symbols" "f_pkg_sh.htm")
("package-use-list" "f_pkg_us.htm")
("package-used-by-list" "f_pkg__1.htm")
("packagep" "f_pkgp.htm")
("pairlis" "f_pairli.htm")
("parse-error" "e_parse_.htm")
("parse-integer" "f_parse_.htm")
("parse-namestring" "f_pars_1.htm")
("pathname" "a_pn.htm")
("pathname-device" "f_pn_hos.htm")
("pathname-directory" "f_pn_hos.htm")
("pathname-host" "f_pn_hos.htm")
("pathname-match-p" "f_pn_mat.htm")
("pathname-name" "f_pn_hos.htm")
("pathname-type" "f_pn_hos.htm")
("pathname-version" "f_pn_hos.htm")
("pathnamep" "f_pnp.htm")
("peek-char" "f_peek_c.htm")
("phase" "f_phase.htm")
("pi" "v_pi.htm")
("plusp" "f_minusp.htm")
("pop" "m_pop.htm")
("position" "f_pos_p.htm")
("position-if" "f_pos_p.htm")
("position-if-not" "f_pos_p.htm")
("pprint" "f_wr_pr.htm")
("pprint-dispatch" "f_ppr_di.htm")
("pprint-exit-if-list-exhausted" "m_ppr_ex.htm")
("pprint-fill" "f_ppr_fi.htm")
("pprint-indent" "f_ppr_in.htm")
("pprint-linear" "f_ppr_fi.htm")
("pprint-logical-block" "m_ppr_lo.htm")
("pprint-newline" "f_ppr_nl.htm")
("pprint-pop" "m_ppr_po.htm")
("pprint-tab" "f_ppr_ta.htm")
("pprint-tabular" "f_ppr_fi.htm")
("prin1" "f_wr_pr.htm")
("prin1-to-string" "f_wr_to_.htm")
("princ" "f_wr_pr.htm")
("princ-to-string" "f_wr_to_.htm")
("print" "f_wr_pr.htm")
("print-not-readable" "e_pr_not.htm")
("print-not-readable-object" "f_pr_not.htm")
("print-object" "f_pr_obj.htm")
("print-unreadable-object" "m_pr_unr.htm")
("probe-file" "f_probe_.htm")
("proclaim" "f_procla.htm")
("prog" "m_prog_.htm")
("prog*" "m_prog_.htm")
("prog1" "m_prog1c.htm")
("prog2" "m_prog1c.htm")
("progn" "s_progn.htm")
("program-error" "e_progra.htm")
("progv" "s_progv.htm")
("provide" "f_provid.htm")
("psetf" "m_setf_.htm")
("psetq" "m_psetq.htm")
("push" "m_push.htm")
("pushnew" "m_pshnew.htm")
("quote" "s_quote.htm")
("random" "f_random.htm")
("random-state" "t_rnd_st.htm")
("random-state-p" "f_rnd_st.htm")
("rassoc" "f_rassoc.htm")
("rassoc-if" "f_rassoc.htm")
("rassoc-if-not" "f_rassoc.htm")
("ratio" "t_ratio.htm")
("rational" "a_ration.htm")
("rationalize" "f_ration.htm")
("rationalp" "f_rati_1.htm")
("read" "f_rd_rd.htm")
("read-byte" "f_rd_by.htm")
("read-char" "f_rd_cha.htm")
("read-char-no-hang" "f_rd_c_1.htm")
("read-delimited-list" "f_rd_del.htm")
("read-from-string" "f_rd_fro.htm")
("read-line" "f_rd_lin.htm")
("read-preserving-whitespace" "f_rd_rd.htm")
("read-sequence" "f_rd_seq.htm")
("reader-error" "e_rder_e.htm")
("readtable" "t_rdtabl.htm")
("readtable-case" "f_rdtabl.htm")
("readtablep" "f_rdta_1.htm")
("real" "t_real.htm")
("realp" "f_realp.htm")
("realpart" "f_realpa.htm")
("reduce" "f_reduce.htm")
("reinitialize-instance" "f_reinit.htm")
("rem" "f_mod_r.htm")
("remf" "m_remf.htm")
("remhash" "f_remhas.htm")
("remove" "f_rm_rm.htm")
("remove-duplicates" "f_rm_dup.htm")
("remove-if" "f_rm_rm.htm")
("remove-if-not" "f_rm_rm.htm")
("remove-method" "f_rm_met.htm")
("remprop" "f_rempro.htm")
("rename-file" "f_rn_fil.htm")
("rename-package" "f_rn_pkg.htm")
("replace" "f_replac.htm")
("require" "f_provid.htm")
("rest" "f_rest.htm")
("restart" "t_rst.htm")
("restart-bind" "m_rst_bi.htm")
("restart-case" "m_rst_ca.htm")
("restart-name" "f_rst_na.htm")
("return" "m_return.htm")
("return-from" "s_ret_fr.htm")
("revappend" "f_revapp.htm")
("reverse" "f_revers.htm")
("room" "f_room.htm")
("rotatef" "m_rotate.htm")
("round" "f_floorc.htm")
("row-major-aref" "f_row_ma.htm")
("rplaca" "f_rplaca.htm")
("rplacd" "f_rplaca.htm")
("safety" "d_optimi.htm")
("satisfies" "t_satisf.htm")
("sbit" "f_bt_sb.htm")
("scale-float" "f_dec_fl.htm")
("schar" "f_char_.htm")
("search" "f_search.htm")
("second" "f_firstc.htm")
("sequence" "t_seq.htm")
("serious-condition" "e_seriou.htm")
("set" "f_set.htm")
("set-difference" "f_set_di.htm")
("set-dispatch-macro-character" "f_set__1.htm")
("set-exclusive-or" "f_set_ex.htm")
("set-macro-character" "f_set_ma.htm")
("set-pprint-dispatch" "f_set_pp.htm")
("set-syntax-from-char" "f_set_sy.htm")
("setf" "a_setf.htm")
("setq" "s_setq.htm")
("seventh" "f_firstc.htm")
("shadow" "f_shadow.htm")
("shadowing-import" "f_shdw_i.htm")
("shared-initialize" "f_shared.htm")
("shiftf" "m_shiftf.htm")
("short-float" "t_short_.htm")
("short-float-epsilon" "v_short_.htm")
("short-float-negative-epsilon" "v_short_.htm")
("short-site-name" "f_short_.htm")
("signal" "f_signal.htm")
("signed-byte" "t_sgn_by.htm")
("signum" "f_signum.htm")
("simple-array" "t_smp_ar.htm")
("simple-base-string" "t_smp_ba.htm")
("simple-bit-vector" "t_smp_bt.htm")
("simple-bit-vector-p" "f_smp_bt.htm")
("simple-condition" "e_smp_cn.htm")
("simple-condition-format-arguments" "f_smp_cn.htm")
("simple-condition-format-control" "f_smp_cn.htm")
("simple-error" "e_smp_er.htm")
("simple-string" "t_smp_st.htm")
("simple-string-p" "f_smp_st.htm")
("simple-type-error" "e_smp_tp.htm")
("simple-vector" "t_smp_ve.htm")
("simple-vector-p" "f_smp_ve.htm")
("simple-warning" "e_smp_wa.htm")
("sin" "f_sin_c.htm")
("single-float" "t_short_.htm")
("single-float-epsilon" "v_short_.htm")
("single-float-negative-epsilon" "v_short_.htm")
("sinh" "f_sinh_.htm")
("sixth" "f_firstc.htm")
("sleep" "f_sleep.htm")
("slot-boundp" "f_slt_bo.htm")
("slot-exists-p" "f_slt_ex.htm")
("slot-makunbound" "f_slt_ma.htm")
("slot-missing" "f_slt_mi.htm")
("slot-unbound" "f_slt_un.htm")
("slot-value" "f_slt_va.htm")
("software-type" "f_sw_tpc.htm")
("software-version" "f_sw_tpc.htm")
("some" "f_everyc.htm")
("sort" "f_sort_.htm")
("space" "d_optimi.htm")
("special" "d_specia.htm")
("special-operator-p" "f_specia.htm")
("speed" "d_optimi.htm")
("sqrt" "f_sqrt_.htm")
("stable-sort" "f_sort_.htm")
("standard" "07_ffb.htm")
("standard-char" "t_std_ch.htm")
("standard-char-p" "f_std_ch.htm")
("standard-class" "t_std_cl.htm")
("standard-generic-function" "t_std_ge.htm")
("standard-method" "t_std_me.htm")
("standard-object" "t_std_ob.htm")
("step" "m_step.htm")
("storage-condition" "e_storag.htm")
("store-value" "a_store_.htm")
("stream" "t_stream.htm")
("stream-element-type" "f_stm_el.htm")
("stream-error" "e_stm_er.htm")
("stream-error-stream" "f_stm_er.htm")
("stream-external-format" "f_stm_ex.htm")
("streamp" "f_stmp.htm")
("string" "a_string.htm")
("string-capitalize" "f_stg_up.htm")
("string-downcase" "f_stg_up.htm")
("string-equal" "f_stgeq_.htm")
("string-greaterp" "f_stgeq_.htm")
("string-left-trim" "f_stg_tr.htm")
("string-lessp" "f_stgeq_.htm")
("string-not-equal" "f_stgeq_.htm")
("string-not-greaterp" "f_stgeq_.htm")
("string-not-lessp" "f_stgeq_.htm")
("string-right-trim" "f_stg_tr.htm")
("string-stream" "t_stg_st.htm")
("string-trim" "f_stg_tr.htm")
("string-upcase" "f_stg_up.htm")
("string/=" "f_stgeq_.htm")
("string<" "f_stgeq_.htm")
("string<=" "f_stgeq_.htm")
("string=" "f_stgeq_.htm")
("string>" "f_stgeq_.htm")
("string>=" "f_stgeq_.htm")
("stringp" "f_stgp.htm")
("structure" "f_docume.htm")
("structure-class" "t_stu_cl.htm")
("structure-object" "t_stu_ob.htm")
("style-warning" "e_style_.htm")
("sublis" "f_sublis.htm")
("subseq" "f_subseq.htm")
("subsetp" "f_subset.htm")
("subst" "f_substc.htm")
("subst-if" "f_substc.htm")
("subst-if-not" "f_substc.htm")
("substitute" "f_sbs_s.htm")
("substitute-if" "f_sbs_s.htm")
("substitute-if-not" "f_sbs_s.htm")
("subtypep" "f_subtpp.htm")
("svref" "f_svref.htm")
("sxhash" "f_sxhash.htm")
("symbol" "t_symbol.htm")
("symbol-function" "f_symb_1.htm")
("symbol-macrolet" "s_symbol.htm")
("symbol-name" "f_symb_2.htm")
("symbol-package" "f_symb_3.htm")
("symbol-plist" "f_symb_4.htm")
("symbol-value" "f_symb_5.htm")
("symbolp" "f_symbol.htm")
("synonym-stream" "t_syn_st.htm")
("synonym-stream-symbol" "f_syn_st.htm")
("t" "a_t.htm")
("tagbody" "s_tagbod.htm")
("tailp" "f_ldiffc.htm")
("tan" "f_sin_c.htm")
("tanh" "f_sinh_.htm")
("tenth" "f_firstc.htm")
("terpri" "f_terpri.htm")
("the" "s_the.htm")
("third" "f_firstc.htm")
("throw" "s_throw.htm")
("time" "m_time.htm")
("trace" "m_tracec.htm")
("translate-logical-pathname" "f_tr_log.htm")
("translate-pathname" "f_tr_pn.htm")
("tree-equal" "f_tree_e.htm")
("truename" "f_tn.htm")
("truncate" "f_floorc.htm")
("two-way-stream" "t_two_wa.htm")
("two-way-stream-input-stream" "f_two_wa.htm")
("two-way-stream-output-stream" "f_two_wa.htm")
("type" "a_type.htm")
("type-error" "e_tp_err.htm")
("type-error-datum" "f_tp_err.htm")
("type-error-expected-type" "f_tp_err.htm")
("type-of" "f_tp_of.htm")
("typecase" "m_tpcase.htm")
("typep" "f_typep.htm")
("unbound-slot" "e_unboun.htm")
("unbound-slot-instance" "f_unboun.htm")
("unbound-variable" "e_unbo_1.htm")
("undefined-function" "e_undefi.htm")
("unexport" "f_unexpo.htm")
("unintern" "f_uninte.htm")
("union" "f_unionc.htm")
("unless" "m_when_.htm")
("unread-char" "f_unrd_c.htm")
("unsigned-byte" "t_unsgn_.htm")
("untrace" "m_tracec.htm")
("unuse-package" "f_unuse_.htm")
("unwind-protect" "s_unwind.htm")
("update-instance-for-different-class" "f_update.htm")
("update-instance-for-redefined-class" "f_upda_1.htm")
("upgraded-array-element-type" "f_upgr_1.htm")
("upgraded-complex-part-type" "f_upgrad.htm")
("upper-case-p" "f_upper_.htm")
("use-package" "f_use_pk.htm")
("use-value" "a_use_va.htm")
("user-homedir-pathname" "f_user_h.htm")
("values" "a_values.htm")
("values-list" "f_vals_l.htm")
("variable" "f_docume.htm")
("vector" "a_vector.htm")
("vector-pop" "f_vec_po.htm")
("vector-push" "f_vec_ps.htm")
("vector-push-extend" "f_vec_ps.htm")
("vectorp" "f_vecp.htm")
("warn" "f_warn.htm")
("warning" "e_warnin.htm")
("when" "m_when_.htm")
("wild-pathname-p" "f_wild_p.htm")
("with-accessors" "m_w_acce.htm")
("with-compilation-unit" "m_w_comp.htm")
("with-condition-restarts" "m_w_cnd_.htm")
("with-hash-table-iterator" "m_w_hash.htm")
("with-input-from-string" "m_w_in_f.htm")
("with-open-file" "m_w_open.htm")
("with-open-stream" "m_w_op_1.htm")
("with-output-to-string" "m_w_out_.htm")
("with-package-iterator" "m_w_pkg_.htm")
("with-simple-restart" "m_w_smp_.htm")
("with-slots" "m_w_slts.htm")
("with-standard-io-syntax" "m_w_std_.htm")
("write" "f_wr_pr.htm")
("write-byte" "f_wr_by.htm")
("write-char" "f_wr_cha.htm")
("write-line" "f_wr_stg.htm")
("write-sequence" "f_wr_seq.htm")
("write-string" "f_wr_stg.htm")
("write-to-string" "f_wr_to_.htm")
("y-or-n-p" "f_y_or_n.htm")
("yes-or-no-p" "f_y_or_n.htm")
("zerop" "f_zerop.htm")))
| 32,835 | Common Lisp | .lisp | 1,004 | 30.656375 | 143 | 0.628406 | fisxoj/hyperspec | 3 | 4 | 3 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | dbf06ef284bb0cf9d15a8d0944f8544702eb7eb48c49922fdc1e255846265080 | 16,757 | [
-1
] |
16,758 | hyperspec.asd | fisxoj_hyperspec/hyperspec.asd | (defsystem "hyperspec"
:author "Matt Novenstern"
:version "0.1.1"
:license "LLGPLv3+"
:depends-on ("alexandria")
:pathname "src/"
:description "A simple library for looking up common-lisp symbols in the hyperspec."
:long-description #.(uiop:read-file-string (make-pathname :defaults *load-truename* :version nil :name "README" :type "rst"))
:components ((:file "hyperspec")))
| 392 | Common Lisp | .asd | 9 | 40.777778 | 127 | 0.718016 | fisxoj/hyperspec | 3 | 4 | 3 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | c2e6adefadf29c95367b5becfe20610e626eb09f233a55c1773ba80a7a94c0ab | 16,758 | [
-1
] |
16,761 | default.css | fisxoj_hyperspec/docs/default.css | /*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 5196 2007-06-03 20:25:28Z wiemann $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
dl.docutils dt {
font-weight: bold }
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left {
clear: left }
img.align-right {
clear: right }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font-family: serif ;
font-size: 100% }
pre.literal-block, pre.doctest-block {
margin-left: 2em ;
margin-right: 2em }
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
table caption { caption-side: bottom; font-weight: bold; font-style: italic; }
p.caption { text-align:center; font-weight: bold; }
table.docutils, table.docutils tr th, table.docutils tr td { outline-width: thin; outline-style: solid; }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
/* Begin coo customization */
@import url("//fonts.googleapis.com/css?family=Fira+Mono|Fira+Sans");
:root {
font-family: "Fira Sans", sans-serif;
font-size: 16px;
}
.document {
max-width: 1200px;
margin: 0 auto;
}
span.pre {
font-family: "Fira Mono", monospace;
}
h2 {
background: #eee;
border-width: 1px 0;
border-color: black;
border-style: solid;
}
.ref-package {
font-family: "Fira Mono", mono;
background-color: #eee;
color: #ab7967;
padding: 3px;
border-radius: 6px;
}
.ref-class {
font-family: "Fira Mono", mono;
background-color: #eee;
color: #99c794;
padding: 3px;
border-radius: 6px;
}
.ref-variable {
font-family: "Fira Mono", mono;
background-color: #eee;
color: #6699cc;
padding: 3px;
border-radius: 6px;
}
.ref-macro {
font-family: "Fira Mono", mono;
background-color: #eee;
color: #fac863;
padding: 3px;
border-radius: 6px;
}
.ref-function {
font-family: "Fira Mono", mono;
background-color: #eee;
color: #c594c5;
padding: 3px;
border-radius: 6px;
}
.param {
background-color: #eee;
color: #6699cc;
}
p {
color: #343d46;
}
/* End coo customization */
| 7,079 | Common Lisp | .l | 268 | 22.682836 | 105 | 0.681933 | fisxoj/hyperspec | 3 | 4 | 3 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | e7fa826d264088a0feb06b1a2c9e6c04ca282e74b0a6f8362a19e94395daf2f4 | 16,761 | [
-1
] |
16,762 | hyperspec.html | fisxoj_hyperspec/docs/hyperspec.html | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="default.css" type="text/css" />
<title>hyperspec package</title>
</head>
<body>
<div id="hyperspec-package" class="document"><h1 class="title">hyperspec package</h1>
<p>Package for looking up hyperspec urls by symbol. The only exposed function is <a class="reference ref-function" href="hyperspec.html#function__lookup"><span class="ref-function">lookup</span></a>.</p>
<div id="functions" class="section"><h2><a name="functions">Functions</a></h2>
<a id="function-lookup" class="target" name="function-lookup"></a><p><tt class="docutils literal">
<span class="pre">lookup</span> <span class="pre">(symbol)</span></tt></p>
<blockquote> Look up a symbol in the COMMON-LISP package and return a url to the appropriate hyperspec page. Returns <tt class="docutils literal">
<span class="pre">nil</span></tt> if the symbol isn't found.</blockquote> </div>
<hr class ="docutils footer" /><div class="footer">Generated on : Sun, 18 Nov 2018 15:40:36 .
Generated by cl-docutils 0.1.1 from <a class="reference" href="http://docutils.sourceforge.net/rst.html"><span>restructured text</span></a> source.
</div>
</div>
</body>
</html> | 1,327 | Common Lisp | .l | 21 | 62.190476 | 204 | 0.723795 | fisxoj/hyperspec | 3 | 4 | 3 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | be03065e7f126fcbaee940067d3f0d7fe6d8fdde303ae024d6949d61db72cbae | 16,762 | [
-1
] |
16,763 | index.html | fisxoj_hyperspec/docs/index.html | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="default.css" type="text/css" />
<title>hyperspec</title>
<meta name="Author" content="Matt Novenstern" />
</head>
<body>
<div id="id3" class="document"><h1 class="title">hyperspec</h1>
<table class="docinfo" frame="void" rules="none"><col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author</th><td>Matt Novenstern</td></tr><tr><th class="docinfo-name">Version</th><td>0.1.0</td></tr><tr class="field"><th colspan="1" class="docinfo-name">license:</th><td class="field-body">LLGPLv3+</td>
</tr>
</tbody>
</table>
<p>A simple library for looking up common-lisp symbols in the <a class="reference" href="hyperspec.html"><span>hyperspec</span></a>.</p>
<p>The only exported symbol is <a class="reference ref-function" href="hyperspec.html#function__lookup"><span class="ref-function">hyperspec:lookup</span></a>. It takes a symbol or string and returns a url or nil if none is found.</p>
<p>The library is based on the implementations of this functionality in sly <a name="id4" class="footnote-reference" id="id4" href="#sly-hyperspec">[<span id="id4">1</span>]</a> and slime <a name="id5" class="footnote-reference" id="id5" href="#slime-hyperspec">[<span id="id5">2</span>]</a> .</p>
<p class="rubric">Footnotes</p>
<div id="sly-hyperspec" class="docutils footnote" frame="void" rules="none"><colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" name="sly-hyperspec" href="#id4">[1]</a></td><td>sly's <a class="reference" href="https://github.com/joaotavora/sly/blob/master/lib/hyperspec.el"><span>hyperspec.el</span></a></td></tr>
</tbody>
</table>
<div id="slime-hyperspec" class="docutils footnote" frame="void" rules="none"><colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" name="slime-hyperspec" href="#id5">[2]</a></td><td>slime's <a class="reference" href="https://github.com/slime/slime/blob/master/lib/hyperspec.el"><span>hyperspec.el</span></a></td></tr>
</tbody>
</table>
<div id="packages" class="section"><h2><a name="packages">Packages</a></h2>
<ul>
<li><p class="first last"><a class="reference" href="hyperspec.html"><span>hyperspec</span></a></p>
</li>
</ul>
</div>
<hr class ="docutils footer" /><div class="footer">Generated on : Sun, 18 Nov 2018 15:40:36 .
Generated by cl-docutils 0.1.1 from <a class="reference" href="http://docutils.sourceforge.net/rst.html"><span>restructured text</span></a> source.
</div>
</div>
</body>
</html> | 2,744 | Common Lisp | .l | 43 | 62.813953 | 297 | 0.699112 | fisxoj/hyperspec | 3 | 4 | 3 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 30e3f9fcad89a1856747b83a613d6e651f40a11e1d66cebf38fedcec17936df6 | 16,763 | [
-1
] |
16,778 | util.lisp | borodust_notalone-again/src/util.lisp | (cl:in-package :notalone-again)
(defparameter *viewport-width* 800)
(defparameter *viewport-height* 600)
(defparameter *background-color* (vec4 0.2 0.2 0.2 1.0))
(defparameter *foreground-color* (vec4 0.8 0.8 0.8 1.0))
(defparameter *zero-origin* (vec2 0 0))
(defparameter *ox-unit* (vec2 1 0))
(defgeneric render (object))
(defgeneric collide (this that)
(:method (this that) nil))
(defclass state-input-handler (input-handler) ())
(defmethod post-initialize :after ((this state-input-handler))
(activate-input-handler this))
(defmethod pre-destroy :before ((this state-input-handler))
(deactivate-input-handler this))
(defun warp-position (position)
(let ((result (copy-vec2 position)))
(when (> (x position) *viewport-width*)
(setf result (vec2 (mod (x position) *viewport-width*) (y position))))
(when (> (y position) *viewport-height*)
(setf result (vec2 (x position) (mod (y position) *viewport-height*))))
(when (< (x position) 0)
(setf result (vec2 (+ (x position) *viewport-width*) (y position))))
(when (< (y position) 0)
(setf result (vec2 (x position) (+ (y position) *viewport-height*))))
result))
| 1,176 | Common Lisp | .lisp | 26 | 41.730769 | 77 | 0.687775 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 5f2d165540e33519b34e7b33982f4ed5159204adea50420bb7b40391b84dac21 | 16,778 | [
-1
] |
16,779 | resources.lisp | borodust_notalone-again/src/resources.lisp | (cl:in-package :notalone-again)
(defun asset-path (pathname)
(asdf:system-relative-pathname :notalone-again (merge-pathnames pathname "assets/")))
(define-font :avara (asset-path "fonts/avara/Avara.ttf"))
(define-font :space-meatball (asset-path "fonts/space-meatball/space-meatball.ttf"))
(define-sound :unknown-energy (asset-path "music/dox-unknown-energy.flac"))
(define-sound :the-anomaly (asset-path "music/tristan-lohengrin-the-anomaly.flac"))
(define-sound :explosion (asset-path "sounds/sfx_exp_short_soft9.flac"))
(define-sound :weapon (asset-path "sounds/sfx_weapon_singleshot8.flac"))
(define-sound :portal (asset-path "sounds/sfx_movement_portal3.flac"))
| 675 | Common Lisp | .lisp | 10 | 65.7 | 87 | 0.772382 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 7fe6ade7c69a029fb3dcbf6b65720b2623398fae296d9e044830f9719b8cf5d4 | 16,779 | [
-1
] |
16,780 | main.lisp | borodust_notalone-again/src/main.lisp | (cl:in-package :notalone-again)
(defgame notalone-again (fistmachine)
()
(:viewport-width *viewport-width*)
(:viewport-height *viewport-height*)
(:viewport-title "NOTALONE: AGAIN")
(:depends-on physics-system)
(:prepare-resources nil)
(:default-initargs :initial-state 'loading-screen))
| 303 | Common Lisp | .lisp | 9 | 30.888889 | 53 | 0.739726 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | ead4c67f176d661ee91b2d2abb9e325de58d546911f3118f7a7c402bd6b61b60 | 16,780 | [
-1
] |
16,781 | packages.lisp | borodust_notalone-again/src/packages.lisp | (cl:defpackage :notalone-again
(:use :cl :trivial-gamekit :trivial-gamekit.fistmachine :trivial-gamekit.input-handler
:cl-bodge.engine
:cl-bodge.physics)
(:export #:play))
| 192 | Common Lisp | .lisp | 5 | 33.4 | 88 | 0.705882 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 7eb6ac281289331b2a7603aea52675600e0ce73a9d281f1f327d1bc02a071483 | 16,781 | [
-1
] |
16,782 | player.lisp | borodust_notalone-again/src/models/player.lisp | (cl:in-package :notalone-again)
(defparameter *player-bow* (vec2 30 0))
(defparameter *player-shape-vertices* (list (vec2 0 -10)
*player-bow*
(vec2 0 10)))
(defparameter *turn-speed* 2.5)
(defparameter *thrust-force* 300)
(defclass player ()
((body :initform nil)
(shape :initform nil)
(thrust-engaged-at :initform nil)
(left-turn-started-at :initform nil)
(right-turn-started-at :initform nil)))
(defmethod initialize-instance :after ((this player) &key universe)
(with-slots (body shape) this
(setf body (make-rigid-body universe)
shape (make-polygon-shape universe
*player-shape-vertices*
:body body
:substance this))))
(defun make-player (universe)
(make-instance 'player :universe universe))
(defun destroy-player (player)
(with-slots (body shape) player
(dispose shape)
(dispose body)))
(defun update-player-position (player x y)
(with-slots (body) player
(setf (body-position body) (vec2 x y))))
(defun player-position (player)
(with-slots (body) player
(body-position body)))
(defun player-bow-position (player)
(with-slots (body) player
(add (body-position body)
(mult (body-rotation body)
*player-bow*))))
(defun player-velocity (player)
(with-slots (body) player
(body-linear-velocity body)))
(defun player-rotation (player)
(with-slots (body) player
(body-rotation body)))
(defun update-player-rotation (player angle)
(with-slots (body) player
(setf (body-rotation body) (euler-angle->mat2 angle))))
(defun engage-thrust (player)
(setf (slot-value player 'thrust-engaged-at) (ge.util:real-time-seconds)))
(defun disengage-thrust (player)
(setf (slot-value player 'thrust-engaged-at) nil))
(defun update-thrust (player)
(with-slots (body thrust-engaged-at) player
(when thrust-engaged-at
(let* ((current-time (ge.util:real-time-seconds))
(time-delta (- current-time thrust-engaged-at)))
(apply-force body (mult (body-rotation body)
(vec2 1 0)
(* *thrust-force* time-delta)))
(setf thrust-engaged-at current-time)))))
(defun turn-left (player)
(setf (slot-value player 'left-turn-started-at) (ge.util:real-time-seconds)))
(defun turn-right (player)
(setf (slot-value player 'right-turn-started-at) (ge.util:real-time-seconds)))
(defun stop-left-turn (player)
(setf (slot-value player 'left-turn-started-at) nil))
(defun stop-right-turn (player)
(setf (slot-value player 'right-turn-started-at) nil))
(defun update-turn (player)
(with-slots (left-turn-started-at right-turn-started-at body) player
(let ((current-time (ge.util:real-time-seconds))
(current-angle (mat2->euler-angle (body-rotation body)))
(angle-delta 0))
(when left-turn-started-at
(incf angle-delta (* (- current-time left-turn-started-at)
*turn-speed*))
(setf left-turn-started-at current-time))
(when right-turn-started-at
(incf angle-delta (- (* (- current-time right-turn-started-at)
*turn-speed*)))
(setf right-turn-started-at current-time))
(update-player-rotation player (+ current-angle angle-delta)))))
(defun update-player (player)
(with-slots (body) player
(setf (body-position body) (warp-position (body-position body))))
(update-thrust player)
(update-turn player))
(defmethod render ((this player))
(with-slots (body) this
(let ((position (body-position body))
(rotation (body-rotation body)))
(flet ((render-object (x-offset y-offset)
(with-pushed-canvas ()
(translate-canvas (+ (x position) x-offset) (+ (y position) y-offset))
(rotate-canvas (mat2->euler-angle rotation))
(draw-polygon *player-shape-vertices*
:fill-paint (vec4 0.8 0.8 0.8 1)))))
(render-object 0 0)
(render-object *viewport-width* 0)
(render-object 0 *viewport-height*)
(render-object (- *viewport-width*) 0)
(render-object 0 (- *viewport-height*))))))
| 4,381 | Common Lisp | .lisp | 101 | 34.782178 | 87 | 0.622107 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | afa5375039c244cae0727eda12d754913dd5892cebd6f4598b05ff52eae4e772 | 16,782 | [
-1
] |
16,783 | projectile.lisp | borodust_notalone-again/src/models/projectile.lisp | (cl:in-package :notalone-again)
(defparameter *projectile-speed* 50)
(defparameter *projectile-radius* 1.5)
(defclass projectile ()
((body :initform nil)
(shape :initform nil)))
(defmethod initialize-instance :after ((this projectile)
&key universe initial-speed position rotation)
(with-slots (body shape) this
(setf body (make-rigid-body universe)
shape (make-circle-shape universe
*projectile-radius*
:body body
:substance this))
(setf (body-position body) position
(body-linear-velocity body) (mult rotation
*ox-unit*
(+ initial-speed *projectile-speed*)))))
(defun make-projectile (universe position rotation initial-speed)
(make-instance 'projectile :universe universe
:position position
:rotation rotation
:initial-speed initial-speed))
(defun destroy-projectile (projectile)
(with-slots (body shape) projectile
(dispose shape)
(dispose body)))
(defmethod render ((this projectile))
(with-slots (body) this
(let ((position (setf (body-position body) (warp-position (body-position body)))))
(flet ((render-object (x-offset y-offset)
(with-pushed-canvas ()
(translate-canvas (+ (x position) x-offset) (+ (y position) y-offset))
(draw-circle *zero-origin* *projectile-radius*
:fill-paint (vec4 0.8 0.8 0.8 1)))))
(render-object 0 0)
(render-object *viewport-width* 0)
(render-object 0 *viewport-height*)
(render-object (- *viewport-width*) 0)
(render-object 0 (- *viewport-height*))))))
| 1,900 | Common Lisp | .lisp | 40 | 33.775 | 87 | 0.559524 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 0c7ce5a94072f616fcbd57d7ff7e4fbc8361aba8cc13f7645aa3358d5ee1ec65 | 16,783 | [
-1
] |
16,784 | enemy.lisp | borodust_notalone-again/src/models/enemy.lisp | (cl:in-package :notalone-again)
(defparameter *enemy-radius* 12)
(defparameter *enemy-teeth* 30)
(defparameter *enemy-shape-vertices* (loop for i from 0 below *enemy-teeth*
for angle = (* (/ (* 2 pi) *enemy-teeth*) i)
collect (mult (vec2 (cos angle) (sin angle))
(if (oddp i)
(* *enemy-radius* 0.7)
*enemy-radius*))))
(defparameter *enemy-acceleration* 1)
(defparameter *enemy-max-speed* 10)
(defclass enemy ()
((body :initform nil)
(shape :initform nil)))
(defmethod initialize-instance :after ((this enemy) &key universe position)
(with-slots (body shape) this
(setf body (make-rigid-body universe)
(body-position body) position
shape (make-circle-shape universe
*enemy-radius*
:body body
:substance this))))
(defun make-enemy (universe x y)
(make-instance 'enemy :universe universe
:position (vec2 x y)))
(defun destroy-enemy (enemy)
(with-slots (body shape) enemy
(dispose shape)
(dispose body)))
(defun seek-player (enemy player)
(with-slots (body) enemy
(let* ((popo-vec (subt (player-position player) (body-position body)))
(distance (vector-length popo-vec))
(target-direction (div popo-vec distance)))
(apply-force body (mult target-direction *enemy-acceleration*))
(when (< distance 100)
(let* ((velocity (body-linear-velocity body))
(speed (vector-length velocity))
(direction (div velocity speed))
(target-speed (min speed (+ (* speed (/ distance 100)) 10)))
(target-force (- target-speed speed)))
(apply-force body (mult direction target-force)))))))
(defmethod render ((this enemy))
(with-slots (body) this
(let ((position (setf (body-position body) (handler-case
(warp-position (body-position body))
(t () (vec2 0 0))))))
(flet ((render-object (x-offset y-offset)
(with-pushed-canvas ()
(translate-canvas (+ (x position) x-offset) (+ (y position) y-offset))
(let ((ratio (- 1 (* (abs (cos (* (ge.util:real-time-seconds) 4))) 0.2))))
(scale-canvas ratio ratio))
(draw-polygon *enemy-shape-vertices*
:fill-paint (vec4 0.8 0.8 0.8 1)))))
(render-object 0 0)
(render-object *viewport-width* 0)
(render-object 0 *viewport-height*)
(render-object (- *viewport-width*) 0)
(render-object 0 (- *viewport-height*))))))
| 2,961 | Common Lisp | .lisp | 59 | 35 | 91 | 0.517313 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 28c57e89f69d4e0d0cc60ad9817528844e4fbad1443d06a7ccca002b9a035c8f | 16,784 | [
-1
] |
16,785 | loading-screen.lisp | borodust_notalone-again/src/states/loading-screen.lisp | (cl:in-package :notalone-again)
(defclass loading-screen () ())
(defmethod post-initialize ((this loading-screen))
(prepare-resources :avara
:space-meatball
:unknown-energy
:the-anomaly
:explosion
:weapon
:portal))
(defmethod notice-resources ((this loading-screen) &rest resource-names)
(declare (ignore resource-names))
(transition-to 'main-menu))
(defmethod draw ((this loading-screen))
(with-slots (player space-font avara-font) this
(draw-rect *zero-origin* *viewport-width* *viewport-height*
:fill-paint *background-color*)
(let* ((time (* (ge.util:real-time-seconds) 10))
(origin (vec2 (+ (* (cos time) 8) 25) (+ (* (sin time) 8) 25))))
(draw-circle origin 5 :fill-paint *foreground-color*)
(with-pushed-canvas ()
(scale-canvas 5 5)
(draw-text "LOADING" (vec2 10 10) :fill-color *foreground-color*)))))
| 1,014 | Common Lisp | .lisp | 23 | 34.217391 | 77 | 0.590031 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 8232d0994a6e08122bd44c4505cab6316e26b29e316a54685a78819ef0dbe9f3 | 16,785 | [
-1
] |
16,786 | main-menu.lisp | borodust_notalone-again/src/states/main-menu.lisp | (cl:in-package :notalone-again)
(defclass main-menu (state-input-handler)
((universe :initform nil)
(player :initform nil)
(space-font :initform nil)
(avara-font :initform nil)))
(defmethod post-initialize ((this main-menu))
(call-next-method)
(with-slots (player universe space-font avara-font) this
(setf universe (make-universe :2d)
player (make-player universe)
space-font (make-font :space-meatball 60)
avara-font (make-font :avara 24))
(play-sound :the-anomaly :looped-p t)))
(defmethod pre-destroy ((this main-menu))
(with-slots (universe player) this
(stop-sound :the-anomaly)
(destroy-player player)
(dispose universe))
(call-next-method))
(defmethod button-pressed ((this main-menu) (button (eql :enter)))
(transition-to 'level))
(defmethod button-pressed ((this main-menu) (button (eql :gamepad-start)))
(transition-to 'level))
(defmethod draw ((this main-menu))
(with-slots (player space-font avara-font) this
(draw-rect *zero-origin* *viewport-width* *viewport-height*
:fill-paint *background-color*)
(let ((time (bodge-util:real-time-seconds)))
(update-player-position player
(+ (* (cos time) 500) 400)
(+ (* (sin time) 100) 300))
(update-player-rotation player (* time 2)))
(render player)
(with-pushed-canvas ()
(let ((v (* (cos (* (ge.util:real-time-seconds) 0.5)) 0.01)))
(scale-canvas (+ 0.55 v) 1))
(draw-text "NOTALONE AGAIN"
(vec2 (- (/ *viewport-width* 2) 50)
(/ *viewport-height* 2))
:fill-color *foreground-color*
:font space-font))
(draw-text "PRESS ENTER TO START"
(vec2 (- (/ *viewport-width* 2) 120)
(- (/ *viewport-height* 2) 200))
:fill-color *foreground-color*
:font avara-font)))
| 1,967 | Common Lisp | .lisp | 47 | 33.319149 | 74 | 0.596436 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 55c59b95d1d04d90603f009bffaa357d53a6a526f5be5eaf5640cca031a55004 | 16,786 | [
-1
] |
16,787 | level.lisp | borodust_notalone-again/src/states/level.lisp | (cl:in-package :notalone-again)
(defparameter *base-batch-cooldown* 10)
(defparameter *spawn-points* (list (vec2 600 400)
(vec2 200 400)
(vec2 600 200)
(vec2 200 200)))
(defclass level (state-input-handler)
((universe :initform nil)
(player :initform nil)
(projectiles :initform nil)
(enemies :initform nil)
(start-time :initform (ge.util:real-time-seconds))
(last-spawn :initform nil)
(next-state :initform nil)
(score :initform 0 :reader level-score)))
(defun on-pre-solve (this that)
(collide (shape-substance this) (shape-substance that))
nil)
(defun level-next-state (state &rest args &key &allow-other-keys)
(with-slots (next-state) (current-state)
(unless next-state
(setf next-state (append (list state) args)))))
(defun spawn-enemy (level x y)
(with-slots (enemies universe) level
(let ((enemy (make-enemy universe x y)))
(push enemy enemies))))
(defun spawn-batch (this)
(with-slots (last-spawn) this
(play-sound :portal)
(loop for spawn-point in *spawn-points*
do (spawn-enemy this (x spawn-point) (y spawn-point)))
(setf last-spawn (ge.util:real-time-seconds))))
(defun kill-enemy (enemy projectile)
(with-slots (enemies projectiles universe score) (current-state)
(when (member enemy enemies)
(play-sound :explosion)
(destroy-enemy enemy)
(alexandria:deletef enemies enemy)
(incf score))
(when (member projectile projectiles)
(destroy-projectile projectile)
(alexandria:deletef projectiles projectile))))
(defmethod post-initialize ((this level))
(with-slots (universe player) this
(play-sound :unknown-energy :looped-p t)
(setf universe (make-universe :2d :on-pre-solve #'on-pre-solve)
player (make-player universe))
(update-player-position player 100 100)
(update-player-rotation player 0)
(spawn-batch this)))
(defmethod pre-destroy ((this level))
(with-slots (universe player projectiles enemies) this
(destroy-player player)
(loop for projectile in projectiles
do (destroy-projectile projectile))
(loop for enemy in enemies
do (destroy-enemy enemy))
(dispose universe)
(stop-sound :unknown-energy))
(call-next-method))
(defmethod button-pressed ((this level) (button (eql :f)))
(with-slots (player) this
(turn-right player)))
(defmethod button-released ((this level) (button (eql :f)))
(with-slots (player) this
(stop-right-turn player)))
(defmethod button-pressed ((this level) (button (eql :d)))
(with-slots (player) this
(turn-left player)))
(defmethod button-released ((this level) (button (eql :d)))
(with-slots (player) this
(stop-left-turn player)))
(defmethod button-pressed ((this level) (button (eql :j)))
(with-slots (player) this
(engage-thrust player)))
(defmethod button-released ((this level) (button (eql :j)))
(with-slots (player) this
(disengage-thrust player)))
(defmethod dpad-changed ((this level) (button (eql :up)))
(with-slots (player) this
(engage-thrust player)))
(defmethod dpad-changed ((this level) (button (eql :left)))
(with-slots (player) this
(turn-left player)))
(defmethod dpad-changed ((this level) (button (eql :right)))
(with-slots (player) this
(turn-right player)))
(defmethod dpad-changed ((this level) (button (eql :left-up)))
(with-slots (player) this
(engage-thrust player)
(turn-left player)))
(defmethod dpad-changed ((this level) (button (eql :right-up)))
(with-slots (player) this
(engage-thrust player)
(turn-right player)))
(defmethod dpad-changed ((this level) (button (eql :centered)))
(with-slots (player) this
(stop-left-turn player)
(stop-right-turn player)
(disengage-thrust player)))
(defmethod button-released ((this level) (button (eql :p)))
(spawn-enemy this 400 300))
(defun shoot (this)
(with-slots (universe projectiles player) this
(let ((projectile (make-projectile universe
(player-bow-position player)
(player-rotation player)
(vector-length (player-velocity player)))))
(play-sound :weapon)
(push projectile projectiles))))
(defmethod button-pressed ((this level) (button (eql :space)))
(shoot this))
(defmethod button-pressed ((this level) (button (eql :gamepad-right-bumper)))
(shoot this))
(defmethod button-released ((this level) (button (eql :escape)))
(transition-to 'loading-screen))
(defmethod button-released ((this level) (button (eql :r)))
(transition-to 'level))
(defun next-batch-spawn-cooldown (level)
(with-slots (start-time) level
(max (* *base-batch-cooldown*
(- 1 (/ (max (- (ge.util:real-time-seconds) start-time) 1) 60)))
2)))
(defmethod act ((this level))
(with-slots (player universe enemies next-state last-spawn) this
(when next-state
(apply #'transition-to next-state))
(update-player player)
(loop for enemy in enemies
do (seek-player enemy player))
(observe-universe universe 0.10)
(when (> (- (ge.util:real-time-seconds) last-spawn)
(next-batch-spawn-cooldown this))
(spawn-batch this))))
(defun elapsed-time-text (level)
(with-slots (start-time) level
(let ((elapsed (- (ge.util:real-time-seconds) start-time)))
(format nil "~2,'0d:~2,'0d"
(floor (/ elapsed 60))
(floor (mod elapsed 60))))))
(defmethod draw ((this level))
(with-slots (player projectiles enemies start-time score) this
(draw-rect *zero-origin* *viewport-width* *viewport-height*
:fill-paint *background-color*)
(render player)
(loop for projectile in projectiles
do (render projectile))
(loop for enemy in enemies
do (render enemy))
(draw-text (elapsed-time-text this)
(vec2 5 5)
:fill-color *foreground-color*)
(draw-text (format nil "~2,'0d" score)
(vec2 65 5)
:fill-color *foreground-color*)))
(defmethod collide ((this player) (that projectile))
(level-next-state 'end-screen :total-time (elapsed-time-text (current-state))
:reason :projectile
:score (level-score (current-state))))
(defmethod collide ((that projectile) (this player))
(collide this that))
(defmethod collide ((this player) (that enemy))
(level-next-state 'end-screen :total-time (elapsed-time-text (current-state))
:reason :enemy
:score (level-score (current-state))))
(defmethod collide ((that enemy) (this player))
(collide this that))
(defmethod collide ((this enemy) (that projectile))
(kill-enemy this that))
(defmethod collide ((that projectile) (this enemy))
(collide this that))
| 7,009 | Common Lisp | .lisp | 171 | 34.327485 | 82 | 0.650656 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 6d8fede3f246307504a9638e33b5167ff4402a43050d1d325bd347e652e3ddde | 16,787 | [
-1
] |
16,788 | end-screen.lisp | borodust_notalone-again/src/states/end-screen.lisp | (cl:in-package :notalone-again)
(defclass end-screen (state-input-handler)
((total-time :initarg :total-time)
(reason :initarg :reason)
(score :initarg :score)
(space-font :initform nil)
(avara-font :initform nil)))
(defmethod post-initialize ((this end-screen))
(play-sound :the-anomaly)
(with-slots (space-font avara-font) this
(setf space-font (make-font :space-meatball 60)
avara-font (make-font :avara 24))))
(defmethod pre-destroy ((this end-screen))
(stop-sound :the-anomaly))
(defmethod button-pressed ((this end-screen) (button (eql :enter)))
(transition-to 'level))
(defmethod button-pressed ((this end-screen) (button (eql :gamepad-start)))
(transition-to 'level))
(defmethod draw ((this end-screen))
(with-slots (reason total-time score space-font avara-font) this
(draw-rect *zero-origin* *viewport-width* *viewport-height*
:fill-paint *background-color*)
(if (eq reason :projectile)
(with-pushed-canvas ()
(scale-canvas 0.6 1)
(draw-text "YOU KILLED YOURSELF"
(vec2 (- (/ *viewport-width* 2) 250)
(+ (/ *viewport-height* 2) 100))
:fill-color *foreground-color*
:font space-font))
(draw-text "YOU DIED"
(vec2 (- (/ *viewport-width* 2) 210)
(+ (/ *viewport-height* 2) 100))
:fill-color *foreground-color*
:font space-font))
(draw-text (format nil "Total time: ~A" total-time)
(vec2 (- (/ *viewport-width* 2) 100)
(- (/ *viewport-height* 2) 100))
:fill-color *foreground-color*
:font avara-font)
(draw-text (format nil "Enemies killed: ~A" score)
(vec2 (- (/ *viewport-width* 2) 100)
(- (/ *viewport-height* 2) 140))
:fill-color *foreground-color*
:font avara-font)
(draw-text "PRESS ENTER TO TRY AGAIN"
(vec2 (- (/ *viewport-width* 2) 170)
(- (/ *viewport-height* 2) 250))
:fill-color *foreground-color*
:font avara-font)))
| 2,229 | Common Lisp | .lisp | 50 | 33.72 | 75 | 0.558837 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 809f73cd39e1a5e3b65b8d6af07a3c10896c405762f6ed4a875b3853d4659bc8 | 16,788 | [
-1
] |
16,789 | notalone-again.asd | borodust_notalone-again/notalone-again.asd | (cl:pushnew :bodge-gl2 cl:*features*)
(asdf:defsystem :notalone-again
:description "Lisp Game Jam 2019 entry"
:author "Pavel Korolev"
:mailto "[email protected]"
:depends-on (alexandria trivial-gamekit
trivial-gamekit-fistmachine
trivial-gamekit-input-handler
cl-bodge/physics
cl-bodge/physics/2d)
:serial t
:pathname "src/"
:components ((:file "packages")
(:file "util")
(:file "resources")
(:module "models"
:serial t
:components ((:file "projectile")
(:file "player")
(:file "enemy")))
(:module "states"
:serial t
:components ((:file "main-menu")
(:file "loading-screen")
(:file "level")
(:file "end-screen")))
(:file "main")))
| 1,033 | Common Lisp | .asd | 27 | 22.37037 | 55 | 0.445328 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 8e51f6423e0ba04197aa79e843d24eb546045015939e39e5ffd573bcbc607b4f | 16,789 | [
-1
] |
16,792 | .travis.yml | borodust_notalone-again/.travis.yml | language: common-lisp
sudo: false
addons:
apt:
packages:
- zip
env:
global:
- GAMEKIT_SYSTEM_NAME: notalone-again
- GAMEKIT_APPLICATION_PACKAGE: notalone-again
- GAMEKIT_APPLICATION_MAIN_CLASS: notalone-again
- PATH: ~/bin/:$PATH
- GAMEKIT_TARGET_PACKAGE: $GAMEKIT_SYSTEM_NAME-x86-64-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.zip
- GAMEKIT_BUILD_DIR: /tmp/$GAMEKIT_SYSTEM_NAME
- secure: "rfKaTa3FsBukWfnIeNbWL8CVI2wUS+c2SsZRraFozuLV/VgO3fMA+li1tZTU3nTeq//JB9OxyPDr+9Hbpoce9QMugg8KWGRE5jYhVHtngjjDo6yKiUk3oKI8D8VX43c922ZeCWyOL9NiBysF7CSU2tlJy4QzTy7P9fhHY+oBRKxAyYG2w9c1LLOVTV23cO0Xs3bfk9QO2D+wPBco4HygYSVKdsgw4AzTxAZl2+p3sOihq1Rzo1FxQiwSWsaiDQVCKuzIvE/E7JYUtV8KeR+/Z/MUoOqZBoUh3SPNAk080BFY7UbkNfAmc0AlSKPkCe58CWH6+bjTHy+LUQdja8G506giIEAvTvKxLEqjXNkuJAC0o+2u6asQKQp7ty2UEdCLWAHKZ06MRtl+J8C9BB+y+PpnI8vEnhjqA6lVHJByTV45ysvAc3z4clHxJWyQe7ui2eIf4eP2fSlI/BOOQO5A1TxWZw0Ie/4wpFn0twW3aSlABBjMXA89vyHmmVxGMQlOOVhkV4Edg7gXb/1URwd/r+3YlqeqW9A64prv8DB4VTYZz24DF6b4fNH6S/icpgfdfAIL22Q0VS9ebg4YqINpPYz9+IapcQ4+t5zO4tDPeV04w8BVUVEAsqW7fRp95uTz0oWCEmZ+IKMkcnDAsVk6iQ0awsMqPZ5JqKPyFkFhnuU="
branches:
only:
- "/^v\\d+(\\.\\d+)+$/"
os:
- linux
- osx
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install git-lfs; fi
- curl -L http://bodge.borodust.org/files/install.sh | sh
- git lfs install && git lfs pull
script:
- >
lisp $HOME/bodge/scripts/build-experimental-gamekit-system.lisp
$GAMEKIT_SYSTEM_NAME $GAMEKIT_APPLICATION_PACKAGE $GAMEKIT_APPLICATION_MAIN_CLASS
$TRAVIS_BUILD_DIR
$GAMEKIT_BUILD_DIR
before_deploy:
- mv "$GAMEKIT_BUILD_DIR/$GAMEKIT_SYSTEM_NAME.zip" $GAMEKIT_TARGET_PACKAGE
deploy:
provider: releases
api-key: $GITHUB_TOKEN
file: $GAMEKIT_TARGET_PACKAGE
skip_cleanup: true
overwrite: true
on:
tags: true
| 1,881 | Common Lisp | .l | 43 | 40.674419 | 698 | 0.792783 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 360dc231f1b1edfc49ecce36a18d97d9e5a23193bb85e27bcad32977763bbc43 | 16,792 | [
-1
] |
16,793 | .appveyor.yml | borodust_notalone-again/.appveyor.yml | image:
- Visual Studio 2017
platform:
- x64
environment:
global:
GAMEKIT_SYSTEM_NAME: notalone-again
GAMEKIT_APPLICATION_PACKAGE: notalone-again
GAMEKIT_APPLICATION_MAIN_CLASS: notalone-again
GAMEKIT_ARTIFACT: $(GAMEKIT_SYSTEM_NAME)-x86-64-windows-$(APPVEYOR_REPO_TAG_NAME).zip
GAMEKIT_BUILD_DIR: $(TMP)\$(GAMEKIT_SYSTEM_NAME)
skip_non_tags: true
branches:
only:
- master
- "/^v\\d+(\\.\\d+)+$/"
install:
- set PATH=C:\msys64\usr\bin\;%PATH%
- pacman --noconfirm -Syu
- pacman --noconfirm -S zip mingw-w64-x86_64-git-lfs
- sh -c "git lfs install && git lfs pull"
- sh -c "curl -L http://bodge.borodust.org/files/install.sh | sh"
build_script:
- >
sh -c "$HOME/bin/lisp $HOME/bodge/scripts/build-experimental-gamekit-system.lisp
%GAMEKIT_SYSTEM_NAME% %GAMEKIT_APPLICATION_PACKAGE% %GAMEKIT_APPLICATION_MAIN_CLASS%
$(cygpath -u '%APPVEYOR_BUILD_FOLDER%')
$(cygpath -u '%GAMEKIT_BUILD_DIR%')"
- mv %GAMEKIT_BUILD_DIR%\%GAMEKIT_SYSTEM_NAME%.zip %GAMEKIT_ARTIFACT%
artifacts:
- path: "%GAMEKIT_ARTIFACT%"
name: release_archive
deploy:
provider: GitHub
release: $(APPVEYOR_REPO_TAG_NAME)
tag: $(APPVEYOR_REPO_TAG_NAME)
description: $(APPVEYOR_REPO_COMMIT_MESSAGE)
auth_token:
secure: Z5XWjDOBlCrmfz3SQAjnLKtdgI5B2b/owJhRPNWYGrI+qwVNbBc4cZiroBZReWP7
artifact: release_archive
force_update: true
draft: false
prerelease: false
on:
appveyor_repo_tag: true
| 1,456 | Common Lisp | .l | 45 | 28.933333 | 89 | 0.71826 | borodust/notalone-again | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 3a0dda22a8ef78e959911b767155aba2d958e86280ae55eb7e8f1b694a371f2b | 16,793 | [
-1
] |
16,819 | hard-ttt-vecs.lisp | oblivia-simplex_genlin/hard-ttt-vecs.lisp | #(14873) #(14792) #(16961) #(15035)
#(14441) #(14684) #(8309) #(16871)
#(7391) #(7877) #(7472) #(14996)
#(16868) #(8444) #(8435) #(11837)
| 176 | Common Lisp | .lisp | 4 | 42 | 43 | 0.430233 | oblivia-simplex/genlin | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | f3da6e6583117c6f30ad000ef48276351cc10d3c47a9950530a4bd241de92c0f | 16,819 | [
-1
] |
16,820 | iris.lisp | oblivia-simplex_genlin/iris.lisp | ;; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;; Data reading functions
;; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;; (defpackage :genlin
;; (:use :common-lisp))
(in-package #:genlin)
(defun parse-iris-key (k)
(coerce (mapcar #'rational
(read-from-string
(concatenate 'string "("
(substitute #\space #\, k) ")")))
'vector))
(defun iris-hash (line ht)
(let* ((kv (split-at-label line))
(raw-k (car kv))
(raw-v (cdr kv))
(val (cond ((search "setosa" raw-v) 0)
((search "versicolor" raw-v) 1)
((search "virginica" raw-v) 2)
(t (error (format nil "NO MATCH FOR ~a" raw-v)))))
(key (parse-iris-key raw-k)))
(setf (gethash key ht) val)))
(defun iris-datafile->hashtable (&key filename)
(format t "FILENAME: ~a~%" filename)
(let ((ht (make-hash-table :test 'equal))
(input (open filename :if-does-not-exist nil)))
(when input
(loop for line = (read-line input nil)
while line do
(iris-hash line ht)
(and *debug* (format t "READ| ~a~%" line)))
(close input))
ht))
(defun iris-data-string (vec)
(format nil "SEPAL LENGTH: ~fcm~%SEPAL WIDTH ~fcm~%PETAL LENGTH: ~fcm~%PETAL WIDTH: ~fcm~%" (aref vec 0) (aref vec 1) (aref vec 2) (aref vec 3)))
(defun iris-plot (vec)
(let ((headings #("SEPAL LENGTH:" "SEPAL WIDTH: " "PETAL LENGTH:"
"PETAL WIDTH: ")))
(loop for i from 0 to (1- (length vec)) collect
(format t "~a ~f ~v@{~A~:*~}~%" (aref headings i) (aref vec i)
(round (* 7.5 (aref vec i))) #\#))))
(defun iris-classification-report (&key (crt *best*) (ht) (out '(0 1 2)))
(print-creature crt)
(let ((seq (creature-eff crt))
(correct 0)
(incorrect 0)
(failures '())
(iris-names '(SETOSA VERSICOLOR VIRGINICA)))
(loop for k being the hash-keys in ht using (hash-value v) do
(let* ((output (mapcar #'abs (execute-creature crt
:debug t
:input k
:output out)))
(sum (reduce #'+ output))
(certainties (loop for guess in output collect
(* (div guess sum) 100)))
(success (= (elt output v)
(reduce #'max output))))
(format t "~%")
(iris-plot k)
(format t "~%")
(loop for i from 0 to 2 do
(format t "~s: ~f%~%" (elt iris-names i)
(elt certainties i)))
(cond (success
(format t "~%CORRECTLY CLASSIFIED AS ~s~%"
(elt iris-names v))
(incf correct))
((not success)
(format t "~%INCORRECTLY CLASSIFIED. WAS ACTUALLY A ~s~%"
(elt iris-names v))
(incf incorrect)
(push k failures))))
(hrule))
(format t " ~@(~r~) Failures:~%"
(length failures))
(hrule)
(loop for fail in failures do
(format t "~%SPECIES: ~s, VECTOR: ~a~%"
(elt iris-names (gethash fail ht)) fail)
(iris-plot fail))
(hrule)
(format t "TOTAL CORRECT: ~d~%TOTAL INCORRECT: ~d~%"
correct incorrect)
(hrule)
failures))
| 3,641 | Common Lisp | .lisp | 86 | 29.802326 | 147 | 0.45226 | oblivia-simplex/genlin | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | f700a44e7490f62f472b4c2e33af0cc375d38d3809ec816aec0b77a69de24caf | 16,820 | [
-1
] |
16,821 | package.lisp | oblivia-simplex_genlin/package.lisp | ;;;; package.lisp
(in-package :common-lisp-user)
(defpackage #:genlin
(:use #:cl
#:sb-thread))
(in-package :genlin)
;; foo
| 137 | Common Lisp | .lisp | 7 | 16.571429 | 30 | 0.642857 | oblivia-simplex/genlin | 3 | 2 | 0 | GPL-3.0 | 9/19/2024, 11:27:44 AM (Europe/Amsterdam) | 5890af6a4ef82293d6b9e48ecf2e013c71bcbbda1e80e18091e5e5312ec1abad | 16,821 | [
-1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.