├── CHANGES ├── IDEAS ├── Makefile ├── Makefile.cf ├── README ├── TODO ├── mod ├── bin │ ├── install.mo │ ├── install.ms │ ├── mosref.mo │ ├── mosref.ms │ ├── wasp-vim-syntax.mo │ ├── wasp-vim-syntax.ms │ ├── wasp.mf │ ├── wasp.mo │ ├── wasp.ms │ ├── waspc.mf │ ├── waspc.mo │ ├── waspc.ms │ ├── waspdoc.mo │ └── waspdoc.ms ├── core │ ├── config.mo │ ├── config.ms │ ├── file.mo │ ├── file.ms │ ├── io.mo │ ├── io.ms │ ├── macro.mo │ ├── macro.ms │ ├── module.mo │ └── module.ms ├── lib │ ├── args-fu.mo │ ├── args-fu.ms │ ├── bridge.mo │ ├── bridge.ms │ ├── buffer-input.mo │ ├── buffer-input.ms │ ├── build.mo │ ├── build.ms │ ├── catch.mo │ ├── catch.ms │ ├── checksum-filter.mo │ ├── checksum-filter.ms │ ├── clue.mo │ ├── clue.ms │ ├── collate-filter.mo │ ├── collate-filter.ms │ ├── compile.mo │ ├── compile.ms │ ├── cons-filter.mo │ ├── cons-filter.ms │ ├── copy-filter.mo │ ├── copy-filter.ms │ ├── crypto-filter.mo │ ├── crypto-filter.ms │ ├── env.mo │ ├── env.ms │ ├── eval.mo │ ├── eval.ms │ ├── filter.mo │ ├── filter.ms │ ├── format-filter.mo │ ├── format-filter.ms │ ├── fuzz-filter.mo │ ├── fuzz-filter.ms │ ├── http-client.mo │ ├── http-client.ms │ ├── http-file-server.mo │ ├── http-file-server.ms │ ├── http-server.mo │ ├── http-server.ms │ ├── http-url.mo │ ├── http-url.ms │ ├── import.mo │ ├── import.ms │ ├── iterate.mo │ ├── iterate.ms │ ├── line-filter.mo │ ├── line-filter.ms │ ├── module.mo │ ├── module.ms │ ├── object.mo │ ├── object.ms │ ├── optimize.mo │ ├── optimize.ms │ ├── options.mo │ ├── options.ms │ ├── package-filter.mo │ ├── package-filter.ms │ ├── patch.mo │ ├── patch.ms │ ├── record.mo │ ├── record.ms │ ├── repl.mo │ ├── repl.ms │ ├── s-filter.mo │ ├── s-filter.ms │ ├── scud.mo │ ├── scud.ms │ ├── shuffle.mo │ ├── shuffle.ms │ ├── socks-client.mo │ ├── socks-client.ms │ ├── socks-server.mo │ ├── socks-server.ms │ ├── spawn-connection.mo │ ├── spawn-connection.ms │ ├── tag-filter.mo │ ├── tag-filter.ms │ ├── tcp-server.mo │ ├── tcp-server.ms │ ├── terminal.mo │ ├── terminal.ms │ ├── test.mo │ ├── test.ms │ ├── trace.mo │ ├── trace.ms │ ├── url.mo │ ├── url.ms │ ├── waspc.mo │ ├── waspc.ms │ ├── with-io.mo │ └── with-io.ms ├── local-config.mo ├── local-config.ms ├── mosref │ ├── cmd │ │ ├── clear.mo │ │ ├── clear.ms │ │ ├── cp.mo │ │ ├── cp.ms │ │ ├── do.mo │ │ ├── do.ms │ │ ├── drone.mo │ │ ├── drone.ms │ │ ├── exit.mo │ │ ├── exit.ms │ │ ├── exploit.mo │ │ ├── exploit.ms │ │ ├── fork.mo │ │ ├── fork.ms │ │ ├── help.mo │ │ ├── help.ms │ │ ├── load.mo │ │ ├── load.ms │ │ ├── nodes.mo │ │ ├── nodes.ms │ │ ├── on.mo │ │ ├── on.ms │ │ ├── proxy.mo │ │ ├── proxy.ms │ │ ├── recover.mo │ │ ├── recover.ms │ │ ├── set.mo │ │ ├── set.ms │ │ ├── sh.mo │ │ ├── sh.ms │ │ ├── with.mo │ │ └── with.ms │ ├── cmds.mo │ ├── cmds.ms │ ├── console.mo │ ├── console.ms │ ├── drone.mo │ ├── drone.ms │ ├── format.mo │ ├── format.ms │ ├── listener.mo │ ├── listener.ms │ ├── node.mo │ ├── node.ms │ ├── parse.mo │ ├── parse.ms │ ├── prop │ │ ├── address.mo │ │ ├── address.ms │ │ ├── online.mo │ │ ├── online.ms │ │ ├── platform.mo │ │ ├── platform.ms │ │ ├── port.mo │ │ └── port.ms │ ├── props.mo │ ├── props.ms │ ├── shell.mo │ ├── shell.ms │ ├── transport.mo │ └── transport.ms ├── site │ └── dont-delete ├── waspc.mf └── waspdoc │ ├── base.mo │ ├── base.ms │ ├── c-file.mo │ ├── c-file.ms │ ├── check-source.mo │ ├── check-source.ms │ ├── dump-source.mo │ ├── dump-source.ms │ ├── dump.mo │ ├── dump.ms │ ├── ms-file.mo │ ├── ms-file.ms │ ├── source.mo │ └── source.ms ├── package.sh ├── rx ├── COPYRIGHT ├── Makefile ├── README ├── WHATSNEW ├── cclass.h ├── cname.h ├── debug.c ├── engine.c ├── fake │ ├── limits.h │ ├── memmove.c │ └── stdlib.h ├── main.c ├── mkh ├── re.exe ├── regcomp.c ├── regerror.c ├── regex.3 ├── regex.7 ├── regex.h ├── regex2.h ├── regexec.c ├── regfree.c ├── split.c ├── tests └── utils.h ├── stubs └── dont-delete ├── test ├── affiliation.ms ├── blit.ms ├── bridge.mo ├── bridge.ms ├── clue.ms ├── collate-filter.ms ├── curve25519.ms ├── http-server.ms ├── http-url.ms ├── mosref-base.ms ├── salsa.ms ├── socks.ms ├── spawn-connection.ms └── url.ms ├── util ├── alter-symbol.sh └── prim-use.ms └── vm ├── boolean.c ├── channel.c ├── closure.c ├── connection.c ├── core.c ├── crc32.c ├── curve.c ├── curve25519_i64.c ├── curve25519_i64.h ├── error.c ├── file.c ├── filesystem.c ├── format.c ├── init.c ├── list.c ├── memory.c ├── mq.c ├── multimethod.c ├── number.c ├── os.c ├── package.c ├── parse.c ├── plugin.c ├── primitive.c ├── print.c ├── procedure.c ├── process.c ├── queue.c ├── regex.c ├── salsa.c ├── salsa20-config.h ├── salsa20-machine.h ├── salsa20-portable.h ├── salsa20.c ├── salsa20.h ├── shell.c ├── string.c ├── tag.c ├── time.c ├── tree.c ├── vector.c ├── vm.c ├── waspld.c ├── waspvm.c ├── waspvm.h └── waspvm ├── boolean.h ├── channel.h ├── closure.h ├── config.h.in ├── connection.h ├── error.h ├── file.h ├── format.h ├── list.h ├── memory.h ├── mq.h ├── multimethod.h ├── number.h ├── os.h ├── package.h ├── parse.h ├── plugin.h ├── primitive.h ├── print.h ├── procedure.h ├── process.h ├── queue.h ├── stamp-h ├── stamp-h.in ├── string.h ├── tag.h ├── time.h ├── tree.h ├── vector.h └── vm.h /Makefile.cf: -------------------------------------------------------------------------------- 1 | OS?=$(shell uname -s | sed 's:_.*::') 2 | ARCH?=$(shell uname -m) 3 | ROOT=$(shell pwd) 4 | SYS=mod/sys 5 | 6 | VERSION=0.4.2 7 | 8 | CFLAGS += -DWASP_VERSION='"$(VERSION)"' 9 | 10 | STATICLIBS += -levent 11 | 12 | ifeq ($(ARCH),i686) 13 | ARCH = x86 14 | else 15 | ifeq ($(ARCH),Power Macintosh) 16 | ARCH = ppc 17 | endif 18 | endif 19 | 20 | ifeq ($(OS),MINGW32) 21 | OS = win 22 | else 23 | ifeq ($(OS),Linux) 24 | OS = linux 25 | endif 26 | endif 27 | 28 | ifeq ($(OS),win) 29 | EXE = .exe 30 | OBJ = .o 31 | SO = .dll 32 | CFLAGS += -mno-cygwin 33 | CFLAGS += -DWASP_SO='".dll"' 34 | CFLAGS += -I/usr/local/include -L/usr/local/lib -L/usr/lib/w32api 35 | CFLAGS += -D_WIN32_WINNT=0x501 36 | EXEFLAGS += -L/usr/local/lib 37 | DYNAMICLIBS += -lws2_32 38 | CFLAGS += -Irx 39 | LDFLAGS += -Lrx 40 | LIBRX += rx/libregex.a 41 | 42 | else # Assuming we're in UNIX.. 43 | 44 | EXE = 45 | OBJ = .o 46 | SO = .so 47 | 48 | ifeq ($(OS),Darwin) 49 | CFLAGS += -fnested-functions 50 | endif 51 | 52 | CFLAGS += -DWASP_SO='".so"' 53 | ### Disabled until lib/build and bin/waspc understands subsystems. 54 | # EXEFLAGS += -rdynamic -ldl 55 | PLATFORM = unix 56 | ### An indirect dependency of libevent. 57 | ifneq ($(OS),Darwin) 58 | ifneq ($(OS),android) 59 | DYNAMICLIBS += -lrt 60 | endif 61 | endif 62 | 63 | endif 64 | 65 | ifdef DEBUG 66 | 67 | CFLAGS += -g 68 | 69 | else 70 | 71 | CFLAGS += -DNDEBUG 72 | 73 | endif 74 | 75 | ifdef COMPACT 76 | ### NOTE: -Os causes list formatting to fail on linux with gcc-4.3. 77 | CFLAGS += -Os 78 | else 79 | ifdef FAST 80 | ### NOTE: -O3 causes list formatting to fail on linux with gcc-4.3. 81 | CFLAGS += -O2 82 | else 83 | CFLAGS += -O 84 | endif 85 | endif 86 | 87 | PLATFORM = $(OS)-$(ARCH) 88 | CFLAGS += -DWASP_PLATFORM='"$(PLATFORM)"' 89 | 90 | ### Derived from a patch submitted by Chris Double. 91 | ifeq ($(OS),Darwin) 92 | EXEFLAGS += $(STATICLIBS) $(DYNAMICLIBS) 93 | else 94 | EXEFLAGS += -Wl,-Bstatic $(STATICLIBS) -Wl,-Bdynamic $(DYNAMICLIBS) 95 | endif 96 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | WHAT IS WASP LISP? 2 | ------------------ 3 | 4 | Wasp Lisp is a member of the Lisp-1 family, borrowing principles from R5RS Scheme, Python and Erlang. It is a pragmatic language, designed to provide developers with tools to rapidly build network applications that require sophisticated logic and quick turnarounds between prototype and production. 5 | 6 | Wasp Lisp provides the following features inherited from Mosquito Lisp: 7 | 8 | - Compact Implementation 9 | - Cooperative Lightweight Threads 10 | - Unique, efficient I/O model 11 | 12 | Beyond the functionality provided by Mosquito Lisp, Wasp Lisp provides the ability to extend Wasp Lisp with modules written in ANSI C and refinement of many of Mosquito's features based on feedback by the Lisp community. 13 | 14 | WHAT IS THIS PACKAGE? 15 | ----------------------- 16 | 17 | This Wasp Lisp source code package consists of the source code for four key components of the Wasp Lisp environment: 18 | 19 | - WaspDoc, the Wasp documentation tool which provides a way to view and update 20 | documentation associated with Wasp Lisp. 21 | 22 | - WaspVM, a compact interpreter written in ANSI C for programs written in 23 | Wasp Lisp. 24 | 25 | - WaspC, the compiler for Wasp Lisp programs, written in Wasp Lisp itself. 26 | 27 | - Wasp, the Wasp interactive environment which provides interactive 28 | programming and troubleshooting for Wasp Lisp programmers. 29 | 30 | The particular version of Wasp Lisp containing this file is called "Wasp Rewind". 31 | 32 | WHO IS THE WASP TEAM? 33 | --------------------- 34 | 35 | Until the 1.0 release of Wasp Lisp, the Wasp Team consists solely of the original designer of WaspVM and MOSVM, Scott W. Dunlop . After the ball gets rolling, the Wasp Team will expand to include members of the Wasp community who have shown the interest and insight to shepherd the evolution of Wasp Lisp. 36 | 37 | THANKS 38 | ------ 39 | 40 | Thank you, foremost, to Wes Brown for his funding of the Mosquito project. I would never have had the time for all this without it. Also, my eternal appreciation to the GNU project, as their toolchain has so thoroughly spoiled me that I refuse to deal with any other. 41 | 42 | MOSREF relies on the cryptographic work of a lot of researchers beyond myself; without their efforts, I would have wasted a tremendous amount of time reinventing the wheel: D. J. Bernstein for his analysis of the 25519 Elliptic, and Matthijs van Duin, for translating D. J. Bernstein's work into ANSI C for use by mere mortals like myself. 43 | 44 | Also, any public notice of Wasp Lisp is largely due to Bill Clementson, whose continued interest and occasional notice has kept the project in the public eye for years, now. 45 | 46 | Years after development stopped on WaspVM and I moved on to other projects, Chris Double (@doublec) has kept coming up with neat fixes and ports, such as an Android stub. 47 | -------------------------------------------------------------------------------- /mod/bin/install.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/bin/install.mo -------------------------------------------------------------------------------- /mod/bin/mosref.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/bin/mosref.mo -------------------------------------------------------------------------------- /mod/bin/mosref.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "bin/mosref") 18 | (import "lib/env") 19 | (import "lib/with-io") 20 | ;(import "lib/terminal") 21 | (import "lib/iterate") 22 | (import "mosref/console") 23 | (import "mosref/shell") 24 | (import "mosref/cmds") 25 | 26 | (export spawn main) 27 | 28 | (define actual-spawn spawn) 29 | 30 | (define (spawn fn . args) 31 | (define (trace-and-halt err) 32 | (define buffer (make-string)) 33 | (traceback err buffer) 34 | (print* "IN: " (format fn) " " buffer) 35 | (halt)) 36 | 37 | (actual-spawn (function (spawn-safety) 38 | (guard trace-and-halt 39 | (apply fn args))))) 40 | 41 | (define (main . args) 42 | (do-mosref args)) 43 | 44 | ;TODO:TERMINAL 45 | ;(if *in-win32* 46 | ; (with-io (spawn-terminal "MOSREF") 47 | ; (do-mosref args)) 48 | ; (do-mosref args))) 49 | 50 | (define (do-mosref args) 51 | (define unparsed-args (apply make-tc args)) 52 | 53 | (define (next-arg) (if (tc-empty? unparsed-args) 54 | #f 55 | (tc-next! unparsed-args))) 56 | 57 | (define addr (next-arg)) 58 | (define portno (next-arg)) 59 | 60 | (define node (make-console-node addr portno)) 61 | 62 | (run-mosref-shell node node)) 63 | 64 | -------------------------------------------------------------------------------- /mod/bin/wasp-vim-syntax.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/bin/wasp-vim-syntax.mo -------------------------------------------------------------------------------- /mod/bin/wasp-vim-syntax.ms: -------------------------------------------------------------------------------- 1 | 2 | (define (vim-keyword-list leader items) 3 | (define page (make-tc)) 4 | (define maxw (- 78 (string-length leader))) 5 | (define item (format (car items))) 6 | (define (next-item) 7 | (set! item (format (car items))) 8 | (set! items (cdr items))) 9 | 10 | (until (null? items) 11 | (define line (make-string)) 12 | (define line-full #f) 13 | 14 | (until (or line-full (null? items)) 15 | (cond 16 | ((> (+ (string-length line) 1 (string-length item)) maxw) 17 | (set! line-full #t)) 18 | 19 | (else 20 | (string-append! line " " item) 21 | (next-item)))) 22 | 23 | (tc-add! page line)) 24 | 25 | (string-join *line-sep* 26 | @(map string-append (repeat leader) page) 27 | "")) 28 | 29 | (define (function-definition? pair) 30 | (and (function? (cdr pair)) 31 | (not (eq? (car pair) 'write-vim-syntax)))) 32 | 33 | (define (vim-syntax-lines) 34 | (vim-keyword-list "syn keyword waspSyntax" 35 | (map-car (list @(waspvm-special-forms) @(waspvm-syntax))))) 36 | 37 | (define (vim-keyword-lines) 38 | (vim-keyword-list "syn keyword waspFunc" 39 | (map-car (filter function-definition? (globals))))) 40 | 41 | (define (write-vim-syntax path) 42 | (write-data-file 43 | path 44 | (string-join *line-sep* 45 | (vim-syntax-lines) 46 | "" 47 | (vim-keyword-lines)))) 48 | 49 | (export write-vim-syntax) 50 | 51 | -------------------------------------------------------------------------------- /mod/bin/wasp.mf: -------------------------------------------------------------------------------- 1 | core/macro core/config site/config core/file core/module core/io lib/optimize lib/module lib/iterate lib/object lib/record lib/compile lib/eval lib/filter lib/trace lib/repl lib/with-io lib/import bin/wasp 2 | -------------------------------------------------------------------------------- /mod/bin/wasp.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/bin/wasp.mo -------------------------------------------------------------------------------- /mod/bin/wasp.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | ; 16 | 17 | (module "bin/wasp") 18 | 19 | (import "lib/repl") 20 | (import "lib/with-io") 21 | (import "lib/import") 22 | 23 | ;TODO: Add a function to alter argv. 24 | 25 | (define (main . args) 26 | (set! main #f) 27 | ;We only want to run this main once.. 28 | 29 | (define (do-waspvm) 30 | (case (length args) 31 | ((0) (repl) 32 | (exit)) 33 | (else 34 | (let ((r (load (car args)))) 35 | ; If main was reset, we should invoke it. 36 | (if main 37 | (apply main (cdr args)) 38 | r))))) 39 | 40 | (do-waspvm)) 41 | 42 | 43 | -------------------------------------------------------------------------------- /mod/bin/waspc.mf: -------------------------------------------------------------------------------- 1 | core/macro core/config site/config core/file core/module core/io lib/module lib/iterate lib/object lib/record lib/compile lib/optimize lib/eval lib/build bin/waspc 2 | -------------------------------------------------------------------------------- /mod/bin/waspc.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/bin/waspc.mo -------------------------------------------------------------------------------- /mod/bin/waspdoc.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/bin/waspdoc.mo -------------------------------------------------------------------------------- /mod/bin/waspdoc.ms: -------------------------------------------------------------------------------- 1 | 2 | (import "waspdoc/check-source") 3 | (import "waspdoc/dump-source") 4 | 5 | (define (main . args) 6 | (define opts (apply make-tc args)) 7 | (define args (make-tc)) 8 | 9 | (define arg #f) 10 | 11 | (define (exit code) 12 | (error 'exit code)) 13 | 14 | (define (next-arg) 15 | (if (tc-empty? args) #f (tc-next! args))) 16 | 17 | (define (usage) 18 | (print* "USAGE: waspdoc check source -- Check source for new and missing.\n" 19 | " waspdoc dump source -- View source info.\n" 20 | " waspdoc dump module -- View module info.\n") 21 | (exit 0)) 22 | 23 | (define (fail . args) 24 | (if (null? args) 25 | (println* "Expected more.") 26 | (println* "Did not understand " @args ".")) 27 | (exit 1)) 28 | 29 | (define (next-opt for-what) 30 | (when (tc-empty? opts) 31 | (println* "Expected " what ".") 32 | (exit 1)) 33 | 34 | (set! opt (tc-next! opts)) 35 | opt) 36 | 37 | (define (parse-global-options) 38 | (until (tc-empty? opts) 39 | (define opt (tc-next! opts)) 40 | (case arg 41 | (("-h" "--help" "-?") (usage)) 42 | (("-r" "--root") (set-waspdoc-root! (next-opt "WaspDoc root path"))) 43 | (else (tc-add! args opt))))) 44 | 45 | (define (perform-command) 46 | (case (next-arg) 47 | (("help") (usage)) 48 | (("check") (case (next-arg) 49 | (("source") (apply check-source (tc->list args))) 50 | (else (fail "check")))) 51 | 52 | (("dump") (case (next-arg) 53 | (("source") (apply dump-source (tc->list args))) 54 | (("module") (apply dump-module (tc->list args))) 55 | (else (fail "dump")))) 56 | 57 | ((#f) (usage)))) 58 | 59 | (guard (function (catch-exit err) 60 | (when (eq? (error-key err) 'exit) 61 | (return)) 62 | 63 | (re-error err)) 64 | (parse-global-options) 65 | (perform-command) 66 | #t)) 67 | 68 | 69 | -------------------------------------------------------------------------------- /mod/core/config.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/core/config.mo -------------------------------------------------------------------------------- /mod/core/config.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (define *waspvm?* #t) 17 | (export *waspvm?*) 18 | 19 | (define *config* (make-dict)) 20 | 21 | (define (site-config key) 22 | (dict-ref *config* key)) 23 | 24 | (define (set-site-config! key value) 25 | (dict-set! *config* key value)) 26 | 27 | (export site-config set-site-config!) 28 | 29 | -------------------------------------------------------------------------------- /mod/core/file.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/core/file.mo -------------------------------------------------------------------------------- /mod/core/file.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (define (read-data-file path) 18 | (define file (open-file path "r")) 19 | (define data (read-file file)) 20 | (close-file file) 21 | data) 22 | 23 | (define (write-data-file path content) 24 | (define file (open-file path "wct")) 25 | (write-file file content) 26 | (close-file file)) 27 | 28 | (define (read-lisp-file path) 29 | (string->exprs (read-data-file path))) 30 | 31 | (define (write-lisp-file path data) 32 | (write-data-file path (exprs->string data))) 33 | 34 | (define (path-join . items) 35 | (apply string-join *path-sep* items)) 36 | 37 | (define (convert-path path) 38 | (apply path-join (string-split* path *path-sep*))) 39 | 40 | (export read-data-file write-data-file read-lisp-file write-lisp-file path-join convert-path) 41 | 42 | -------------------------------------------------------------------------------- /mod/core/io.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/core/io.mo -------------------------------------------------------------------------------- /mod/core/macro.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/core/macro.mo -------------------------------------------------------------------------------- /mod/core/macro.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (define *waspvm-syntax* (list)) 17 | (define (waspvm-syntax) *waspvm-syntax*) 18 | 19 | (define (set-macro! key fn) 20 | (unless (assq key *waspvm-syntax*) 21 | (set! *waspvm-syntax* 22 | (cons (cons key fn) *waspvm-syntax*)))) 23 | 24 | (define (ignore-method . any) #f) 25 | 26 | (export waspvm-syntax set-macro!) 27 | -------------------------------------------------------------------------------- /mod/core/module.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/core/module.mo -------------------------------------------------------------------------------- /mod/lib/args-fu.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/args-fu.mo -------------------------------------------------------------------------------- /mod/lib/bridge.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/bridge.mo -------------------------------------------------------------------------------- /mod/lib/buffer-input.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/buffer-input.mo -------------------------------------------------------------------------------- /mod/lib/build.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/build.mo -------------------------------------------------------------------------------- /mod/lib/catch.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/catch.mo -------------------------------------------------------------------------------- /mod/lib/catch.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/catch") 18 | 19 | ; Given a list of cases -- each in the form of ((key ...) stmt ...), and 20 | ; a block to evaluate, constructs a guard block that will catch errors, 21 | ; and pass them to the specified clause if encountered, as "err". 22 | 23 | ; If an else case is omitted, errors that do not match any of the clauses 24 | ; will be re-error'd. 25 | 26 | (define-macro (catch-case cases . body) 27 | (unless (assq 'else cases) 28 | (set! cases (append cases '((else (re-error err)))))) 29 | 30 | `(guard (lambda (err) 31 | (case (error-key err) 32 | ,@cases)) 33 | ,@body)) 34 | 35 | (define-macro (catch-cond conds . body) 36 | (unless (assq 'else conds) 37 | (set! conds (append conds '((else (re-error err)))))) 38 | 39 | `(guard (lambda (err) 40 | (cond ,@conds)) 41 | ,@body)) 42 | 43 | (export catch-case catch-cond) 44 | 45 | -------------------------------------------------------------------------------- /mod/lib/checksum-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/checksum-filter.mo -------------------------------------------------------------------------------- /mod/lib/checksum-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/checksum-filter") 18 | (import "lib/filter") 19 | (export prepend-checksum-filter check-checksum-filter) 20 | 21 | ; This filter will prepend data with a checksum prior to transmission. 22 | (define-filter (prepend-checksum-filter checksum) 23 | (forever 24 | (define evt (wait in)) 25 | (when (string? evt) 26 | (string-prepend! evt (quad->string (checksum evt)))) 27 | (send evt out))) 28 | 29 | (define-filter (check-checksum-filter checksum) 30 | (define buf (make-string)) 31 | 32 | (forever 33 | (define evt (wait in)) 34 | (when (string? evt) 35 | (define c (string-read-quad! evt)) 36 | (unless (= c (checksum evt)) 37 | (set! evt (list 'fail 'crc evt) out))) 38 | (send evt out))) 39 | 40 | -------------------------------------------------------------------------------- /mod/lib/clue.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/clue.mo -------------------------------------------------------------------------------- /mod/lib/collate-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/collate-filter.mo -------------------------------------------------------------------------------- /mod/lib/collate-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/collate-filter") 18 | (import "lib/buffer-input") 19 | (import "lib/filter") 20 | (export prepend-collation-filter check-collation-filter halt-on-close) 21 | 22 | ; This filter will prepend data with a length prior to transmission. 23 | (define-filter (prepend-collation-filter) 24 | (forever 25 | (define evt (wait in)) 26 | (when (string? evt) 27 | (when (> len 16) (set! len 16)) 28 | (string-prepend! evt 29 | (word->string (string-length evt)))) 30 | (send evt out))) 31 | 32 | ; This filter will refuse to produce data until its full length has been 33 | ; digested. 34 | (define-filter (check-collation-filter) 35 | (define read (buffer-input in #f out)) 36 | 37 | (define (wait-for-int) 38 | (string->word (read 2))) 39 | 40 | (forever 41 | (define len (wait-for-int)) 42 | (define msg (read len)) 43 | (define len (string-length msg)) 44 | (when (> len 16) (set! len 16)) 45 | (send msg out))) 46 | 47 | (define-filter (halt-on-close) 48 | (forever 49 | (define evt (wait in)) 50 | (when (eq? evt 'close) 51 | (halt)) 52 | (send evt out))) 53 | 54 | -------------------------------------------------------------------------------- /mod/lib/compile.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/compile.mo -------------------------------------------------------------------------------- /mod/lib/cons-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/cons-filter.mo -------------------------------------------------------------------------------- /mod/lib/cons-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | ; This filter will cons any values prior to forwarding with a given tag. 18 | 19 | (module "lib/cons-filter") 20 | (import "lib/filter") 21 | (export cons-filter) 22 | 23 | (define-filter (cons-filter tag) 24 | (forever 25 | (send (cons tag (wait in)) out))) 26 | 27 | -------------------------------------------------------------------------------- /mod/lib/copy-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/copy-filter.mo -------------------------------------------------------------------------------- /mod/lib/copy-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | ; This filter will copy any strings prior to forwarding. This is extremely 17 | ; useful when dealing with crypto filters, because they operate in a 18 | ; destructive fashion. 19 | ; 20 | (module "lib/copy-filter") 21 | (import "lib/filter") 22 | (export copy-filter) 23 | 24 | (define-filter (copy-filter) 25 | (forever 26 | (define evt (wait in)) 27 | (when (string? evt) 28 | (set! evt (copy-string evt))) 29 | (send evt out))) 30 | 31 | -------------------------------------------------------------------------------- /mod/lib/crypto-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/crypto-filter.mo -------------------------------------------------------------------------------- /mod/lib/crypto-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/crypto-filter") 18 | (import "lib/filter") 19 | (export decrypt-filter encrypt-filter) 20 | 21 | ; Decrypts each block as it arrives, and forwards. 22 | 23 | (define-filter (decrypt-filter decrypt) 24 | (forever 25 | (define evt (wait in)) 26 | (if (string? evt) 27 | (send (decrypt evt) out) 28 | (send evt out)))) 29 | 30 | ; Encrypts each block as it arrives, and forwards. 31 | 32 | (define-filter (encrypt-filter encrypt) 33 | (forever 34 | (define evt (wait in)) 35 | (if (string? evt) 36 | (send (encrypt evt) out) 37 | (send evt out)))) 38 | 39 | -------------------------------------------------------------------------------- /mod/lib/env.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/env.mo -------------------------------------------------------------------------------- /mod/lib/env.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/env") 18 | (import "lib/iterate") 19 | 20 | (define *in-winnt* (string-begins-with? *platform* "win-")) 21 | (define *in-win32* *in-winnt*) 22 | (define *in-darwin* (string-begins-with? *platform* "darwin")) 23 | ; We need to test if this is GNU/Darwin, or OS X ? 24 | (define *in-macosx* *in-darwin*) 25 | (define *in-posix* (not *in-win32*)) 26 | 27 | (define *env* (make-dict)) 28 | (define tc (apply make-tc *environ*)) 29 | (until (tc-empty? tc) 30 | (define args (string-split (tc-next! tc) "=")) 31 | (define key (if *in-win32* (string->uppercase (car args)) (car args))) 32 | (define value (cadr args)) 33 | (dict-set! *env* key value)) 34 | 35 | (define (has-env name) (dict-ref *env* name)) 36 | (define (get-env name) (has-env name)) 37 | (define (env-is name val) 38 | (equal? (get-env name) val)) 39 | 40 | (define *in-x11* (has-env "DISPLAY")) 41 | 42 | (define (locate-cmd name) 43 | (apply locate-path name 44 | (string-split* (get-env "PATH") 45 | (if *in-win32* ";" ":")))) 46 | 47 | (define-macro (osdef formals . cases) 48 | (define (gen-case case) 49 | `(,(car case) (function ,formals ,@(cdr case)))) 50 | 51 | `(define ,(car formals) (cond ,@(map gen-case (filter pair? cases))))) 52 | 53 | (export osdef locate-cmd env-is get-env has-env *env* 54 | *in-win32* *in-x11* *in-posix* *in-darwin* *in-macosx* *in-winnt*) 55 | 56 | -------------------------------------------------------------------------------- /mod/lib/eval.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/eval.mo -------------------------------------------------------------------------------- /mod/lib/eval.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (module "lib/eval") 17 | (import "lib/compile") 18 | (import "lib/optimize") 19 | 20 | (define (exec block) 21 | ((assemble (optimize (compile block))))) 22 | 23 | (define (eval expr) 24 | (exec (list expr))) 25 | 26 | (define (load-ms path) 27 | (exec (read-lisp-file path))) 28 | 29 | (define (load path) 30 | (cond ((string-ends-with? path ".ms") (load-ms path)) 31 | ((string-ends-with? path ".mo") (load-mo path)) 32 | (else "lib/eval load can only handle .mo and .ms files"))) 33 | 34 | (export eval load-ms load exec) 35 | -------------------------------------------------------------------------------- /mod/lib/filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/filter.mo -------------------------------------------------------------------------------- /mod/lib/format-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/format-filter.mo -------------------------------------------------------------------------------- /mod/lib/format-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | ; This filter will format any values prior to forwarding. 18 | ; 19 | (module "lib/format-filter") 20 | (import "lib/filter") 21 | (export format-filter) 22 | 23 | (define-filter (format-filter) 24 | (forever 25 | (send (format (wait in)) out))) 26 | 27 | -------------------------------------------------------------------------------- /mod/lib/fuzz-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/fuzz-filter.mo -------------------------------------------------------------------------------- /mod/lib/fuzz-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | ; This filter will copy any strings prior to forwarding. This is extremely 17 | ; useful when dealing with crypto filters, because they operate in a 18 | ; destructive fashion. 19 | 20 | (module "lib/fuzz-filter") 21 | (import "lib/filter") 22 | 23 | (export fuzz-filter) 24 | 25 | ; The fuzz filter randomly concatenates or divides string messages it receives 26 | ; to simulate the disruptive qualities of most TCP/IP implementations, disparate 27 | ; MTUs. The fuzz filter is guaranteed to cost resources, cause ulcers, and 28 | ; torment filter users. 29 | 30 | (define (wait/timeout duration channel) 31 | (define event (wait duration channel)) 32 | (cond 33 | ((eq? event 'timeout) 34 | (error 'timeout "wait/timeout lost its patience" duration channel)) 35 | (else event))) 36 | 37 | (define (pass-up in out) 38 | (forever 39 | (define cmd (wait in)) 40 | (if (string? cmd) 41 | (return cmd) 42 | (send cmd out)))) 43 | 44 | (define (pass-up/duration in out duration) 45 | (forever 46 | (define cmd (wait/timeout duration in)) 47 | (if (string? cmd) 48 | (return cmd) 49 | (send cmd out)))) 50 | 51 | (define-filter (fuzz-filter) 52 | (define (chop-rule) 53 | (define str (pass-up in out)) 54 | (define len (string-length str)) 55 | (define cut (random-integer 0 (- len 1))) 56 | (send (substring str 0 cut) out) 57 | (send (substring str cut (- len cut)) out)) 58 | 59 | (define (fuse-rule) 60 | (define first (pass-up in out)) 61 | (guard (lambda (err) 62 | (if (eq? (error-key err) 'timeout) 63 | (send first out) 64 | (re-error err))) 65 | (define second (pass-up/duration in out 10)) 66 | (send (string-append first second) out))) 67 | 68 | (define (pass-rule) 69 | (send (pass-up in out) out)) 70 | 71 | (forever 72 | ((case (random-integer 1 3) 73 | ((1) chop-rule) 74 | ((2) fuse-rule) 75 | ((3) pass-rule))))) 76 | 77 | -------------------------------------------------------------------------------- /mod/lib/http-client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/http-client.mo -------------------------------------------------------------------------------- /mod/lib/http-file-server.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/http-file-server.mo -------------------------------------------------------------------------------- /mod/lib/http-server.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/http-server.mo -------------------------------------------------------------------------------- /mod/lib/http-url.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/http-url.mo -------------------------------------------------------------------------------- /mod/lib/import.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/import.mo -------------------------------------------------------------------------------- /mod/lib/import.ms: -------------------------------------------------------------------------------- 1 | (module "lib/import") 2 | (import "lib/waspc") 3 | 4 | (define core-import import) 5 | 6 | (define (recompile-needed? path) 7 | (define path-ms (string-append path ".ms")) 8 | (define path-mo (string-append path ".mo")) 9 | 10 | (unless (path-exists? path-ms) (return #f)) 11 | (when (path-exists? path-mo) 12 | (return (> (path-mtime path-ms) (path-mtime path-mo)))) 13 | 14 | (return #t)) 15 | 16 | (define (import path) 17 | (when (recompile-needed? path) (waspc path)) 18 | (core-import path)) 19 | 20 | (export import) 21 | 22 | -------------------------------------------------------------------------------- /mod/lib/iterate.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/iterate.mo -------------------------------------------------------------------------------- /mod/lib/line-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/line-filter.mo -------------------------------------------------------------------------------- /mod/lib/line-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/line-filter") 18 | (import "lib/filter") 19 | 20 | (define-filter (line-filter) 21 | (define buf (make-string 80)) 22 | 23 | (define (parse) 24 | (forever 25 | (define next (string-read-line! buf)) 26 | (if next (send next out) 27 | (return)))) 28 | 29 | (define (line-loop) 30 | (forever 31 | (define next (wait-input in)) 32 | (cond 33 | ((string? next) 34 | (string-append! buf next) 35 | (parse)) 36 | ((eq? next 'close) 37 | (return)) 38 | (else 39 | (send-output next out))))) 40 | 41 | (line-loop) 42 | 43 | (send-output buf out) 44 | (send-output 'close out)) 45 | 46 | (export line-filter) 47 | -------------------------------------------------------------------------------- /mod/lib/module.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/module.mo -------------------------------------------------------------------------------- /mod/lib/object.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/object.mo -------------------------------------------------------------------------------- /mod/lib/optimize.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/optimize.mo -------------------------------------------------------------------------------- /mod/lib/options.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/options.mo -------------------------------------------------------------------------------- /mod/lib/options.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (module "lib/options") 17 | (export option define-option) 18 | 19 | (define (option options key default) 20 | (define rest (memq key options)) 21 | (if rest (cadr rest) default)) 22 | 23 | (define-macro (define-option key) 24 | `(define ,key ',key)) 25 | 26 | -------------------------------------------------------------------------------- /mod/lib/package-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/package-filter.mo -------------------------------------------------------------------------------- /mod/lib/package-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/package-filter") 18 | (import "lib/filter") 19 | 20 | (export freeze-filter thaw-filter) 21 | 22 | ; Freezes each block as it arrives, and forwards. 23 | ; TODO: This has some unexpected responses to fail.. 24 | (define-filter (freeze-filter) 25 | (forever 26 | (define evt (wait in)) 27 | (if (eq? evt 'close) 28 | (send evt out) 29 | (send (freeze evt) out)))) 30 | 31 | ; Thaws each block as it arrives, and forwards. 32 | (define-filter (thaw-filter) 33 | (forever 34 | (define evt (wait in)) 35 | (if (string? evt) 36 | (send (thaw evt) out) 37 | (send evt out)))) 38 | 39 | -------------------------------------------------------------------------------- /mod/lib/patch.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/patch.mo -------------------------------------------------------------------------------- /mod/lib/patch.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/patch") 18 | 19 | ; Given a pair of channels, xmit and recv, spawns a process that relays all 20 | ; data received by xmit to recv. 21 | 22 | (define (preface-input data in) 23 | (define q (make-queue)) 24 | (send data q) 25 | (patch in q) 26 | (input q)) 27 | 28 | (define (preface-connection data conn) 29 | (make-connection (preface-input data conn) (output conn))) 30 | 31 | (define (patch in out) 32 | (set! in (input in)) 33 | (set! out (output out)) 34 | (spawn (function (patch-process) 35 | (forever 36 | (define evt (wait in)) 37 | (send evt out) 38 | (when (eq? evt 'close) 39 | (return)))))) 40 | 41 | (define (patch2 left right) 42 | (patch left right) 43 | (patch right left)) 44 | 45 | (export patch patch2 preface-input preface-connection) 46 | -------------------------------------------------------------------------------- /mod/lib/record.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/record.mo -------------------------------------------------------------------------------- /mod/lib/record.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (module "lib/record") 17 | (import "lib/object") 18 | 19 | ;;; (set-macro! define-record-type 20 | ;;; (lambda (record-name make-proto pred-name . record-fields) 21 | (define-macro (define-record-type record-name 22 | make-proto pred-name . record-fields) 23 | (let ((tc (make-tc))) 24 | (tc-append! tc (list 'define-class record-name ')) 25 | (tc-append! tc (list make-proto pred-name)) 26 | (tc-append! tc record-fields) 27 | (tc->list tc))) 28 | ;`(define-class ,record-name ,make-proto ,pred-name 29 | ; ,@record-fields)) 30 | 31 | 32 | (export define-record-type) 33 | -------------------------------------------------------------------------------- /mod/lib/repl.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/repl.mo -------------------------------------------------------------------------------- /mod/lib/repl.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | ; under the terms of the GNU Lesser General Public License, version 2.1 16 | ; as published by the Free Software Foundation. 17 | 18 | (module "lib/repl") 19 | 20 | (import "lib/optimize") 21 | (import "lib/compile") 22 | (import "lib/eval") 23 | (import "lib/trace") 24 | 25 | (define (repl-syntax-err err) 26 | (send (string-append "SYNTAX: " (car (error-info err)) 27 | *line-sep* ">> "))) 28 | 29 | (define (repl) 30 | (define done #f) 31 | 32 | (define input-buffer (make-string 80)) 33 | (define input-exprs (make-tc)) 34 | 35 | (define (read-exprs) 36 | (define data (wait)) 37 | 38 | (when (eq? data 'close) 39 | (set! done #t) 40 | (return)) 41 | 42 | (string-append! input-buffer data) 43 | 44 | (guard (function (catch-inc err) 45 | (unless (eq? (error-key err) 'inc) 46 | (re-error err)) 47 | (send ".. ") 48 | (read-exprs)) 49 | 50 | (tc-add! input-exprs (string->exprs input-buffer)) 51 | (set! input-buffer (make-string 80)))) 52 | 53 | (until done 54 | (send ">> ") 55 | (read-exprs) 56 | 57 | (until (tc-empty? input-exprs) 58 | (guard (lambda (x) (traceback x (current-output))) 59 | (define data (format (exec (tc-next! input-exprs)))) 60 | (send (string-append ":: " data *line-sep*)))))) 61 | 62 | (export repl) 63 | -------------------------------------------------------------------------------- /mod/lib/s-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/s-filter.mo -------------------------------------------------------------------------------- /mod/lib/s-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (module "lib/s-filter") 17 | (import "lib/filter") 18 | (import "lib/iterate") 19 | (import "lib/options") 20 | 21 | (define-option :prompt0) 22 | (define-option :promptN) 23 | (define-option :errfn) 24 | 25 | (export :prompt0 :promptN :errfn) 26 | 27 | (define-filter (s-filter . opts) 28 | (define prompt0 (option opts :prompt0 #f)) 29 | (define promptN (option opts :promptN #f)) 30 | (define errfn (option opts :errfn #f)) 31 | 32 | (define ct 0) 33 | (define buf (make-string 80)) 34 | 35 | (define (parse) 36 | (guard (function (handle-parse-err err) 37 | (define key (error-key err)) 38 | (define info (error-info err)) 39 | (case key 40 | ((inc) (string-append! buf *line-sep*)) 41 | ((and parse errfn) (errfn err) 42 | (flush-string buf)) 43 | (else (traceback err)))) 44 | (send-output (string->exprs buf) out) 45 | (flush-string buf))) 46 | 47 | (forever 48 | (cond 49 | ((empty-string? buf) (if prompt0 (send-output prompt0))) 50 | (promptN (send-output promptN))) 51 | 52 | (define next (wait-input in)) 53 | 54 | (if (string? next) 55 | (begin 56 | (string-append! buf next) 57 | (parse)) 58 | (send-output next out)))) 59 | 60 | (export s-filter) 61 | -------------------------------------------------------------------------------- /mod/lib/scud.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/scud.mo -------------------------------------------------------------------------------- /mod/lib/shuffle.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/shuffle.mo -------------------------------------------------------------------------------- /mod/lib/shuffle.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/shuffle") 18 | 19 | ; A Fisher-Yates Shuffle -- The F-Y shuffle is as strong as our PRNG, but 20 | ; expensive with containers that do not have constant time access. 21 | 22 | (define (shuffle/list l) 23 | (vector->list (shuffle/vector (list->vector l)))) 24 | 25 | (define (shuffle/vector v) 26 | (define left 0) 27 | (define last (- (vector-length v) 1)) 28 | (while (< left last) 29 | (define right (random-integer left last)) 30 | (define x (vector-ref v left)) 31 | (vector-set! v left (vector-ref v right)) 32 | (vector-set! v right x) 33 | (set! left (+ left 1))) 34 | v) 35 | 36 | (define (shuffle x) 37 | (if (list? x) 38 | (shuffle/list x) 39 | (shuffle/vector x))) 40 | 41 | -------------------------------------------------------------------------------- /mod/lib/socks-client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/socks-client.mo -------------------------------------------------------------------------------- /mod/lib/socks-server.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/socks-server.mo -------------------------------------------------------------------------------- /mod/lib/spawn-connection.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/spawn-connection.mo -------------------------------------------------------------------------------- /mod/lib/spawn-connection.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2008, Scott W. Dunlop 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (module "lib/spawn-connection") 17 | 18 | (define (spawn-connection func . rest) 19 | (define input-queue (make-queue)) 20 | (define output-queue (make-queue)) 21 | (define process 22 | (with-io (queue-input input-queue) 23 | (queue-output output-queue) 24 | (apply spawn func rest))) 25 | (make-connection (queue-input output-queue) (queue-output input-queue))) 26 | 27 | (export spawn-connection) 28 | 29 | -------------------------------------------------------------------------------- /mod/lib/tag-filter.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/tag-filter.mo -------------------------------------------------------------------------------- /mod/lib/tag-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/tag-filter") 18 | (import "lib/filter") 19 | 20 | (export tag-filter) 21 | 22 | ; TODO: This has some unexpected responses to fail and close.. 23 | (define-filter (tag-filter tag) 24 | (forever 25 | (send (cons tag (wait in)) out))) 26 | 27 | -------------------------------------------------------------------------------- /mod/lib/tcp-server.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/tcp-server.mo -------------------------------------------------------------------------------- /mod/lib/tcp-server.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "lib/tcp-server") 18 | (import "lib/with-io") 19 | 20 | (define (spawn-tcp-server portno fn . rest) 21 | (define server (serve-tcp portno)) 22 | (spawn (function (tcp-server) 23 | (forever 24 | (define conn (wait server)) 25 | (when (eq? conn 'close) (return)) 26 | 27 | (with-io (os-connection-input conn) 28 | (os-connection-output conn) 29 | (apply spawn fn rest))))) 30 | server) 31 | 32 | (export spawn-tcp-server) 33 | -------------------------------------------------------------------------------- /mod/lib/terminal.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/terminal.mo -------------------------------------------------------------------------------- /mod/lib/test.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/test.mo -------------------------------------------------------------------------------- /mod/lib/trace.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/trace.mo -------------------------------------------------------------------------------- /mod/lib/trace.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (module "lib/trace") 17 | (import "lib/filter") 18 | 19 | (define-macro (trace . stmts) 20 | `(guard (lambda (err) (disable-trace) 21 | (re-error err)) 22 | (enable-trace) 23 | (let ((%x (begin ,@stmts))) 24 | (disable-trace) 25 | %x))) 26 | 27 | (define-macro (trap . stmts) 28 | `(guard (lambda (err) err) ,@stmts)) 29 | 30 | (define-filter (trace-filter tag) 31 | (forever 32 | (define msg (wait-input in)) 33 | (println* tag ": " (format msg)) 34 | (send-output msg out))) 35 | 36 | (export trace trap trace-filter) 37 | -------------------------------------------------------------------------------- /mod/lib/url.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/url.mo -------------------------------------------------------------------------------- /mod/lib/waspc.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/waspc.mo -------------------------------------------------------------------------------- /mod/lib/waspc.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | ; 16 | 17 | ; Given a source file, or the input port, and a target file, or the output 18 | ; port, compiles and outputs a frozen file. 19 | 20 | (module "lib/waspc") 21 | 22 | (import "lib/compile") 23 | (import "lib/optimize") 24 | 25 | (define (waspc module) 26 | (define src-file #f) 27 | (define dst-file #f) 28 | 29 | (cond 30 | ((string-ends-with? module ".ms") 31 | (set! src-file module) 32 | (set! module (string-head module (- (string-length module) 3)))) 33 | ((string-ends-with? module ".scm") 34 | (set! src-file module) 35 | (set! module (string-head module (- (string-length module) 4)))) 36 | (else 37 | (set! src-file (string-append module ".ms")))) 38 | 39 | ;; Only WASPVM can produce object files. 40 | 41 | (if *waspvm?* 42 | (set! dst-file (string-append module ".mo")) 43 | (set! dst-file (string-append module ".ma"))) 44 | 45 | (let ((data (read-lisp-file src-file))) 46 | (set! data (compile data)) 47 | (set! data (optimize data)) 48 | 49 | (cond 50 | (*waspvm?* 51 | (set! data (assemble data)) 52 | (set! data (freeze data)) 53 | (write-data-file dst-file data)) 54 | (else 55 | (set! dst-file (open-output-file dst-file)) 56 | (for-each (lambda (item) 57 | (write item dst-file) 58 | (newline dst-file)) 59 | data) 60 | (close-output-port dst-file))))) 61 | 62 | (export waspc) 63 | -------------------------------------------------------------------------------- /mod/lib/with-io.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/lib/with-io.mo -------------------------------------------------------------------------------- /mod/lib/with-io.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (module "lib/with-io") 17 | 18 | ;;TODO:WASPVM:PORT: This needs a multimethod, input and output, that can determine 19 | ;; the input and output of various objects. 20 | 21 | (define (do-with-io new-input new-output func) 22 | (let ((old-input (current-input)) 23 | (old-output (current-output))) 24 | (define (reset) 25 | (set-current-input! old-input) 26 | (set-current-output! old-output)) 27 | (define result 28 | (guard (lambda (e) 29 | (reset) 30 | (re-error e)) 31 | (set-current-input! (input new-input)) 32 | (set-current-output! (output new-output)) 33 | (func))) 34 | (reset) 35 | result)) 36 | 37 | (define (do-with-input new-input func) 38 | (let ((old-input (current-input))) 39 | (define (reset) 40 | (set-current-input! old-input)) 41 | (define result 42 | (guard (lambda (e) 43 | (reset) 44 | (re-error e)) 45 | (set-current-input! (input new-input)) 46 | (func))) 47 | (reset) 48 | result)) 49 | 50 | (define (do-with-output new-output func) 51 | (let ((old-output (current-output))) 52 | (define (reset) 53 | (set-current-output! old-output)) 54 | (define result 55 | (guard (lambda (e) 56 | (reset) 57 | (re-error e)) 58 | (set-current-output! (output new-output)) 59 | (func))) 60 | (reset) 61 | result)) 62 | 63 | (define-macro (with-io input output . body) 64 | (list 'do-with-io input output (apply list 'function '(inner-io-func) body))) 65 | 66 | (define-macro (with-input input . body) 67 | (list 'do-with-input input 68 | (apply list 'function '(inner-input-func) body))) 69 | 70 | (define-macro (with-output output . body) 71 | (list 'do-with-output output 72 | (apply list 'function '(inner-output-func) body))) 73 | 74 | (export do-with-io with-io do-with-input do-with-output 75 | with-input with-output) 76 | 77 | -------------------------------------------------------------------------------- /mod/local-config.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/local-config.mo -------------------------------------------------------------------------------- /mod/local-config.ms: -------------------------------------------------------------------------------- 1 | (set-site-config! 'stub-path '"../stubs") 2 | (set-site-config! 'mod-path '(".")) 3 | -------------------------------------------------------------------------------- /mod/mosref/cmd/clear.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/clear.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/clear.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/clear") 18 | (import "mosref/shell") 19 | (import "mosref/node") 20 | 21 | (define-cmd "clear" 22 | "clear ..." 23 | (string-append 24 | "Resets zero or more properties on the current node to their" 25 | " default value.") 26 | 27 | (define node (mosref-shell-node shell)) 28 | (define count 0) 29 | (until (tc-empty? terms) 30 | (clear-node-prop! node (resolve-key (tc-next! terms))) 31 | (set! count (+ count 1))) 32 | (send-line (case count 33 | ((0) "No properties cleared.") 34 | ((1) "Property cleared.") 35 | (else (string-append (format count) " properties cleared."))))) 36 | 37 | -------------------------------------------------------------------------------- /mod/mosref/cmd/cp.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/cp.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/do.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/do.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/drone.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/drone.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/exit.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/exit.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/exit.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/exit") 18 | (import "mosref/shell") 19 | 20 | (define-cmd "exit" 21 | "exit" 22 | "Terminates the current shell session." 23 | 24 | (set-mosref-shell-running! shell #f)) 25 | 26 | -------------------------------------------------------------------------------- /mod/mosref/cmd/exploit.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/exploit.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/exploit.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/exit") 18 | (import "mosref/shell") 19 | 20 | (define-cmd "exploit" 21 | "exploit ..." 22 | (string-append 23 | "Constructs a drone with id , and , then" 24 | " attempts to deploy the drone via the specified exploit. This" 25 | " command requires exploit and shellcode modules that are not" 26 | " distributed with MOSREF." 27 | "\n\n" 28 | "Get your own, scavengers.") 29 | 30 | (define id (req-term terms " drone identifier")) 31 | (define platform (req-term terms " drone platform")) 32 | (define exploit (req-term terms " exploit identifier")) 33 | (define exploit-args (tc->list terms exploit)) 34 | 35 | (define node (mosref-shell-node shell)) 36 | (define ecdh (make-console-ecdh)) 37 | (define addr (node-addr node)) 38 | (unless addr 39 | (send-err " node address unknown, use set addr to assign one")) 40 | 41 | (define portno (node-port node)) 42 | (define sin (node-make-sin node portno)) 43 | (define data (guard (lambda (e) 44 | (send-err "Could not compile drone.")) 45 | (make-drone-exe addr sin portno ecdh platform))) 46 | (run-exploit data exploit exploit-args)) 47 | 48 | -------------------------------------------------------------------------------- /mod/mosref/cmd/fork.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/fork.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/fork.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2012, Chris Double 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/fork") 18 | (import "mosref/shell") 19 | (import "mosref/node") 20 | (import "lib/terminal") 21 | 22 | (define-cmd "fork" 23 | "fork []" 24 | (string-append 25 | "Creates a new MOSREF console shell session that may be used" 26 | " in parallel with the current one.\n\n") 27 | 28 | (define conn (spawn-terminal 29 | (if (tc-empty? terms) 30 | "MOSREF" 31 | (tc-next! terms)))) 32 | (with-io (os-connection-input conn) 33 | (os-connection-output conn) 34 | 35 | (define console (mosref-shell-console shell)) 36 | (define node (mosref-shell-node shell)) 37 | (spawn (lambda () (run-mosref-shell console node))))) 38 | 39 | -------------------------------------------------------------------------------- /mod/mosref/cmd/help.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/help.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/help.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/help") 18 | (import "mosref/shell") 19 | 20 | (define-cmd "help" 21 | "help []" 22 | (string-append 23 | "If no command is suppled, help will list all of the commands" 24 | " currently recognized by the shell, and their usage. If a" 25 | " a command is supplied, help will provide more detailed" 26 | " information about the command.") 27 | 28 | (when (tc-empty? terms) 29 | (send-line "Commands: " 30 | (apply string-join "\n " 31 | (map mosref-cmd-usage (mosref-cmds)))) 32 | (return)) 33 | 34 | (define verb (tc-next! terms)) 35 | (define cmd (find-mosref-cmd verb)) 36 | 37 | (unless cmd (send-err "Command " (format verb) " not found.")) 38 | 39 | (send (string-append "\n" (mosref-cmd-usage cmd) "\n\n" 40 | (mosref-cmd-info cmd) "\n\n"))) 41 | 42 | -------------------------------------------------------------------------------- /mod/mosref/cmd/load.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/load.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/load.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/load") 18 | (import "mosref/shell") 19 | (import "mosref/cmd/do") 20 | 21 | (define-cmd "load" 22 | "load " 23 | (string-append 24 | "Loads the Mosquito Lisp source file, compiles it, then transmits" 25 | " the resulting program to the current node for execution.") 26 | 27 | (define file-name (req-term terms "lisp file name")) 28 | 29 | (guard (lambda (err) 30 | (send-err "Could not read lisp file " (format file-name) ", " 31 | (cadr (error-info err)))) 32 | (define expr (read-lisp-file file-name))) 33 | 34 | (eval-node-expr (mosref-shell-node shell) expr)) 35 | 36 | -------------------------------------------------------------------------------- /mod/mosref/cmd/nodes.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/nodes.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/nodes.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/nodes") 18 | (import "mosref/shell") 19 | (import "mosref/node") 20 | 21 | (define-cmd "nodes" 22 | "nodes" 23 | "Lists the nodes currently known to the console." 24 | 25 | (send-line "NODES: " 26 | (apply string-join "\n " 27 | (map (function (format-node node) 28 | (define addr (node-addr node)) 29 | (define port (and (node-has-port? node) 30 | (node-port node))) 31 | (string-append 32 | (node-id node) 33 | (if (node-online node) " online" " offline") 34 | (if addr (string-append 35 | " address: " (format-addr addr)) 36 | "") 37 | (if port (string-append 38 | " port: " (format port)) 39 | ""))) 40 | (list-mosref-nodes))))) 41 | 42 | -------------------------------------------------------------------------------- /mod/mosref/cmd/on.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/on.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/on.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/on") 18 | (import "mosref/shell") 19 | 20 | (define-cmd "on" 21 | "on []" 22 | (string-append 23 | "Instructs the console to perform subsequent commands on the" 24 | " specified node. If an optional command is included, only that" 25 | " command will be performed on that node before returning to the" 26 | " current node.") 27 | 28 | (define node (req-node terms "")) 29 | (define old-node (mosref-shell-node shell)) 30 | 31 | (set-mosref-shell-node! shell node) 32 | 33 | (define (revert-node) (set-mosref-shell-node! shell old-node)) 34 | 35 | (unless (tc-empty? terms) 36 | (guard (function (revert-node-before-err err) 37 | (revert-node) 38 | (re-error err)) 39 | (do-mosref-cmd shell terms) 40 | (revert-node)))) 41 | 42 | -------------------------------------------------------------------------------- /mod/mosref/cmd/proxy.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/proxy.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/recover.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/recover.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/recover.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/recover") 18 | 19 | (import "mosref/shell") 20 | (import "mosref/node") 21 | (import "mosref/listener") 22 | (import "mosref/cmd/drone") 23 | 24 | (define-cmd "recover" 25 | "recover " 26 | (string-append 27 | "If the specified node is currently offline, and the node it" 28 | " affiliates to is currently online, directs the listening node" 29 | " to once again listen for the drone. While this is useful for" 30 | " drones that have been terminated abruptly, it can greatly" 31 | " simplify man in the middle attacks and should be used" 32 | " carefully.") 33 | 34 | (define id (req-term terms " drone identifier")) 35 | (define next (find-mosref-node id)) 36 | 37 | (unless (drone-node? next) 38 | (send-err "Drone node " (format id) " not found.")) 39 | 40 | (when (node-online next) 41 | (send-err "Drone is still online, and cannot be recovered.")) 42 | 43 | (define node (drone-node-link next)) 44 | (unless (node-online node) 45 | (send-err "Intermediate node " (format (node-id node)) " is not online.")) 46 | 47 | ;TODO: (define ecdh (make-console-ecdh)) Unnecessary? 48 | 49 | (spawn-drone-listener node next)) 50 | 51 | -------------------------------------------------------------------------------- /mod/mosref/cmd/set.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/set.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/set.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/set") 18 | 19 | (import "mosref/shell") 20 | (import "mosref/node") 21 | (import "mosref/props") 22 | 23 | (define-cmd "set" 24 | "set [[=] []]" 25 | (string-append 26 | "If no key is supplied, lists properties associated with the" 27 | " current node. If a key and value is supplied, assigns the" 28 | " supplied value to the key, for the current node. If only" 29 | " the key is supplied, the value is assumed to be \"true\"." 30 | "\n\n" 31 | "If a command is furnished, in addition to a key, it will be" 32 | "performed after the property has been updated." 33 | "\n\n" 34 | "The word 'set' may be omitted, if the key=value form is used.") 35 | 36 | (define node (mosref-shell-node shell)) 37 | (define key-val (opt-term terms)) 38 | (define command (if (and key-val (not (tc-empty? terms))) terms #f)) 39 | 40 | (when key-val 41 | (set! key-val (parse-property key-val))) 42 | 43 | (cond (command (set-node-prop! node @key-val) 44 | (do-mosref-cmd shell command)) 45 | (key-val (set-node-prop! node @key-val) 46 | (send-line "Set.")) 47 | (else (send-line "Properties: " 48 | (apply string-join "\n " 49 | (map format-property 50 | (list-node-props node))))))) 51 | 52 | (define (format-property key-val) 53 | (define key (car key-val)) 54 | (define val (cdr key-val)) 55 | (string-append (format key) " = " (format-propval key val))) 56 | 57 | (define (parse-property key-val) 58 | (set! key-val (string-split key-val "=")) 59 | (define key (resolve-key (car key-val))) 60 | (define val (if (null? (cdr key-val)) #t 61 | (cadr key-val))) 62 | (set! val (validate-prop key val)) 63 | (list key val)) 64 | 65 | (export format-property parse-property) 66 | -------------------------------------------------------------------------------- /mod/mosref/cmd/sh.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/sh.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/with.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmd/with.mo -------------------------------------------------------------------------------- /mod/mosref/cmd/with.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmd/set") 18 | (import "mosref/shell") 19 | (import "mosref/node") 20 | (import "mosref/props") 21 | 22 | (define-cmd "with" 23 | "with [=] []" 24 | "Performs the supplied command with key temporarily set to value." 25 | 26 | (define node (mosref-shell-node shell)) 27 | 28 | (define key-val (parse-property (req-term terms))) 29 | (define key (car key-val)) 30 | 31 | (define command terms) 32 | 33 | (define was-set (has-node-prop? node key)) 34 | (define old-val (if was-set (find-node-prop node key))) 35 | 36 | (set-node-prop! node @key-val) 37 | (do-mosref-cmd shell command) 38 | (if was-set (set-node-prop! node key old-val) 39 | (clear-node-prop! node key))) 40 | 41 | -------------------------------------------------------------------------------- /mod/mosref/cmds.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/cmds.mo -------------------------------------------------------------------------------- /mod/mosref/cmds.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/cmds") 18 | (import "mosref/cmd/clear") 19 | (import "mosref/cmd/cp") 20 | (import "mosref/cmd/do") 21 | (import "mosref/cmd/drone") 22 | (import "mosref/cmd/exit") 23 | (import "mosref/cmd/fork") 24 | (import "mosref/cmd/help") 25 | (import "mosref/cmd/load") 26 | (import "mosref/cmd/nodes") 27 | (import "mosref/cmd/on") 28 | (import "mosref/cmd/proxy") 29 | (import "mosref/cmd/recover") 30 | ;(import "mosref/cmd/scan") 31 | (import "mosref/cmd/set") 32 | (import "mosref/cmd/sh") 33 | (import "mosref/cmd/with") 34 | 35 | -------------------------------------------------------------------------------- /mod/mosref/console.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/console.mo -------------------------------------------------------------------------------- /mod/mosref/drone.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/drone.mo -------------------------------------------------------------------------------- /mod/mosref/format.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/format.mo -------------------------------------------------------------------------------- /mod/mosref/format.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/format") 18 | 19 | (define (format-ipv4 i) 20 | (unless i (return "unknown")) 21 | 22 | (define (ub i) 23 | (if (< i 0) (+ i 256) i)) 24 | 25 | (define buf (make-string 16)) 26 | (string-append! buf (format (ub (>> i 24)))) 27 | (string-append! buf ".") 28 | (set! i (& i $FFFFFF)) 29 | (string-append! buf (format (>> i 16))) 30 | (string-append! buf ".") 31 | (set! i (& i $FFFF)) 32 | (string-append! buf (format (>> i 8))) 33 | (string-append! buf ".") 34 | (set! i (& i $FF)) 35 | (string-append! buf (format i)) 36 | buf) 37 | 38 | (define (format-path path) 39 | (string-append (node-id (car path)) ":" (cadr path))) 40 | 41 | (export format-ipv4 format-path) 42 | 43 | (define (send-line . items) 44 | (send (string-append @items *line-sep*))) 45 | 46 | (define (send-err . items) 47 | (apply send-line "ERROR: " items) 48 | (error 'syn)) 49 | 50 | (export send-line send-err ) 51 | 52 | (define (format-addr addr) 53 | (if (integer? addr) (format-ipv4 addr) addr)) 54 | 55 | (export format-addr) 56 | 57 | (define (format-flag flag) 58 | (if flag "true" "false")) 59 | 60 | (export format-flag) 61 | -------------------------------------------------------------------------------- /mod/mosref/listener.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/listener.mo -------------------------------------------------------------------------------- /mod/mosref/node.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/node.mo -------------------------------------------------------------------------------- /mod/mosref/parse.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/parse.mo -------------------------------------------------------------------------------- /mod/mosref/prop/address.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/prop/address.mo -------------------------------------------------------------------------------- /mod/mosref/prop/address.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/prop/address") 18 | 19 | (import "mosref/node") 20 | (import "mosref/parse") 21 | (import "mosref/format") 22 | 23 | (define-prop (address addr) 24 | doc: "Assigns an IPv4 or DNS address to the node. This address" 25 | " will be used when a drone attempts to affiliate with the" 26 | " node." 27 | "\n\n" 28 | "Drones resolve these addresses at initialization, so any" 29 | " DNS addresses must be valid for resolution for the drone's" 30 | " host environment." 31 | valid: (unless (or (string? value) 32 | (integer? value)) 33 | (send-err "Expected DNS or IPv4 address, " 34 | (format value) ".")) 35 | value 36 | format: (format-addr value)) 37 | 38 | (define (node-addr node) (find-node-prop node 'address)) 39 | (define (set-node-addr! node value) (set-node-prop! node 'address value)) 40 | 41 | (export node-addr set-node-addr!) 42 | -------------------------------------------------------------------------------- /mod/mosref/prop/online.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/prop/online.mo -------------------------------------------------------------------------------- /mod/mosref/prop/online.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/prop/online") 18 | 19 | (import "mosref/node") 20 | (import "mosref/parse") 21 | (import "mosref/format") 22 | 23 | (define-prop (online onlineno pn) 24 | doc: "Determines whether a node is considered to be online and" 25 | " accessible by the console or other nodes. This is normally" 26 | " updated as network disconnects are detected and drones" 27 | " affiliate." 28 | 29 | valid: (cond ((string? value) (parse-flag value)) 30 | ((boolean? value) value) 31 | (else 32 | (send-err "Expected a flag, not " (format value) 33 | "."))) 34 | format: (format-flag value)) 35 | 36 | (define (node-online node) (find-node-prop node 'online)) 37 | 38 | (define (set-node-online! node value) (set-node-prop! node 'online value)) 39 | 40 | (export node-online set-node-online!) 41 | -------------------------------------------------------------------------------- /mod/mosref/prop/platform.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/prop/platform.mo -------------------------------------------------------------------------------- /mod/mosref/prop/platform.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/prop/platform") 18 | 19 | (import "lib/build") 20 | (import "mosref/node") 21 | (import "mosref/parse") 22 | (import "mosref/format") 23 | 24 | (define-prop (platform plat pl) 25 | doc: "Designates the MOSVM platform for the specified host; this" 26 | " property determines what variant of the Mosquito virtual" 27 | " machine will be employed when constructing an executable" 28 | " for the drone's host environment." 29 | 30 | valid: (unless (string? value) 31 | (send-err "expected a platform string, not " 32 | (format value) ".")) 33 | (or (read-platform-stub value) 34 | (send-err "the console does not have a stub for " 35 | value "."))) 36 | 37 | 38 | (define (node-platform node) (find-node-prop node 'platform)) 39 | 40 | (define (set-node-platform! node value) (set-node-prop! node 'platform value)) 41 | 42 | (export node-platform set-node-platform!) 43 | -------------------------------------------------------------------------------- /mod/mosref/prop/port.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/prop/port.mo -------------------------------------------------------------------------------- /mod/mosref/prop/port.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/prop/port") 18 | 19 | (import "mosref/node") 20 | (import "mosref/parse") 21 | (import "mosref/format") 22 | 23 | (define-prop (port portno pn) 24 | doc: "Assigns a TCP port for incoming DCNR sessions. Drones that" 25 | " need to contact the node will attempt to contact this port." 26 | "\n\n" 27 | "The node will only listen to this port when it is informed" 28 | " that one or more drones are expected to affiliate with the" 29 | " node. If a port has not been assigned, a random one will" 30 | " be assigned, in the range 10000 to 30000, inclusive." 31 | "\n\n" 32 | 33 | valid: (unless (or (string? value) 34 | (integer? value)) 35 | (send-err "Expected a port number, not " 36 | (format value) ".")) 37 | (parse-port value)) 38 | 39 | (define (node-port node) 40 | (define x (find-node-prop node 'port)) 41 | (unless x 42 | (set! x (random-integer 10000 30000)) 43 | (set-node-port! node x)) 44 | x) 45 | 46 | (define (set-node-port! node value) (set-node-prop! node 'port value)) 47 | 48 | (define (node-has-port? node) (has-node-prop? node 'port)) 49 | 50 | (export node-port set-node-port! node-has-port?) 51 | -------------------------------------------------------------------------------- /mod/mosref/props.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/props.mo -------------------------------------------------------------------------------- /mod/mosref/props.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License, version 2.1 6 | ; as published by the Free Software Foundation. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | (module "mosref/props") 18 | 19 | (import "mosref/prop/address") 20 | (import "mosref/prop/online") 21 | (import "mosref/prop/platform") 22 | (import "mosref/prop/port") 23 | 24 | -------------------------------------------------------------------------------- /mod/mosref/shell.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/shell.mo -------------------------------------------------------------------------------- /mod/mosref/transport.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/mosref/transport.mo -------------------------------------------------------------------------------- /mod/site/dont-delete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/site/dont-delete -------------------------------------------------------------------------------- /mod/waspc.mf: -------------------------------------------------------------------------------- 1 | core/macro.mo core/config.mo site/config.mo core/file.mo core/module.mo core/io.mo lib/module.mo lib/iterate.mo lib/object.mo lib/record.mo lib/compile.mo lib/optimize.mo lib/eval.mo lib/waspc.mo lib/build.mo bin/waspc.mo 2 | -------------------------------------------------------------------------------- /mod/waspdoc/base.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/waspdoc/base.mo -------------------------------------------------------------------------------- /mod/waspdoc/base.ms: -------------------------------------------------------------------------------- 1 | (module "waspdoc/base.ms") 2 | 3 | (define *waspdoc-root* ".") 4 | (define (waspdoc-root) *waspdoc-root*) 5 | (define (set-waspdoc-root! path) 6 | (set! *waspdoc-root* path)) 7 | 8 | (export set-waspdoc-root! waspdoc-root) 9 | 10 | -------------------------------------------------------------------------------- /mod/waspdoc/c-file.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/waspdoc/c-file.mo -------------------------------------------------------------------------------- /mod/waspdoc/c-file.ms: -------------------------------------------------------------------------------- 1 | (module "waspdoc/c-file") 2 | (import "waspdoc/source") 3 | 4 | (define (waspdoc-scan-c path) 5 | (define name (substring path 0 (- (string-length path) 2))) 6 | (define id (path->id name)) ;;TODO: Where do we get path->id ? 7 | 8 | (define func-defns (make-tc)) 9 | (define type-defns (make-tc)) 10 | (define exported (make-dict)) 11 | 12 | (define source (make-waspdoc-source id name (make-set) exported)) 13 | 14 | (define lines (split-lines (read-data-file path))) 15 | 16 | (define (scan-c-line line) 17 | TODO) 18 | 19 | (for-each scan-c-line lines) 20 | 21 | source) 22 | 23 | (export waspdoc-scan-c) 24 | -------------------------------------------------------------------------------- /mod/waspdoc/check-source.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/waspdoc/check-source.mo -------------------------------------------------------------------------------- /mod/waspdoc/dump-source.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/waspdoc/dump-source.mo -------------------------------------------------------------------------------- /mod/waspdoc/dump-source.ms: -------------------------------------------------------------------------------- 1 | (module "waspdoc/dump-source") 2 | 3 | (import "waspdoc/ms-file") 4 | (import "waspdoc/dump") 5 | 6 | (define (dump-source path) 7 | ;TODO 8 | ;(when (string-ends-with? path ".c") 9 | ; (dump-waspdoc-source (waspdoc-scan-c path))) 10 | 11 | (unless (path-exists? path) 12 | (send (string-append "Cannot scan \"" path "\", cannot find file.\n")) 13 | (return)) 14 | 15 | (when (string-ends-with? path ".ms") 16 | (dump-waspdoc-source (waspdoc-scan-ms path)) 17 | (return)) 18 | 19 | (send (string-append "Cannot dump informaton from \"" path 20 | "\", unrecognized file type.\n"))) 21 | 22 | (define (dump-module name) 23 | (dump-source (find-module-file (if (string-ends-with? name ".ms") 24 | name 25 | (string-append name ".ms"))))) 26 | 27 | (export dump-source dump-module) 28 | -------------------------------------------------------------------------------- /mod/waspdoc/dump.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/waspdoc/dump.mo -------------------------------------------------------------------------------- /mod/waspdoc/dump.ms: -------------------------------------------------------------------------------- 1 | (module "waspdoc/dump") 2 | 3 | (define (send-line . items) 4 | (send (string-append @items "\n"))) 5 | 6 | (define (normalize-formal-arg arg) 7 | (unless (pair? arg) (return arg)) 8 | (unless (= (length arg) 2) (return arg)) 9 | (unless (eq? (car arg) #t) (return arg)) 10 | (cadr arg)) 11 | 12 | (define (format-formals formals) 13 | (define buf (make-string 32)) 14 | (string-append! buf "(" (format (car formals))) 15 | (set! formals (cdr formals)) 16 | 17 | (forever 18 | (when (null? formals) 19 | (string-append! buf ")") 20 | (return buf)) 21 | 22 | (string-append! buf " ") 23 | 24 | (unless (list? formals) 25 | (string-append! buf (format formals)) 26 | (string-append! buf " ...)") 27 | (return buf)) 28 | 29 | (string-append! buf (format (normalize-formal-arg (car formals)))) 30 | 31 | (set! formals (cdr formals)))) 32 | 33 | (define (format-defn ( defn)) 34 | (waspdoc-defn-id defn)) 35 | 36 | ;; Shouldn't be necessary, but it is.. 37 | (define (format-defn ( defn)) 38 | (string-append "<" (waspdoc-defn-id defn) ">")) 39 | 40 | (export format-defn) 41 | 42 | (define (format-defn ( defn)) 43 | (format-formals (waspdoc-func-defn-formals defn))) 44 | 45 | (define (dump-waspdoc-source src) 46 | (send-line "MODULE: " (waspdoc-source-name src)) 47 | (send-line "IMPORTS: " (apply string-join ", " 48 | (set->list (waspdoc-source-imports src)))) 49 | (send-line "EXPORTS: " (apply string-join "\n " 50 | (map format-defn 51 | (map cadr 52 | (list-waspdoc-source-exports src)))))) 53 | 54 | (export dump-waspdoc-source) 55 | 56 | -------------------------------------------------------------------------------- /mod/waspdoc/ms-file.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/waspdoc/ms-file.mo -------------------------------------------------------------------------------- /mod/waspdoc/source.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/mod/waspdoc/source.mo -------------------------------------------------------------------------------- /mod/waspdoc/source.ms: -------------------------------------------------------------------------------- 1 | (module "waspdoc/source") 2 | (import "lib/object") 3 | 4 | (define-class waspdoc-source 5 | (make-waspdoc-source id name imports exports) 6 | waspdoc-source? 7 | 8 | (id waspdoc-source-id) 9 | (name waspdoc-source-name) 10 | (imports waspdoc-source-imports) 11 | (exports waspdoc-source-exports)) 12 | 13 | (export make-waspdoc-source waspdoc-source? 14 | waspdoc-source-imports waspdoc-source-id waspdoc-source-name 15 | waspdoc-source-exports) 16 | 17 | (define-class waspdoc-defn 18 | (make-waspdoc-defn source id) 19 | waspdoc-defn? 20 | 21 | (id waspdoc-defn-id) 22 | (source waspdoc-defn-source)) 23 | 24 | (export make-waspdoc-defn waspdoc-defn? 25 | waspdoc-defn-id waspdoc-defn-source) 26 | 27 | ;; Shouldn't have to redefine id and source.. 28 | (define-class waspdoc-type-defn 29 | (make-waspdoc-type-defn source id) 30 | waspdoc-type-defn? 31 | 32 | (id waspdoc-defn-id) 33 | (source waspdoc-defn-source)) 34 | 35 | (export make-waspdoc-type-defn waspdoc-type-defn? 36 | waspdoc-type-defn-id waspdoc-type-defn-source) 37 | 38 | ;; Shouldn't have to redefine id and source.. 39 | (define-class waspdoc-func-defn 40 | (make-waspdoc-func-defn source id formals) 41 | waspdoc-func-defn? 42 | 43 | (source waspdoc-defn-source) 44 | (id waspdoc-defn-id) 45 | (formals waspdoc-func-defn-formals)) 46 | 47 | (export make-waspdoc-func-defn waspdoc-func-defn? 48 | waspdoc-func-defn-formals) 49 | 50 | (define (add-waspdoc-source-export! source defn) 51 | (define id (waspdoc-defn-id defn)) 52 | (define exports (waspdoc-source-exports source)) 53 | (define defns (dict-ref exports id '())) 54 | 55 | (dict-set! exports id (cons defn defns))) 56 | 57 | (define (list-waspdoc-source-exports source) 58 | (dict->list (waspdoc-source-exports source))) 59 | 60 | (export add-waspdoc-source-export! list-waspdoc-source-exports) 61 | 62 | (define rx-morsel (make-regex "[A-Za-z0-9]+")) 63 | 64 | (define (name->id name) 65 | (when (symbol? name) 66 | (set! name (symbol->string name))) 67 | 68 | (define id (apply string-join "-" (match-regex* rx-morsel name))) 69 | (when (string-ends-with? name "?") 70 | (string-append! id "q")) 71 | id) 72 | 73 | (define (path->id path) 74 | (when (symbol? path) 75 | (set! path (symbol->string path))) 76 | 77 | (apply string-join "-" (match-regex* rx-morsel path))) 78 | 79 | (export path->id name->id) 80 | 81 | -------------------------------------------------------------------------------- /package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test z$1 = z; then 4 | echo "USAGE: package.sh " 5 | echo "This should only be used by invoking \"make package\", and then" 6 | echo "only on Windows or other non-UNIX platforms." 7 | fi 8 | 9 | OS=`uname -s | sed -e 's:[_-].*$::'` 10 | 11 | if test z$OS = zMINGW32; then 12 | EXE=.exe 13 | else 14 | EXE= 15 | fi 16 | 17 | PLATFORM=$1 18 | PKGDIR=$2 19 | WASPVM=waspvm-$PLATFORM$EXE 20 | 21 | rm -rf $PKGDIR 22 | mkdir -pm 0755 $PKGDIR 23 | cp -rf mod/* $PKGDIR 24 | cp -rf stubs/$WASPVM $PKGDIR 25 | rm $PKGDIR/local-* $(find $PKGDIR -name '*.mf') 26 | cd $PKGDIR 27 | 28 | cat >site/config.ms <. 13 | 14 | The "fake" directory contains quick-and-dirty fakes for some header 15 | files and routines that old systems may not have. Note also that 16 | -DUSEBCOPY will make utils.h substitute bcopy() for memmove(). 17 | 18 | After that, "make r" will build regcomp.o, regexec.o, regfree.o, 19 | and regerror.o (the actual routines), bundle them together into a test 20 | program, and run regression tests on them. No output is good output. 21 | 22 | "make lib" builds just the .o files for the actual routines (when 23 | you're happy with testing and have adjusted CFLAGS for production), 24 | and puts them together into libregex.a. You can pick up either the 25 | library or *.o ("make lib" makes sure there are no other .o files left 26 | around to confuse things). 27 | 28 | Main.c, debug.c, split.c are used for regression testing but are not part 29 | of the RE routines themselves. 30 | 31 | Regex.h goes in /usr/include. All other .h files are internal only. 32 | -------- 33 | -------------------------------------------------------------------------------- /rx/cclass.h: -------------------------------------------------------------------------------- 1 | /* character-class table */ 2 | static struct cclass { 3 | char *name; 4 | char *chars; 5 | char *multis; 6 | } cclasses[] = { 7 | "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 8 | 0123456789", "", 9 | "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 | "", 11 | "blank", " \t", "", 12 | "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ 13 | \25\26\27\30\31\32\33\34\35\36\37\177", "", 14 | "digit", "0123456789", "", 15 | "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 16 | 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", 17 | "", 18 | "lower", "abcdefghijklmnopqrstuvwxyz", 19 | "", 20 | "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 21 | 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", 22 | "", 23 | "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", 24 | "", 25 | "space", "\t\n\v\f\r ", "", 26 | "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 27 | "", 28 | "xdigit", "0123456789ABCDEFabcdef", 29 | "", 30 | NULL, 0, "" 31 | }; 32 | -------------------------------------------------------------------------------- /rx/cname.h: -------------------------------------------------------------------------------- 1 | /* character-name table */ 2 | static struct cname { 3 | char *name; 4 | char code; 5 | } cnames[] = { 6 | "NUL", '\0', 7 | "SOH", '\001', 8 | "STX", '\002', 9 | "ETX", '\003', 10 | "EOT", '\004', 11 | "ENQ", '\005', 12 | "ACK", '\006', 13 | "BEL", '\007', 14 | "alert", '\007', 15 | "BS", '\010', 16 | "backspace", '\b', 17 | "HT", '\011', 18 | "tab", '\t', 19 | "LF", '\012', 20 | "newline", '\n', 21 | "VT", '\013', 22 | "vertical-tab", '\v', 23 | "FF", '\014', 24 | "form-feed", '\f', 25 | "CR", '\015', 26 | "carriage-return", '\r', 27 | "SO", '\016', 28 | "SI", '\017', 29 | "DLE", '\020', 30 | "DC1", '\021', 31 | "DC2", '\022', 32 | "DC3", '\023', 33 | "DC4", '\024', 34 | "NAK", '\025', 35 | "SYN", '\026', 36 | "ETB", '\027', 37 | "CAN", '\030', 38 | "EM", '\031', 39 | "SUB", '\032', 40 | "ESC", '\033', 41 | "IS4", '\034', 42 | "FS", '\034', 43 | "IS3", '\035', 44 | "GS", '\035', 45 | "IS2", '\036', 46 | "RS", '\036', 47 | "IS1", '\037', 48 | "US", '\037', 49 | "space", ' ', 50 | "exclamation-mark", '!', 51 | "quotation-mark", '"', 52 | "number-sign", '#', 53 | "dollar-sign", '$', 54 | "percent-sign", '%', 55 | "ampersand", '&', 56 | "apostrophe", '\'', 57 | "left-parenthesis", '(', 58 | "right-parenthesis", ')', 59 | "asterisk", '*', 60 | "plus-sign", '+', 61 | "comma", ',', 62 | "hyphen", '-', 63 | "hyphen-minus", '-', 64 | "period", '.', 65 | "full-stop", '.', 66 | "slash", '/', 67 | "solidus", '/', 68 | "zero", '0', 69 | "one", '1', 70 | "two", '2', 71 | "three", '3', 72 | "four", '4', 73 | "five", '5', 74 | "six", '6', 75 | "seven", '7', 76 | "eight", '8', 77 | "nine", '9', 78 | "colon", ':', 79 | "semicolon", ';', 80 | "less-than-sign", '<', 81 | "equals-sign", '=', 82 | "greater-than-sign", '>', 83 | "question-mark", '?', 84 | "commercial-at", '@', 85 | "left-square-bracket", '[', 86 | "backslash", '\\', 87 | "reverse-solidus", '\\', 88 | "right-square-bracket", ']', 89 | "circumflex", '^', 90 | "circumflex-accent", '^', 91 | "underscore", '_', 92 | "low-line", '_', 93 | "grave-accent", '`', 94 | "left-brace", '{', 95 | "left-curly-bracket", '{', 96 | "vertical-line", '|', 97 | "right-brace", '}', 98 | "right-curly-bracket", '}', 99 | "tilde", '~', 100 | "DEL", '\177', 101 | NULL, 0, 102 | }; 103 | -------------------------------------------------------------------------------- /rx/fake/limits.h: -------------------------------------------------------------------------------- 1 | #define _POSIX2_RE_DUP_MAX 255 2 | #define CHAR_MIN (-128) 3 | #define CHAR_MAX 127 4 | #define CHAR_BIT 8 5 | -------------------------------------------------------------------------------- /rx/fake/memmove.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* 6 | - memmove - fake ANSI C routine 7 | */ 8 | char * 9 | memmove(dst, src, count) 10 | char *dst; 11 | char *src; 12 | size_t count; 13 | { 14 | register char *s; 15 | register char *d; 16 | register size_t n; 17 | 18 | if (dst > src) 19 | for (d = dst+count, s = src+count, n = count; n > 0; n--) 20 | *--d = *--s; 21 | else 22 | for (d = dst, s = src, n = count; n > 0; n--) 23 | *d++ = *s++; 24 | 25 | return(dst); 26 | } 27 | -------------------------------------------------------------------------------- /rx/fake/stdlib.h: -------------------------------------------------------------------------------- 1 | extern char *malloc(); 2 | extern char *realloc(); 3 | -------------------------------------------------------------------------------- /rx/mkh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkh - pull headers out of C source 3 | PATH=/bin:/usr/bin ; export PATH 4 | 5 | # egrep pattern to pick out marked lines 6 | egrep='^ =([ ]|$)' 7 | 8 | # Sed program to process marked lines into lines for the header file. 9 | # The markers have already been removed. Two things are done here: removal 10 | # of backslashed newlines, and some fudging of comments. The first is done 11 | # because -o needs to have prototypes on one line to strip them down. 12 | # Getting comments into the output is tricky; we turn C++-style // comments 13 | # into /* */ comments, after altering any existing */'s to avoid trouble. 14 | peel=' /\\$/N 15 | /\\\n[ ]*/s///g 16 | /\/\//s;\*/;* /;g 17 | /\/\//s;//\(.*\);/*\1 */;' 18 | 19 | for a 20 | do 21 | case "$a" in 22 | -o) # old (pre-function-prototype) compiler 23 | # add code to comment out argument lists 24 | peel="$peel 25 | "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);' 26 | shift 27 | ;; 28 | -b) # funny Berkeley __P macro 29 | peel="$peel 30 | "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));' 31 | shift 32 | ;; 33 | -s) # compiler doesn't like `static foo();' 34 | # add code to get rid of the `static' 35 | peel="$peel 36 | "'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;' 37 | shift 38 | ;; 39 | -p) # private declarations 40 | egrep='^ ==([ ]|$)' 41 | shift 42 | ;; 43 | -i) # wrap in #ifndef, argument is name 44 | ifndef="$2" 45 | shift ; shift 46 | ;; 47 | *) break 48 | ;; 49 | esac 50 | done 51 | 52 | if test " $ifndef" != " " 53 | then 54 | echo "#ifndef $ifndef" 55 | echo "#define $ifndef /* never again */" 56 | fi 57 | echo "/* ========= begin header generated by $0 ========= */" 58 | echo '#ifdef __cplusplus' 59 | echo 'extern "C" {' 60 | echo '#endif' 61 | for f 62 | do 63 | echo 64 | echo "/* === $f === */" 65 | egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel" 66 | echo 67 | done 68 | echo '#ifdef __cplusplus' 69 | echo '}' 70 | echo '#endif' 71 | echo "/* ========= end header generated by $0 ========= */" 72 | if test " $ifndef" != " " 73 | then 74 | echo "#endif" 75 | fi 76 | exit 0 77 | -------------------------------------------------------------------------------- /rx/re.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/rx/re.exe -------------------------------------------------------------------------------- /rx/regex.h: -------------------------------------------------------------------------------- 1 | #ifndef _REGEX_H_ 2 | #define _REGEX_H_ /* never again */ 3 | /* ========= begin header generated by ./mkh ========= */ 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* === regex2.h === */ 9 | typedef off_t regoff_t; 10 | typedef struct { 11 | int re_magic; 12 | size_t re_nsub; /* number of parenthesized subexpressions */ 13 | const char *re_endp; /* end pointer for REG_PEND */ 14 | struct re_guts *re_g; /* none of your business :-) */ 15 | } regex_t; 16 | typedef struct { 17 | regoff_t rm_so; /* start of match */ 18 | regoff_t rm_eo; /* end of match */ 19 | } regmatch_t; 20 | 21 | 22 | /* === regcomp.c === */ 23 | extern int regcomp(regex_t *, const char *, int); 24 | #define REG_BASIC 0000 25 | #define REG_EXTENDED 0001 26 | #define REG_ICASE 0002 27 | #define REG_NOSUB 0004 28 | #define REG_NEWLINE 0010 29 | #define REG_NOSPEC 0020 30 | #define REG_PEND 0040 31 | #define REG_DUMP 0200 32 | 33 | 34 | /* === regerror.c === */ 35 | #define REG_OKAY 0 36 | #define REG_NOMATCH 1 37 | #define REG_BADPAT 2 38 | #define REG_ECOLLATE 3 39 | #define REG_ECTYPE 4 40 | #define REG_EESCAPE 5 41 | #define REG_ESUBREG 6 42 | #define REG_EBRACK 7 43 | #define REG_EPAREN 8 44 | #define REG_EBRACE 9 45 | #define REG_BADBR 10 46 | #define REG_ERANGE 11 47 | #define REG_ESPACE 12 48 | #define REG_BADRPT 13 49 | #define REG_EMPTY 14 50 | #define REG_ASSERT 15 51 | #define REG_INVARG 16 52 | #define REG_ATOI 255 /* convert name to number (!) */ 53 | #define REG_ITOA 0400 /* convert number to name (!) */ 54 | extern size_t regerror(int, const regex_t *, char *, size_t); 55 | 56 | 57 | /* === regexec.c === */ 58 | extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int); 59 | #define REG_NOTBOL 00001 60 | #define REG_NOTEOL 00002 61 | #define REG_STARTEND 00004 62 | #define REG_TRACE 00400 /* tracing of execution */ 63 | #define REG_LARGE 01000 /* force large representation */ 64 | #define REG_BACKR 02000 /* force use of backref code */ 65 | 66 | 67 | /* === regfree.c === */ 68 | extern void regfree(regex_t *); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | /* ========= end header generated by ./mkh ========= */ 74 | #endif 75 | -------------------------------------------------------------------------------- /rx/regfree.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "utils.h" 7 | #include "regex2.h" 8 | 9 | /* 10 | - regfree - free everything 11 | = extern void regfree(regex_t *); 12 | */ 13 | void 14 | regfree(preg) 15 | regex_t *preg; 16 | { 17 | register struct re_guts *g; 18 | 19 | if (preg->re_magic != MAGIC1) /* oops */ 20 | return; /* nice to complain, but hard */ 21 | 22 | g = preg->re_g; 23 | if (g == NULL || g->magic != MAGIC2) /* oops again */ 24 | return; 25 | preg->re_magic = 0; /* mark it invalid */ 26 | g->magic = 0; /* mark it invalid */ 27 | 28 | if (g->strip != NULL) 29 | free((char *)g->strip); 30 | if (g->sets != NULL) 31 | free((char *)g->sets); 32 | if (g->setbits != NULL) 33 | free((char *)g->setbits); 34 | if (g->must != NULL) 35 | free(g->must); 36 | free((char *)g); 37 | } 38 | -------------------------------------------------------------------------------- /rx/utils.h: -------------------------------------------------------------------------------- 1 | /* utility definitions */ 2 | #ifdef _POSIX2_RE_DUP_MAX 3 | #define DUPMAX _POSIX2_RE_DUP_MAX 4 | #else 5 | #define DUPMAX 255 6 | #endif 7 | #define INFINITY (DUPMAX + 1) 8 | #define NC (CHAR_MAX - CHAR_MIN + 1) 9 | typedef unsigned char uch; 10 | 11 | /* switch off assertions (if not already off) if no REDEBUG */ 12 | #ifndef REDEBUG 13 | #ifndef NDEBUG 14 | #define NDEBUG /* no assertions please */ 15 | #endif 16 | #endif 17 | #include 18 | 19 | /* for old systems with bcopy() but no memmove() */ 20 | #ifdef USEBCOPY 21 | #define memmove(d, s, c) bcopy(s, d, c) 22 | #endif 23 | -------------------------------------------------------------------------------- /stubs/dont-delete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/stubs/dont-delete -------------------------------------------------------------------------------- /test/blit.ms: -------------------------------------------------------------------------------- 1 | (import "lib/iterate") 2 | (import "lib/scud") 3 | (scud-cls) 4 | 5 | (define t "0123456789ABCDEF") 6 | (define f (make-string 16 0)) 7 | (for-each (lambda (col) 8 | (string-set! f col col)) 9 | (integer-range 0 16)) 10 | 11 | (for-each (lambda (row) 12 | (define b (make-string 16 row)) 13 | (console-blit t f b) 14 | (print *line-sep*)) 15 | (integer-range 0 8)) 16 | 17 | (set-scud-colors 'clear 'white) 18 | -------------------------------------------------------------------------------- /test/bridge.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/test/bridge.mo -------------------------------------------------------------------------------- /test/clue.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (import "lib/test") 17 | (import "lib/clue") 18 | 19 | (enable-spot-tests) 20 | 21 | (define db (new-clue-db)) 22 | 23 | (s: (find-clue db)) 24 | (r: '()) 25 | 26 | (s: (find-clue db customer)) 27 | (r: '()) 28 | 29 | (s: (drop-clue '())) 30 | (r: '()) 31 | 32 | (s: (clue-db->list db)) 33 | (r: '()) 34 | 35 | (s: (list->clue-db '())) 36 | 37 | (define record 38 | (put-clue db customer (first-name "John") (last-name "Doe"))) 39 | 40 | (s: (get-clue record customer)) 41 | (r: #t) 42 | 43 | (s: (get-clue record first-name)) 44 | (r: "John") 45 | 46 | (s: (get-clue record last-name)) 47 | (r: "Doe") 48 | 49 | (s: (get-clue record missing)) 50 | (r: #f) 51 | 52 | (s: (get-clue record customer last-name first-name missing)) 53 | (r: (list #t "Doe" "John" #f)) 54 | 55 | (s: (get-clue (list record record record) 56 | customer last-name first-name missing)) 57 | (r: (list (list #t "Doe" "John" #f) 58 | (list #t "Doe" "John" #f) 59 | (list #t "Doe" "John" #f))) 60 | 61 | (put-clue db customer (first-name "Jane") (last-name "Doe")) 62 | 63 | (s: (find-clue db (first-name "John"))) 64 | (r: (list record)) 65 | 66 | (s: (find-clue db (last-name "Doe"))) 67 | (t: (= (length _) 2)) 68 | 69 | (drop-clue record) 70 | 71 | (s: (find-clue db (first-name "John"))) 72 | (r: '()) 73 | 74 | (s: (find-clue db (last-name "Doe"))) 75 | (t: (= (length _) 1)) 76 | 77 | (drop-clue (find-clue db customer)) 78 | 79 | (s: (find-clue db)) 80 | (t: (= (length _) 0)) 81 | -------------------------------------------------------------------------------- /test/collate-filter.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2008, Scott W. Dunlop 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License as published by 5 | ; the Free Software Foundation; either version 2.1 of the License, or (at 6 | ; your option) any later version. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, but WITHOUT 9 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | ; for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public License 14 | ; along with this library; if not, write to the Free Software Foundation, 15 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | ; 17 | 18 | (import "lib/test") 19 | (import "lib/filter") 20 | (import "lib/collate-filter") 21 | 22 | (enable-spot-tests) 23 | 24 | (define xmit (make-queue)) 25 | (define recv (input-chain xmit (check-collation-filter))) 26 | 27 | (send "\0\0\0\5alpha\0\0\0\4beta\0\0\0\7charlie" xmit) 28 | 29 | (s: (wait 100 recv)) 30 | (r: "alpha") 31 | 32 | (s: (wait 100 recv)) 33 | (r: "beta") 34 | 35 | (s: (wait 100 recv)) 36 | (r: "charlie") 37 | 38 | (send "\0\0\0\5alpha" xmit) 39 | (send "\0\0" xmit) 40 | (send "\0\4beta\0\0\0\7charlie\0" xmit) 41 | 42 | (s: (wait 100 recv)) 43 | (r: "alpha") 44 | 45 | (s: (wait 100 recv)) 46 | (r: "beta") 47 | 48 | (s: (wait 100 recv)) 49 | (r: "charlie") 50 | 51 | (s: (wait 100 recv)) 52 | (r: 'timeout) 53 | 54 | (define xmit (make-queue)) 55 | (define recv (input-chain xmit (prepend-collation-filter))) 56 | 57 | (send "Alpha" xmit) 58 | (send "Beta" xmit) 59 | (send "Charlie" xmit) 60 | 61 | (s: (wait 100 recv)) 62 | (r: "\0\0\0\5Alpha") 63 | 64 | (s: (wait 100 recv)) 65 | (r: "\0\0\0\4Beta") 66 | 67 | (s: (wait 100 recv)) 68 | (r: "\0\0\0\7Charlie") 69 | 70 | (s: (wait 100 recv)) 71 | (r: 'timeout) 72 | 73 | -------------------------------------------------------------------------------- /test/curve25519.ms: -------------------------------------------------------------------------------- 1 | (import "lib/test") 2 | 3 | (enable-spot-tests) 4 | 5 | (define (spam item) #f) 6 | (define (spam* . items) 7 | (for-each spam items) 8 | (spam *line-sep*)) 9 | 10 | (define private-1 11 | "a\1\2\3\4\5\6\7\8\9\0\1\2\3\4\5\6\7\8\9\0\1\2\3\4\5\6\7\8\9\0a") 12 | (define private-2 13 | "a\1\2\3\4\5\6\7\8\9\0\1\2\3\4\5\6\7\8\9\0\1\2\3\4\5\6\7\8\9\0b") 14 | 15 | (define public-1 (curve25519-public private-1)) 16 | (define public-2 (curve25519-public private-2)) 17 | 18 | (s: public-1) 19 | (t: (= (string-length _) 32)) 20 | 21 | (s: public-2) 22 | (t: (= (string-length _) 32)) 23 | 24 | (define secret-1 (curve25519-secret private-1 public-2)) 25 | (define secret-2 (curve25519-secret private-2 public-1)) 26 | 27 | (spam* " SECRET 1: " (format secret-1)) 28 | (spam* " SECRET 2: " (format secret-2)) 29 | 30 | (s: secret-1) 31 | (t: (= (string-length _) 32)) 32 | (t: (string=? secret-1 secret-2)) 33 | 34 | -------------------------------------------------------------------------------- /test/http-server.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2008, Scott W. Dunlop 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (import "lib/test") 17 | (import "lib/http-url") 18 | (import "lib/http-server") 19 | (import "lib/spawn-connection") 20 | 21 | (enable-spot-tests) 22 | 23 | (define last-request #f) 24 | (define response-queue (make-queue)) 25 | 26 | (define (my-responder request) 27 | (set! last-request request) 28 | (apply write-http-response (wait response-queue))) 29 | 30 | (define conn (spawn-connection http-service my-responder)) 31 | (send "GET /index.ms?a=1&b=2#frag HTTP/0.1\n\n" conn) 32 | (pause) 33 | 34 | (s: last-request) 35 | 36 | (t: (http-request? _)) 37 | (t: (equal? (http-request-method _) "GET")) 38 | (t: (equal? (dict->list (http-request-headers _)) '())) 39 | 40 | (t: (set! last-url (http-request-url _)) 41 | (http-url? last-url)) 42 | 43 | (t: (equal? (url-scheme last-url) "http")) 44 | (t: (equal? (url-path last-url) "/index.ms")) 45 | (t: (equal? (url-query last-url) "a=1&b=2")) 46 | (t: (equal? (url-frag last-url) "frag")) 47 | (t: (equal? (http-url-arg last-url "a") "1")) 48 | 49 | (t: (equal? (http-request-version _) "HTTP/0.1")) 50 | (t: (equal? (http-request-body _) #f)) 51 | 52 | (send `(,last-request 200 "OK" 53 | ("Content-type: text/plain" ) 54 | "The quick brown fox") 55 | response-queue) 56 | 57 | (s: (wait 100 conn)) 58 | (t: (equal? _ 59 | "HTTP/1.1 200 OK\r\nContent-type: text/plain\r\n\r\nThe quick brown fox")) 60 | 61 | -------------------------------------------------------------------------------- /test/http-url.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2006, Ephemeral Security, LLC 2 | ; Modifications (C) 2008, Scott W. Dunlop 3 | ; 4 | ; This library is free software; you can redistribute it and/or modify it 5 | ; under the terms of the GNU Lesser General Public License as published by 6 | ; the Free Software Foundation; either version 2.1 of the License, or (at 7 | ; your option) any later version. 8 | ; 9 | ; This library is distributed in the hope that it will be useful, but WITHOUT 10 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 12 | ; for more details. 13 | ; 14 | ; You should have received a copy of the GNU Lesser General Public License 15 | ; along with this library; if not, write to the Free Software Foundation, 16 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ; 18 | 19 | (import "lib/test") 20 | (import "lib/http-url") 21 | 22 | (enable-spot-tests) 23 | 24 | (s: (string->url "http://un:pw@server:99/check?x=1#frag")) 25 | (t: (equal? (url-scheme _) "http")) 26 | (t: (equal? (url-auth _) "un:pw@server:99")) 27 | (t: (equal? (http-url-host _) "server")) 28 | (t: (equal? (http-url-portno _) 99)) 29 | 30 | (t: (equal? (url-path _) "/check")) 31 | (t: (equal? (url-query _) "x=1")) 32 | (t: (equal? (url-frag _) "frag")) 33 | (t: (equal? (http-url-arg _ "x") "1")) 34 | 35 | (t: (http-url? _) #t) 36 | (t: (url? _) #t) 37 | (t: (equal? (percent-decode (url->string _)) "http://un:pw@server:99/check?x=1#frag")) 38 | 39 | -------------------------------------------------------------------------------- /test/mosref-base.ms: -------------------------------------------------------------------------------- 1 | (import "lib/test") 2 | (import "mosref/transport") 3 | 4 | (enable-spot-tests) 5 | 6 | (print "Gathering entropy..\n") 7 | 8 | (define private-1 (make-private-key)) 9 | (define private-2 (make-private-key)) 10 | 11 | (define public-1 (find-public-key private-1)) 12 | (define public-2 (find-public-key private-2)) 13 | 14 | (define secret-1 (find-shared-secret private-1 public-2)) 15 | (define secret-2 (find-shared-secret private-2 public-1)) 16 | 17 | (s: secret-1) 18 | (r: secret-2) 19 | 20 | (define iv-1 (make-iv)) 21 | (define iv-2 iv-1) 22 | 23 | (print "..Entropy gathered, proceeding to test.\n") 24 | 25 | (define transport (make-queue)) 26 | 27 | (define xmit (make-mosref-xmit transport secret-1 iv-1)) 28 | (define recv (make-mosref-recv "" transport secret-2 iv-2)) 29 | 30 | ;; Shameless Pirates of Penzance fandom follows: 31 | (define verse 32 | (string-join " " 33 | "I am the very model of a modern Major-General," 34 | "I've information vegetable, animal, and mineral," 35 | "I know the kings of England, and I quote the fights historical" 36 | "From Marathon to Waterloo, in order categorical;" 37 | "I'm very well acquainted, too, with matters mathematical," 38 | "I understand equations, both the simple and quadratical," 39 | "About binomial theorem I'm teeming with a lot o' news," 40 | "With many cheerful facts about the square of the hypotenuse.")) 41 | 42 | (s: (send "Hello" xmit) 43 | (wait 1000 recv)) 44 | 45 | (r: "Hello") 46 | 47 | (s: (send verse xmit) 48 | (wait 1000 recv)) 49 | 50 | (r: verse) 51 | 52 | -------------------------------------------------------------------------------- /test/salsa.ms: -------------------------------------------------------------------------------- 1 | (import "lib/test") 2 | 3 | (enable-spot-tests) 4 | 5 | ;; Shameless Pirates of Penzance fandom follows: 6 | (define plaintext 7 | (string-join " " 8 | "I am the very model of a modern Major-General," 9 | "I've information vegetable, animal, and mineral," 10 | "I know the kings of England, and I quote the fights historical" 11 | "From Marathon to Waterloo, in order categorical;" 12 | "I'm very well acquainted, too, with matters mathematical," 13 | "I understand equations, both the simple and quadratical," 14 | "About binomial theorem I'm teeming with a lot o' news," 15 | "With many cheerful facts about the square of the hypotenuse.")) 16 | 17 | (define seed (read-prng 32)) 18 | (define xmit-key (make-salsa20-key seed)) 19 | (define recv-key (make-salsa20-key seed)) 20 | 21 | (define ciphertext-1 (salsa20-encrypt xmit-key plaintext)) 22 | 23 | (s: ciphertext-1) 24 | (t: (= (string-length _) (string-length plaintext))) 25 | (t: (not (string=? ciphertext-1 plaintext))) 26 | 27 | (define intercept (salsa20-decrypt recv-key ciphertext-1)) 28 | (s: intercept) 29 | (t: (string=? intercept plaintext)) 30 | 31 | (define iv (read-prng 8)) 32 | (define ciphertext-2 (salsa20-encrypt xmit-key plaintext iv)) 33 | 34 | (s: ciphertext-2) 35 | (t: (= (string-length _) (string-length plaintext))) 36 | (t: (not (string=? ciphertext-2 plaintext))) 37 | 38 | ;;TODO: Note, there is a 1 in 2 ^ 64 chance of this test failing without cause. 39 | ;; Let me know if you win that lottery.. 40 | 41 | (t: (not (string=? ciphertext-1 ciphertext-2))) 42 | 43 | (define intercept (salsa20-decrypt recv-key ciphertext-2 iv)) 44 | (s: intercept) 45 | (t: (string=? intercept plaintext)) 46 | 47 | -------------------------------------------------------------------------------- /test/spawn-connection.ms: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2008, Scott W. Dunlop 2 | ; 3 | ; This library is free software; you can redistribute it and/or modify it 4 | ; under the terms of the GNU Lesser General Public License, version 2.1 5 | ; as published by the Free Software Foundation. 6 | ; 7 | ; This library is distributed in the hope that it will be useful, but WITHOUT 8 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | ; for more details. 11 | ; 12 | ; You should have received a copy of the GNU Lesser General Public License 13 | ; along with this library; if not, write to the Free Software Foundation, 14 | ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | 16 | (import "lib/test") 17 | (import "lib/spawn-connection") 18 | (enable-spot-tests) 19 | 20 | (s: (spawn-connection (function (add-1) (forever (send (+ 1 (wait))))))) 21 | (t: (send 1 _) 22 | (= (wait _) 2)) 23 | (t: (send 22 _) 24 | (= (wait _) 23)) 25 | (t: (send 333 _) 26 | (= (wait _) 334)) 27 | (t: (eq? (wait 5 _) 'timeout)) 28 | 29 | -------------------------------------------------------------------------------- /util/alter-symbol.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PATTERN="([^a-zA-Z>._!*-])$1([^a-zA-Z_!*-])" 4 | 5 | for FILE in $(find vm sys mod -name '*.c' -o -name '*.ms') 6 | do if egrep $PATTERN $FILE >/dev/null 7 | then FILES="$FILES $FILE" 8 | fi 9 | done 10 | 11 | exec vim -p $FILES 12 | -------------------------------------------------------------------------------- /util/prim-use.ms: -------------------------------------------------------------------------------- 1 | (import "lib/module") 2 | 3 | (define (find-module-globals module globals) 4 | ;(print (string-append "Scanning " module "...\n")) 5 | 6 | (define source (read-module-source module)) 7 | 8 | (for-each (lambda (x) 9 | (unless (pair? x) (return)) 10 | (unless (eq? (car x) 'ldg) (return)) 11 | (set-add! globals (cadr x))) 12 | (compile source))) 13 | 14 | (define (module-globals module) 15 | (define globals (set)) 16 | (for-each find-module-globals 17 | (code-dependencies module) 18 | (repeat globals)) 19 | globals) 20 | 21 | (define (module-primitives module) 22 | (define (primitive-global? symbol) 23 | (primitive? (get-global symbol))) 24 | 25 | (filter primitive-global? 26 | (module-globals module))) 27 | 28 | (for-each 29 | (lambda (x) (print (format x)) (print *line-sep*)) 30 | (module-primitives "bin/wasp")) 31 | 32 | -------------------------------------------------------------------------------- /vm/boolean.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "waspvm.h" 18 | 19 | wasp_value wasp_the_true; 20 | wasp_value wasp_the_false; 21 | 22 | void wasp_format_boolean( wasp_string buf, wasp_value v ){ 23 | wasp_string_append_cs( buf, v == wasp_the_false ? "#f" : "#t" ); 24 | } 25 | wasp_integer wasp_boolean_compare( wasp_value a, wasp_value b ){ 26 | if( a == b )return 0; 27 | return ( a == wasp_the_false ) ? -1 : +1; 28 | } 29 | WASP_GENERIC_GC( boolean ); 30 | WASP_C_TYPE( boolean ); 31 | 32 | wasp_value wasp_make_mote( wasp_type type ){ 33 | wasp_object mote = wasp_objalloc( type, sizeof( struct wasp_object_data ) ); 34 | wasp_root_obj( mote ); 35 | return wasp_vf_obj( mote ); 36 | } 37 | 38 | void wasp_init_boolean_subsystem( ){ 39 | WASP_I_TYPE( boolean ); 40 | wasp_the_true = wasp_make_mote( wasp_boolean_type ); 41 | wasp_the_false = wasp_make_mote( wasp_boolean_type ); 42 | } 43 | -------------------------------------------------------------------------------- /vm/closure.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, print to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "waspvm.h" 18 | 19 | wasp_closure wasp_make_closure( wasp_value name, wasp_instruction inst, wasp_pair env ){ 20 | wasp_closure clos = WASP_OBJALLOC( closure ); 21 | clos->inst = inst; 22 | clos->env = env; 23 | clos->name = name; 24 | return clos; 25 | } 26 | 27 | void wasp_trace_closure( wasp_closure clos ){ 28 | wasp_grey_val( wasp_clos_name( clos ) ); 29 | wasp_grey_obj( (wasp_object) wasp_clos_inst( clos )->proc ); 30 | wasp_grey_obj( (wasp_object) wasp_clos_env( clos ) ); 31 | } 32 | 33 | void wasp_format_closure( wasp_string buf, wasp_closure clos ){ 34 | // wasp_format_begin( buf, clos ); 35 | // wasp_string_append_byte( buf, ' ' ); 36 | wasp_format_item( buf, clos->name ); 37 | // wasp_format_end( buf ); 38 | } 39 | 40 | wasp_value wasp_function_name( wasp_value function ){ 41 | wasp_value result; 42 | 43 | if( wasp_is_closure( function ) ){ 44 | result = wasp_closure_fv( function )->name; 45 | if( ! result ) result = function; 46 | }else if( wasp_is_multimethod( function ) ){ 47 | result = wasp_vf_symbol( wasp_multimethod_fv( function )->name ); 48 | }else if( wasp_is_primitive( function ) ){ 49 | result = wasp_vf_symbol( wasp_primitive_fv( function )->name ); 50 | }else{ 51 | result = function; 52 | } 53 | 54 | return result; 55 | } 56 | void wasp_format_func( wasp_string buf, wasp_value func ){ 57 | wasp_format_item( buf, wasp_function_name( func ) ); 58 | } 59 | WASP_GENERIC_COMPARE( closure ); 60 | WASP_GENERIC_FREE( closure ); 61 | WASP_C_TYPE( closure ); 62 | 63 | void wasp_init_closure_subsystem( ){ 64 | WASP_I_TYPE( closure ); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /vm/connection.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "waspvm.h" 18 | 19 | void wasp_init_connection( wasp_connection c, wasp_input i, wasp_output o ){ 20 | c->input = i; 21 | c->output = o; 22 | } 23 | 24 | wasp_connection wasp_make_connection( wasp_input i, wasp_output o ){ 25 | wasp_connection c = WASP_OBJALLOC( connection ); 26 | wasp_init_connection( c, i, o ); 27 | return c; 28 | } 29 | 30 | void wasp_trace_connection( wasp_connection c ){ 31 | wasp_grey_obj( (wasp_object) c->input ); 32 | wasp_grey_obj( (wasp_object) c->output ); 33 | } 34 | 35 | WASP_GENERIC_FREE( connection ) 36 | 37 | WASP_GENERIC_FORMAT( connection ); 38 | WASP_GENERIC_COMPARE( connection ); 39 | WASP_C_TYPE( connection ); 40 | 41 | WASP_BEGIN_PRIM( "make-connection", make_connection ) 42 | REQ_INPUT_ARG( input ); 43 | REQ_OUTPUT_ARG( output ); 44 | NO_REST_ARGS( ); 45 | 46 | CONNECTION_RESULT( wasp_make_connection( input, output ) ); 47 | WASP_END_PRIM( make_connection ); 48 | 49 | WASP_BEGIN_PRIM( "connection-input", connection_input ) 50 | REQ_CONNECTION_ARG( connection ); 51 | NO_REST_ARGS( ); 52 | 53 | RESULT( wasp_vf_input( connection->input ) ); 54 | WASP_END_PRIM( connection_input ); 55 | 56 | WASP_BEGIN_PRIM( "connection-output", connection_output ) 57 | REQ_CONNECTION_ARG( connection ); 58 | NO_REST_ARGS( ); 59 | 60 | RESULT( wasp_vf_output( connection->output ) ); 61 | WASP_END_PRIM( connection_output ); 62 | 63 | void wasp_init_connection_subsystem( ){ 64 | WASP_I_TYPE( connection ); 65 | 66 | WASP_BIND_PRIM( make_connection ); 67 | WASP_BIND_PRIM( connection_input ); 68 | WASP_BIND_PRIM( connection_output ); 69 | } 70 | -------------------------------------------------------------------------------- /vm/crc32.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * With modifications Copyright (C) 2008, Scott W. Dunlop 3 | * 4 | * This library is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU Lesser General Public License, version 2.1 6 | * as published by the Free Software Foundation. 7 | * 8 | * This library is distributed in the hope that it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | * for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public License 14 | * along with this library; if not, write to the Free Software Foundation, 15 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | // The classic CRC-32 from http://www.w3.org/TR/PNG-CRCAppendix.html, modified 19 | // to behave itself in MOSVM. 20 | 21 | #include "waspvm.h" 22 | #include 23 | 24 | /* Table of CRCs of all 8-bit messages. */ 25 | wasp_quad* wasp_crc_table = NULL; 26 | 27 | /* Flag: has the table been computed? Initially false. */ 28 | int wasp_crc_table_computed = 0; 29 | 30 | /* Make the table for a fast CRC. */ 31 | void wasp_init_crc_table(){ 32 | wasp_quad c; 33 | int n, k; 34 | 35 | wasp_crc_table = malloc( 256 * sizeof( wasp_quad ) ); 36 | 37 | for (n = 0; n < 256; n++) { 38 | c = (wasp_quad) n; 39 | for (k = 0; k < 8; k++) { 40 | if (c & 1) 41 | c = 0xedb88320L ^ (c >> 1); 42 | else 43 | c = c >> 1; 44 | } 45 | wasp_crc_table[n] = c; 46 | } 47 | } 48 | 49 | /* Update a running CRC with the bytes buf[0..len-1]--the CRC 50 | should be initialized to all 1's, and the transmitted value 51 | is the 1's complement of the final running CRC (see the 52 | wasp_crc() routine below)). */ 53 | 54 | wasp_quad wasp_update_crc( wasp_quad crc, unsigned char *buf, int len ){ 55 | int n; 56 | 57 | for (n = 0; n < len; n++) { 58 | crc = wasp_crc_table[(crc ^ buf[n]) & 0xff] ^ (crc >> 8); 59 | } 60 | return crc; 61 | } 62 | 63 | /* Return the CRC of the bytes buf[0..len-1]. */ 64 | wasp_quad wasp_crc( unsigned char *buf, int len ){ 65 | return wasp_update_crc(0xffffffffL, buf, len) ^ 0xffffffffL; 66 | } 67 | 68 | WASP_BEGIN_PRIM( "crc32", crc32 ) 69 | REQ_STRING_ARG( data ) 70 | NO_REST_ARGS( ); 71 | 72 | INTEGER_RESULT( wasp_crc( (unsigned char*)wasp_sf_string( data ), 73 | wasp_string_length( data ) ) ); 74 | WASP_END_PRIM( crc32 ) 75 | 76 | void wasp_init_crc32_subsystem( ){ 77 | wasp_init_crc_table(); 78 | WASP_BIND_PRIM( crc32 ); 79 | } 80 | -------------------------------------------------------------------------------- /vm/curve.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2008, Scott W. Dunlop 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "curve25519_i64.h" 18 | #include "waspvm.h" 19 | 20 | WASP_BEGIN_PRIM( "curve25519-public", curve25519_public ) 21 | REQ_STRING_ARG( private ) 22 | NO_REST_ARGS( ) 23 | 24 | if( wasp_string_length( private ) != 32 ) 25 | wasp_errf( 26 | wasp_es_vm, "si", "private must be 32 bytes long", 27 | wasp_string_length( private ) ); 28 | 29 | wasp_string public = wasp_make_string( 32 ); 30 | 31 | /* 32 | keygen25519(P, s, k); 33 | core25519(P, s, k, NULL); 34 | core25519(Px, s, const k, const Gx); 35 | */ 36 | 37 | keygen25519( 38 | wasp_sf_string( public ), 39 | NULL, 40 | wasp_sf_string( private ) 41 | ); 42 | 43 | wasp_string_wrote( public, 32 ); 44 | 45 | STRING_RESULT( public ); 46 | WASP_END_PRIM( curve25519_public ) 47 | 48 | WASP_BEGIN_PRIM( "curve25519-secret", curve25519_secret ) 49 | REQ_STRING_ARG( private ) 50 | REQ_STRING_ARG( public ) 51 | NO_REST_ARGS( ); 52 | 53 | if( wasp_string_length( public ) != 32 ) 54 | wasp_errf( wasp_es_vm, "s", "public key must be 32 bytes long" ); 55 | 56 | if( wasp_string_length( private ) != 32 ) 57 | wasp_errf( wasp_es_vm, "s", "private key must be 32 bytes long" ); 58 | 59 | wasp_string s = wasp_make_string( 32 ); 60 | 61 | curve25519( wasp_sf_string( s ), 62 | wasp_sf_string( private ), 63 | wasp_sf_string( public ) ); 64 | 65 | wasp_string_wrote( s, 32 ); 66 | 67 | STRING_RESULT( s ); 68 | WASP_END_PRIM( curve25519_secret ) 69 | 70 | void wasp_init_curve25519_subsystem( ){ 71 | WASP_BIND_PRIM( curve25519_public ); 72 | WASP_BIND_PRIM( curve25519_secret ); 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /vm/curve25519_i64.h: -------------------------------------------------------------------------------- 1 | #ifndef CURVE25519_I64_H 2 | #define CURVE25519_I64_H 1 3 | 4 | /* Generic 64-bit integer implementation of Curve25519 ECDH 5 | * Written by Matthijs van Duin, 200608242056 6 | * Public domain. 7 | * 8 | * Based on work by Daniel J Bernstein, http://cr.yp.to/ecdh.html 9 | */ 10 | 11 | #include 12 | 13 | typedef unsigned char k25519[32]; /* any type of key */ 14 | 15 | extern const k25519 zero25519; /* 0 */ 16 | extern const k25519 prime25519; /* the prime 2^255-19 */ 17 | extern const k25519 order25519; /* group order (a prime near 2^252+2^124) */ 18 | 19 | typedef k25519 pub25519; /* public key */ 20 | typedef k25519 priv25519; /* private key (for key agreement) */ 21 | typedef k25519 spriv25519; /* private key for signing */ 22 | typedef k25519 sec25519; /* shared secret */ 23 | 24 | 25 | //Internal, do not use. 26 | void core25519(k25519 Px, k25519 s, const k25519 k, const k25519 Gx); 27 | 28 | /********* KEY AGREEMENT *********/ 29 | 30 | /* Private key clamping 31 | * k [out] your private key for key agreement 32 | * k [in] 32 random bytes 33 | */ 34 | static inline 35 | void clamp25519(priv25519 k) { 36 | k[31] &= 0x7F; 37 | k[31] |= 0x40; 38 | k[ 0] &= 0xF8; 39 | } 40 | 41 | /* Key-pair generation 42 | * P [out] your public key 43 | * s [out] your private key for signing 44 | * k [out] your private key for key agreement 45 | * k [in] 32 random bytes 46 | * s may be NULL if you don't care 47 | * 48 | * WARNING: if s is not NULL, this function has data-dependent timing */ 49 | static inline 50 | void keygen25519(pub25519 P, spriv25519 s, priv25519 k) { 51 | clamp25519(k); 52 | core25519(P, s, k, NULL); 53 | } 54 | 55 | 56 | /* Key agreement 57 | * Z [out] shared secret (needs hashing before use) 58 | * k [in] your private key for key agreement 59 | * P [in] peer's public key 60 | * Buffers may overlap. */ 61 | static inline 62 | void curve25519(sec25519 Z, const priv25519 k, const pub25519 P) { 63 | core25519(Z, NULL, k, P); 64 | } 65 | 66 | 67 | int sign25519(k25519 v, const k25519 h, const priv25519 x, const spriv25519 s); 68 | 69 | 70 | /* Signature verification primitive, calculates Y = vP + hG 71 | * Y [out] signature public key 72 | * v [in] signature value 73 | * h [in] signature hash 74 | * P [in] public key 75 | */ 76 | void verify25519(pub25519 Y, const k25519 v, const k25519 h, const pub25519 P); 77 | 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /vm/mq.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "waspvm.h" 18 | 19 | void wasp_mq_heap( void* obj ){ free( obj ); } 20 | void wasp_mq_gc( ){ }; 21 | 22 | wasp_mq wasp_make_mq( wasp_gc_mt free ){ 23 | wasp_mq q = (wasp_mq)malloc( sizeof( struct wasp_mq_data ) ); 24 | q->first = q->last = NULL; 25 | q->refct = 1; 26 | q->free = free; 27 | return q; 28 | } 29 | 30 | void wasp_mq_xmit( wasp_mq q, void* data ){ 31 | wasp_message m = (wasp_message)malloc( sizeof( struct wasp_message_data ) ); 32 | 33 | if( q->last ){ 34 | q->last->next = m; 35 | }else{ 36 | q->first = m; 37 | }; 38 | 39 | m->next = NULL; 40 | q->last = m; 41 | m->content = data; 42 | } 43 | 44 | int wasp_mq_recv( wasp_mq q, void** data ){ 45 | wasp_message m = q->first; 46 | wasp_message n; 47 | 48 | if( ! m ){ 49 | return 0; 50 | }; 51 | 52 | n = m->next; 53 | 54 | if( n ){ 55 | q->first = n; 56 | }else{ 57 | q->first = q->last = NULL; 58 | } 59 | 60 | if( data ) *data = m->content; 61 | free( m ); 62 | 63 | return 1; 64 | } 65 | 66 | void wasp_incref_mq( wasp_mq q ){ 67 | q->refct ++; 68 | } 69 | 70 | void wasp_decref_mq( wasp_mq q ){ 71 | wasp_message m, n; 72 | 73 | if( ! ( -- q->refct ) ){ 74 | m = q->first; 75 | while( m ){ 76 | q->free( m->content ); 77 | n = m->next; 78 | free( m ); 79 | m = n; 80 | } 81 | }; 82 | } 83 | 84 | void wasp_trace_mq( wasp_mq q, wasp_gc_mt trace ){ 85 | wasp_message m, n; 86 | 87 | m = q->first; 88 | while( m ){ 89 | trace( m->content ); 90 | n = m->next; 91 | m = n; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vm/primitive.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, print to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "waspvm.h" 18 | 19 | wasp_primitive wasp_make_primitive( const char* name, wasp_prim_fn impl ){ 20 | wasp_primitive prim = WASP_OBJALLOC( primitive ); 21 | prim->name = wasp_symbol_fs( name ); 22 | prim->impl = impl; 23 | return prim; 24 | } 25 | void wasp_bind_primitive( const char* name, wasp_prim_fn impl ){ 26 | wasp_primitive prim = wasp_make_primitive( name, impl ); 27 | wasp_set_global( prim->name, wasp_vf_primitive( prim ) ); 28 | } 29 | void wasp_trace_primitive( wasp_primitive prim ){ 30 | wasp_grey_obj( (wasp_object) wasp_prim_name( prim ) ); 31 | } 32 | void wasp_format_primitive( wasp_string buf, wasp_primitive prim ){ 33 | // wasp_format_begin( buf, prim ); 34 | // wasp_string_append_byte( buf, ' ' ); 35 | wasp_string_append_sym( buf, wasp_prim_name( prim ) ); 36 | // wasp_format_end( buf ); 37 | } 38 | 39 | wasp_pair wasp_arg_ptr = NULL; 40 | wasp_integer wasp_arg_ct = 0; 41 | 42 | void wasp_no_more_args( ){ 43 | if( wasp_arg_ptr != NULL ){ 44 | wasp_errf( wasp_es_vm, "s", "expected no more arguments" ); 45 | } 46 | } 47 | 48 | WASP_GENERIC_COMPARE( primitive ); 49 | WASP_GENERIC_FREE( primitive ); 50 | WASP_C_TYPE( primitive ); 51 | 52 | void wasp_init_primitive_subsystem( ){ 53 | WASP_I_TYPE( primitive ); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /vm/print.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "waspvm.h" 18 | #include 19 | #include 20 | #include 21 | 22 | void wasp_printmem( const void* mem, wasp_integer len ){ 23 | while( len ){ 24 | int rs = write( STDOUT_FILENO, mem, len ); 25 | if( rs > 0 ){ 26 | len -= rs; 27 | }else if( rs ){ break; } 28 | } 29 | } 30 | void wasp_print( const char* st ){ 31 | wasp_printmem( st, strlen( st ) ); 32 | } 33 | void wasp_printch( wasp_byte ch ){ 34 | wasp_printmem( &ch, 1 ); 35 | } 36 | void wasp_printstr( wasp_string s ){ 37 | if( s )wasp_print( wasp_sf_string( s ) ); 38 | } 39 | void wasp_newline( ){ 40 | wasp_printch( '\n' ); 41 | } 42 | void wasp_space( ){ 43 | wasp_printch( ' ' ); 44 | } 45 | void wasp_show( wasp_value v ){ 46 | wasp_string s = wasp_make_string( 64 ); 47 | wasp_format_value( s, v, 32, 16 ); 48 | wasp_printstr( s ); 49 | wasp_objfree( s ); 50 | } 51 | 52 | WASP_BEGIN_PRIM( "print", print ) 53 | REQ_STRING_ARG( value ); 54 | NO_REST_ARGS( ); 55 | 56 | wasp_printstr( value ); 57 | 58 | NO_RESULT( ); 59 | WASP_END_PRIM( print ) 60 | 61 | WASP_BEGIN_PRIM( "format", format ) 62 | REQ_ANY_ARG( value ); 63 | OPT_INTEGER_ARG( breadth ); 64 | OPT_INTEGER_ARG( depth ); 65 | OPT_STRING_ARG( buffer ); 66 | NO_REST_ARGS( ); 67 | 68 | if( ! has_buffer ) buffer = wasp_make_string( 64 ); 69 | if( ! has_breadth ) breadth = 32; 70 | if( ! has_depth ) depth = 3; 71 | 72 | wasp_format_value( buffer, value, breadth, depth ); 73 | 74 | STRING_RESULT( buffer ); 75 | WASP_END_PRIM( format ) 76 | 77 | void wasp_init_print_subsystem( ){ 78 | WASP_BIND_PRIM( print ); 79 | WASP_BIND_PRIM( format ); 80 | } 81 | -------------------------------------------------------------------------------- /vm/salsa20-machine.h: -------------------------------------------------------------------------------- 1 | /* salsa20-machine.h */ 2 | 3 | /* 4 | * This file is included by 'salsa20-portable.h'. It allows to override 5 | * the default macros for specific platforms. Please carefully check 6 | * the machine code generated by your compiler (with optimisations 7 | * turned on) before deciding to edit this file. 8 | */ 9 | 10 | /* ------------------------------------------------------------------------- */ 11 | 12 | #if (defined(SALSA20_DEFAULT_ROT) && !defined(SALSA20_MACHINE_ROT)) 13 | 14 | #define SALSA20_MACHINE_ROT 15 | 16 | #if (defined(WIN32) && defined(_MSC_VER)) 17 | 18 | #undef ROTL32 19 | #undef ROTR32 20 | #undef ROTL64 21 | #undef ROTR64 22 | 23 | #include 24 | 25 | #define ROTL32(v, n) _lrotl(v, n) 26 | #define ROTR32(v, n) _lrotr(v, n) 27 | #define ROTL64(v, n) _rotl64(v, n) 28 | #define ROTR64(v, n) _rotr64(v, n) 29 | 30 | #endif 31 | 32 | #endif 33 | 34 | /* ------------------------------------------------------------------------- */ 35 | 36 | #if (defined(SALSA20_DEFAULT_SWAP) && !defined(SALSA20_MACHINE_SWAP)) 37 | 38 | #define SALSA20_MACHINE_SWAP 39 | 40 | /* 41 | * If you want to overwrite the default swap macros, put it here. And so on. 42 | */ 43 | 44 | #endif 45 | 46 | /* ------------------------------------------------------------------------- */ 47 | -------------------------------------------------------------------------------- /vm/salsa20.h: -------------------------------------------------------------------------------- 1 | /* salsa20-sync.h 2 | * Heavily modified from the ECRYPT header for Salsa20. */ 3 | 4 | #ifndef SALSA20_SYNC 5 | #define SALSA20_SYNC 6 | 7 | #include "salsa20-portable.h" 8 | 9 | 10 | // The Salsa20 Cipher Context 11 | typedef struct{ u32 input[16]; }salsa20_ctx; 12 | 13 | /* ------------------------------------------------------------------------- */ 14 | 15 | void salsa20_keysetup( salsa20_ctx* ctx, const u8* key ); 16 | void salsa20_ivsetup( salsa20_ctx* ctx, const u8* iv); 17 | void salsa20_crypt( 18 | salsa20_ctx* ctx, const u8* src, u8* dst, u32 len 19 | ); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /vm/waspvm.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * 3 | * Portions Copyright (C) 2006, Ephemeral Security, furnished via the LGPL. 4 | * 5 | * This library is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License, version 2.1 7 | * as published by the Free Software Foundation. 8 | * 9 | * This library is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 12 | * for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this library; if not, write to the Free Software Foundation, 16 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include "waspvm.h" 20 | #include 21 | 22 | #ifdef WASP_IN_CYGWIN 23 | #include 24 | #endif 25 | 26 | #ifdef WASP_IN_MINGW 27 | #include 28 | #endif 29 | 30 | // This file describes the basic WaspVM bootstrap for the WaspVM stub binary; 31 | // it will initialize the VM, load any linked modules -- see waspld -- and run 32 | // the main program, if one has been supplied. 33 | 34 | int main( int argc, const char** argv ){ 35 | wasp_string wasp = wasp_find_arg0( argc, argv ); 36 | wasp_init_waspvm( argc - 1, argv + 1 ); 37 | 38 | #ifndef WASP_IN_WIN32 39 | // We like sigint to trigger a trace and bail out. Not the best behavior, 40 | // but it'll do for 1.0. 41 | signal( SIGINT, wasp_handle_sigint ); 42 | 43 | // SIGPIPE is the devil; wasp's write operations check for errors. 44 | signal( SIGPIPE, SIG_IGN ); 45 | #endif 46 | 47 | wasp_load_linked( wasp ); 48 | wasp_run_main( ); 49 | 50 | if( wasp_show_globals ){ 51 | wasp_list globals = wasp_get_globals( ); 52 | while( globals ){ 53 | wasp_show( wasp_car( wasp_pair_fv( wasp_car( globals ) ) ) ); 54 | wasp_print( " -- " ); 55 | wasp_show( wasp_value_type( wasp_cdr( wasp_pair_fv( wasp_car( globals ) ) ) )->name ); 56 | wasp_newline( ); 57 | globals = wasp_list_fv( wasp_cdr( globals ) ); 58 | }; 59 | }; 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /vm/waspvm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_MOSVM_H 18 | #define WASP_MOSVM_H 1 19 | 20 | #ifdef __linux__ 21 | #define WASP_IN_LINUX LINUX_IS_NOT_XOPEN_UNIX 22 | #endif 23 | 24 | #ifdef __CYGWIN__ 25 | #define WASP_IN_CYGWIN A_LITTLE_UNIX_IS_A_DANGEROUS_THING 26 | #endif 27 | 28 | #ifdef __MINGW32__ 29 | #define WASP_IN_MINGW BUT_NONE_AT_ALL_IS_DEFINITELY_WORSE 30 | #endif 31 | 32 | #if defined( _WIN32 )||defined( WASP_IN_CYGWIN )||defined( WASP_IN_MINGW ) 33 | #define WASP_IN_WIN32 WELCOME_TO_SCHIZOPHRENIA_LAND 34 | #endif 35 | 36 | #ifdef __APPLE__ 37 | #define WASP_IN_DARWIN SMELLS_LIKE_BSD_UNTIL_YOU_TASTE_THE_BITROT 38 | #endif 39 | 40 | #include "waspvm/memory.h" 41 | #include "waspvm/number.h" 42 | #include "waspvm/boolean.h" 43 | #include "waspvm/list.h" 44 | #include "waspvm/tree.h" 45 | #include "waspvm/string.h" 46 | #include "waspvm/vector.h" 47 | #include "waspvm/primitive.h" 48 | #include "waspvm/procedure.h" 49 | #include "waspvm/closure.h" 50 | #include "waspvm/parse.h" 51 | #include "waspvm/print.h" 52 | #include "waspvm/format.h" 53 | #include "waspvm/file.h" 54 | #include "waspvm/package.h" 55 | #include "waspvm/vm.h" 56 | #include "waspvm/process.h" 57 | #include "waspvm/mq.h" 58 | #include "waspvm/channel.h" 59 | #include "waspvm/connection.h" 60 | #include "waspvm/error.h" 61 | #include "waspvm/tag.h" 62 | #include "waspvm/multimethod.h" 63 | #include "waspvm/file.h" 64 | #include "waspvm/time.h" 65 | #include "waspvm/plugin.h" 66 | #include "waspvm/queue.h" 67 | #include "waspvm/os.h" 68 | 69 | void wasp_init_wasp( ); 70 | void wasp_init_signal_subsystem( ); 71 | void wasp_init_crc32_subsystem( ); 72 | void wasp_init_shell_subsystem( ); 73 | void wasp_bind_core_prims( ); 74 | wasp_value wasp_make_mote( wasp_type type ); 75 | void wasp_handle_sigint( int sig ); 76 | wasp_string wasp_find_arg0( int argc, const char** argv ); 77 | 78 | extern int wasp_argc; 79 | extern wasp_list wasp_argv; 80 | extern int wasp_abort_on_error; 81 | extern int wasp_show_globals; 82 | extern wasp_input wasp_stdin; 83 | extern wasp_output wasp_stdout; 84 | 85 | extern wasp_symbol wasp_ss_main; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /vm/waspvm/boolean.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_BOOLEAN_H 18 | #define WASP_BOOLEAN_H 1 19 | 20 | #include "memory.h" 21 | 22 | extern wasp_value wasp_the_true; 23 | extern wasp_value wasp_the_false; 24 | 25 | WASP_H_TP( boolean ); 26 | WASP_H_IS( boolean ); 27 | #define REQ_BOOLEAN_ARG( vn ) REQ_TYPED_ARG( vn, boolean ) 28 | #define BOOLEAN_RESULT( vn ) TYPED_RESULT( boolean, vn ) 29 | #define OPT_TYPE_ARG( vn ) OPT_TYPED_ARG( vn, type ) 30 | #define TRUE_RESULT( ) RESULT( wasp_vf_true( ) ); 31 | #define FALSE_RESULT( ) RESULT( wasp_vf_false( ) ); 32 | 33 | static inline wasp_value wasp_vf_false( ){ return wasp_the_false; } 34 | static inline wasp_value wasp_vf_true( ){ return wasp_the_true; } 35 | static inline wasp_value wasp_vf_boolean( wasp_boolean q ){ 36 | return q ? wasp_the_true : wasp_the_false; 37 | } 38 | static inline wasp_boolean wasp_is_false( wasp_value v ){ 39 | return v == wasp_the_false; 40 | } 41 | static inline wasp_boolean wasp_is_true( wasp_value v ){ 42 | return v == wasp_the_true; 43 | } 44 | 45 | void wasp_init_boolean_subsystem( ); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /vm/waspvm/channel.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * 3 | * Portions Copyright (C) 2006, Ephemeral Security, furnished via the LGPL. 4 | * 5 | * This library is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License, version 2.1 7 | * as published by the Free Software Foundation. 8 | * 9 | * This library is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 12 | * for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this library; if not, write to the Free Software Foundation, 16 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef WASP_CHANNEL_H 20 | #define WASP_CHANNEL_H 1 21 | 22 | #define WASP_CLOSE_EVT 1 23 | #define WASP_XMIT_EVT 2 24 | #define WASP_RECV_EVT 3 25 | #define WASP_TIMEOUT_EVT 4 26 | 27 | extern wasp_symbol wasp_ss_close; 28 | extern wasp_symbol wasp_ss_channel; 29 | 30 | typedef void (*wasp_output_mt)( void*, wasp_value ); 31 | typedef wasp_byte (*wasp_input_mt)( void*, wasp_value* ); 32 | typedef void (*wasp_event_mt)( wasp_object context, unsigned int event ); 33 | 34 | WASP_BEGIN_TYPE( input ) 35 | wasp_input_mt recv; 36 | wasp_process monitor; 37 | WASP_END_TYPE( input ) 38 | 39 | WASP_BEGIN_TYPE( output ) 40 | wasp_output_mt xmit; 41 | WASP_END_TYPE( output ) 42 | 43 | void wasp_set_monitor( wasp_input channel, wasp_process process ); 44 | void wasp_clear_monitor( wasp_input channel ); 45 | wasp_boolean wasp_wake_monitor( wasp_input channel, wasp_value message ); 46 | int wasp_wake_process( wasp_process process, wasp_value message ); 47 | 48 | /* Predicate testing whether an input is being monitored by one or more 49 | * processes. */ 50 | wasp_boolean wasp_input_monitored( wasp_input input ); 51 | 52 | /* Initializes the channel subsystem, part of the core. */ 53 | void wasp_init_channel_subsystem( ); 54 | 55 | #define REQ_CHANNEL_ARG( vn ) REQ_SUBTYPED_ARG( vn, channel ) 56 | #define OPT_CHANNEL_ARG( vn ) OPT_SUBTYPED_ARG( vn, channel ) 57 | #define CHANNEL_RESULT( vn ) TYPED_RESULT( channel, vn ) 58 | 59 | #define REQ_INPUT_ARG( vn ) REQ_SUBTYPED_ARG( vn, input ) 60 | #define OPT_INPUT_ARG( vn ) OPT_SUBTYPED_ARG( vn, input ) 61 | #define INPUT_RESULT( vn ) TYPED_RESULT( input, vn ) 62 | 63 | #define REQ_OUTPUT_ARG( vn ) REQ_SUBTYPED_ARG( vn, output ) 64 | #define OPT_OUTPUT_ARG( vn ) OPT_SUBTYPED_ARG( vn, output ) 65 | #define OUTPUT_RESULT( vn ) TYPED_RESULT( output, vn ) 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /vm/waspvm/closure.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_CLOSURE_H 18 | #define WASP_CLOSURE_H 1 19 | 20 | #include "memory.h" 21 | #include "procedure.h" 22 | 23 | WASP_BEGIN_TYPE( closure ) 24 | wasp_value name; 25 | wasp_instruction inst; 26 | wasp_pair env; 27 | WASP_END_TYPE( closure ) 28 | 29 | #define REQ_CLOSURE_ARG( vn ) REQ_TYPED_ARG( vn, closure ) 30 | #define CLOSURE_RESULT( vn ) TYPED_RESULT( vn, closure ) 31 | #define OPT_CLOSURE_ARG( vn ) OPT_TYPED_ARG( vn, closure ) 32 | 33 | static inline wasp_value wasp_clos_name( wasp_closure clos ){ 34 | return clos->name; 35 | } 36 | static inline wasp_instruction wasp_clos_inst( wasp_closure clos ){ 37 | return clos->inst; 38 | } 39 | static inline wasp_pair wasp_clos_env( wasp_closure clos ){ 40 | return clos->env; 41 | } 42 | 43 | wasp_closure wasp_make_closure( wasp_value name, wasp_instruction inst, wasp_pair env ); 44 | wasp_value wasp_function_name( wasp_value function ); 45 | void wasp_format_func( wasp_string buf, wasp_value func ); 46 | 47 | void wasp_init_closure_subsystem( ); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /vm/waspvm/config.h.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/vm/waspvm/config.h.in -------------------------------------------------------------------------------- /vm/waspvm/connection.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_CONNECTION_H 18 | #define WASP_CONNECTION_H 1 19 | 20 | /** a simple combination of input and output; often used as a base class for communication 21 | with the host environment. */ 22 | 23 | WASP_BEGIN_TYPE( connection ) 24 | wasp_input input; 25 | wasp_output output; 26 | WASP_END_TYPE( connection ); 27 | 28 | #define REQ_CONNECTION_ARG( x ) REQ_SUBTYPED_ARG( x, connection ) 29 | #define OPT_CONNECTION_ARG( x ) OPT_SUBTYPED_ARG( x, connection ) 30 | #define CONNECTION_RESULT( x ) TYPED_RESULT( connection, x ) 31 | 32 | void wasp_init_connection( wasp_connection conn, wasp_input input, wasp_output output ); 33 | wasp_connection wasp_make_connection( wasp_input input, wasp_output output ); 34 | 35 | void wasp_init_connection_subsystem( ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /vm/waspvm/error.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_ERROR_H 18 | #define WASP_ERROR_H 1 19 | 20 | #include "memory.h" 21 | 22 | WASP_BEGIN_TYPE( error ) 23 | wasp_symbol key; 24 | wasp_pair info, context; 25 | WASP_END_TYPE( error ) 26 | 27 | WASP_BEGIN_TYPE( guard ) 28 | wasp_value fn; 29 | wasp_callframe ap, cp; 30 | wasp_instruction ip; 31 | wasp_pair ep; 32 | wasp_integer t; 33 | WASP_END_TYPE( guard ) 34 | 35 | #define REQ_ERROR_ARG( vn ) REQ_TYPED_ARG( vn, error ) 36 | #define ERROR_RESULT( vn ) TYPED_RESULT( vn, error ) 37 | #define OPT_ERROR_ARG( vn ) OPT_TYPED_ARG( vn, error ) 38 | 39 | #define REQ_GUARD_ARG( vn ) REQ_TYPED_ARG( vn, guard ) 40 | #define GUARD_RESULT( vn ) TYPED_RESULT( vn, guard ) 41 | #define OPT_GUARD_ARG( vn ) OPT_TYPED_ARG( vn, guard ) 42 | 43 | void wasp_errf( wasp_symbol key, const char* fmt, ... ); 44 | void wasp_show_error( wasp_error e, wasp_word* ct ); 45 | void wasp_format_traceback( wasp_string buf, wasp_error e ); 46 | int wasp_format_context( wasp_string buf, wasp_list context ); 47 | wasp_error wasp_make_error( wasp_symbol key, wasp_list info, wasp_list context ); 48 | wasp_pair wasp_frame_context( wasp_callframe callframe ); 49 | void wasp_throw_error( wasp_error e ); 50 | 51 | wasp_guard wasp_make_guard( 52 | wasp_value fn, wasp_callframe cp, wasp_callframe ap, wasp_pair ep, 53 | wasp_instruction ip, wasp_integer t 54 | ); 55 | 56 | void wasp_init_error_subsystem( ); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /vm/waspvm/file.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_FILE_H 18 | #define WASP_FILE_H 1 19 | 20 | WASP_BEGIN_TYPE( file ); 21 | wasp_string path; 22 | wasp_integer fd; 23 | wasp_boolean closed; 24 | WASP_END_TYPE( file ); 25 | 26 | wasp_file wasp_make_file( wasp_string path, int fd ); 27 | 28 | void wasp_init_file_subsystem( ); 29 | 30 | int wasp_os_error( int code ); 31 | wasp_string wasp_read_file( wasp_file file, wasp_quad max ); 32 | void wasp_write_file( wasp_file file, const void* data, wasp_integer datalen ); 33 | void wasp_close_file( wasp_file file ); 34 | wasp_file wasp_open_file( const char* path, const char* flags, wasp_integer mode ); 35 | 36 | wasp_boolean wasp_file_exists( wasp_string filename ); 37 | wasp_string wasp_locate_file( wasp_string filename, wasp_list paths ); 38 | wasp_string wasp_locate_util( wasp_string utilname ); 39 | 40 | #define REQ_FILE_ARG( vn ) REQ_TYPED_ARG( vn, file ); 41 | #define OPT_FILE_ARG( vn ) OPT_TYPED_ARG( vn, file ); 42 | #define FILE_RESULT( x ) TYPED_RESULT( file, x ); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /vm/waspvm/format.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_FORMAT_H 18 | #define WASP_FORMAT_H 19 | 20 | #include "memory.h" 21 | #include 22 | 23 | void wasp_format_begin( wasp_string buf, void* o ); 24 | void wasp_format_end( wasp_string buf ); 25 | int wasp_format_item( wasp_string s, wasp_value v ); 26 | void wasp_format_value( 27 | wasp_string s, wasp_value v, wasp_quad breadth, wasp_quad depth 28 | ); 29 | wasp_string wasp_formatf( char* fmt, ... ); 30 | 31 | #define wasp_printf( fmt, ... ) wasp_printstr( wasp_formatf( fmt, __VA_ARGS__ ) ); 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /vm/waspvm/multimethod.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_MULTIMETHOD_H 18 | #define WASP_MULTIMETHOD_H 1 19 | 20 | #include "memory.h" 21 | 22 | WASP_BEGIN_TYPE( multimethod ) 23 | wasp_value signature; 24 | wasp_value func; 25 | wasp_value next; 26 | wasp_symbol name; 27 | WASP_END_TYPE( multimethod ) 28 | 29 | #define REQ_MULTIMETHOD_ARG( vn ) REQ_TYPED_ARG( vn, multimethod ) 30 | #define MULTIMETHOD_RESULT( vn ) TYPED_RESULT( multimethod, vn ) 31 | #define OPT_MULTIMETHOD_ARG( vn ) OPT_TYPED_ARG( vn, multimethod ) 32 | 33 | wasp_multimethod wasp_make_multimethod( 34 | wasp_value signature, wasp_value func, wasp_value next 35 | ); 36 | wasp_value wasp_reduce_function( wasp_value func, wasp_list args ); 37 | 38 | void wasp_init_multimethod_subsystem( ); 39 | 40 | static inline wasp_boolean wasp_is_function( wasp_value v ){ 41 | return wasp_is_closure( v ) 42 | || wasp_is_primitive( v ) 43 | || wasp_is_procedure( v ) 44 | || wasp_is_multimethod( v ); 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /vm/waspvm/number.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_INTEGER_H 18 | #define WASP_INTEGER_H 1 19 | 20 | #include "memory.h" 21 | 22 | struct wasp_number_data { 23 | struct wasp_object_data header; 24 | 25 | wasp_integer intval; 26 | }; 27 | typedef struct wasp_number_data* wasp_number; 28 | 29 | WASP_H_TP( number ); 30 | WASP_H_VF( number ); 31 | 32 | wasp_number wasp_nf_integer( wasp_integer x ); 33 | wasp_integer wasp_integer_fn( wasp_number x ); 34 | 35 | WASP_H_RQ( integer ); 36 | WASP_H_RQ( number ); 37 | 38 | #define REQ_INTEGER_ARG( vn ) wasp_integer vn = wasp_req_intarg( ); 39 | #define INTEGER_RESULT( vn ) RESULT( wasp_vf_integer( vn ) ); 40 | #define OPT_INTEGER_ARG( vn ) \ 41 | wasp_boolean has_##vn; \ 42 | wasp_integer vn = wasp_opt_intarg( &has_##vn ); 43 | 44 | wasp_boolean wasp_is_integer( wasp_value val ); 45 | wasp_boolean wasp_is_number( wasp_value val ); 46 | wasp_value wasp_vf_integer( wasp_integer ix ); 47 | wasp_integer wasp_integer_fv( wasp_value val ); 48 | 49 | wasp_integer wasp_number_compare( wasp_value a, wasp_value b ); 50 | wasp_integer wasp_req_intarg( ); 51 | wasp_integer wasp_opt_intarg( ); 52 | 53 | void wasp_init_number_subsystem( ); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /vm/waspvm/package.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_PACKAGE_H 18 | #define WASP_PACKAGE_H 19 | 20 | #include "memory.h" 21 | #include "string.h" 22 | 23 | wasp_value wasp_thaw_mem( const void* mem, wasp_quad len ); 24 | wasp_string wasp_freeze( wasp_value value ); 25 | 26 | static inline wasp_value wasp_thaw_str( wasp_string str ){ 27 | return wasp_thaw_mem( wasp_sf_string( str ), wasp_string_length( str ) ); 28 | } 29 | void wasp_init_package_subsystem(); 30 | wasp_pair wasp_thaw_tail( const char *name ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /vm/waspvm/parse.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | // These expressions can parse a S-Expression, as defined by Mosquito Lisp; 18 | // they do not do any pre-pass alteration of the contents, such as altering 19 | // '(...) to (quote ...) or `(...) to (quasiquote ...). 20 | 21 | #ifndef WASP_PARSE_H 22 | #define WASP_PARSE_H 1 23 | 24 | #include "memory.h" 25 | 26 | wasp_quad wasp_parse_dec( char** r_str, wasp_boolean* r_succ ); 27 | wasp_quad wasp_parse_hex( char** r_str, wasp_boolean* r_succ ); 28 | wasp_quad wasp_parse_hex2( char** r_str, wasp_boolean* r_succ ); 29 | wasp_integer wasp_parse_int( char** r_str, wasp_boolean* r_succ ); 30 | 31 | wasp_symbol wasp_parse_sym( char** r_str, wasp_boolean* r_succ ); 32 | 33 | wasp_string wasp_parse_str( char** r_str, wasp_boolean* r_succ ); 34 | wasp_list wasp_parse_list( char** r_str, wasp_boolean* r_succ ); 35 | wasp_value wasp_parse_value( char** r_str, wasp_boolean* r_succ ); 36 | wasp_list wasp_parse_document( char* doc, wasp_boolean* r_succ ); 37 | 38 | extern const char* wasp_parse_errmsg; 39 | extern wasp_integer wasp_parse_incomplete; 40 | 41 | void wasp_init_parse_subsystem( ); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /vm/waspvm/plugin.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * Portions copyright (C) 2006, Ephemeral Security, LLC -- used under the LGPL. 3 | * 4 | * This library is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU Lesser General Public License, version 2.1 6 | * as published by the Free Software Foundation. 7 | * 8 | * This library is distributed in the hope that it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | * for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public License 14 | * along with this library; if not, write to the Free Software Foundation, 15 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | #ifndef WASP_PLUGIN_H 19 | #define WASP_PLUGIN_H 1 20 | 21 | void wasp_init_plugin_subsystem( ); 22 | void wasp_load_plugin( const char* path, const char* init ); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /vm/waspvm/primitive.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_PRIMITIVE_H 18 | #define WASP_PRIMITIVE_H 1 19 | 20 | #include "memory.h" 21 | 22 | typedef void (*wasp_prim_fn)(); 23 | 24 | WASP_BEGIN_TYPE( primitive ) 25 | wasp_symbol name; 26 | wasp_prim_fn impl; 27 | wasp_byte code, a, b; // Only used for instructions. 28 | WASP_END_TYPE( primitive ) 29 | 30 | #define REQ_PRIMITIVE_ARG( vn ) REQ_TYPED_ARG( vn, primitive ) 31 | #define PRIMITIVE_RESULT( vn ) TYPED_RESULT( vn, primitive ) 32 | #define OPT_PRIMITIVE_ARG( vn ) OPT_TYPED_ARG( vn, primitive ) 33 | 34 | static inline wasp_symbol wasp_prim_name( wasp_primitive prim ){ 35 | return prim->name; 36 | } 37 | static inline wasp_prim_fn wasp_prim_impl( wasp_primitive prim ){ 38 | return prim->impl; 39 | } 40 | 41 | wasp_primitive wasp_make_primitive( const char* name, wasp_prim_fn impl ); 42 | void wasp_bind_primitive( const char* name, wasp_prim_fn impl ); 43 | 44 | extern wasp_pair wasp_arg_ptr; 45 | extern wasp_integer wasp_arg_ct; 46 | 47 | #define WASP_BIND_PRIM( pn ) \ 48 | wasp_bind_primitive( wasp_prim_##pn##_name, wasp_prim_##pn ); 49 | 50 | #define WASP_BEGIN_PRIM( ln, pn ) \ 51 | const char* wasp_prim_##pn##_name = ln; \ 52 | void wasp_prim_##pn( ){ 53 | 54 | #define WASP_END_PRIM( pn ) }; 55 | 56 | #define REST_ARGS( vn ) wasp_pair vn = wasp_arg_ptr; 57 | #define NO_REST_ARGS( vn ) wasp_no_more_args( ); 58 | 59 | void wasp_init_primitive_subsystem( ); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /vm/waspvm/print.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_PRINT_H 18 | #define WASP_PRINT_H 1 19 | 20 | #include "memory.h" 21 | 22 | void wasp_printmem( const void* mem, wasp_integer len ); 23 | void wasp_print( const char* st ); 24 | void wasp_printch( wasp_byte ch ); 25 | void wasp_printstr( wasp_string s ); 26 | void wasp_newline( ); 27 | void wasp_space( ); 28 | void wasp_show( wasp_value v ); 29 | void wasp_init_print_subsystem( ); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /vm/waspvm/procedure.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_PROCEDURE_H 18 | #define WASP_PROCEDURE_H 1 19 | 20 | #include "memory.h" 21 | 22 | struct wasp_procedure_data; 23 | typedef struct wasp_procedure_data* wasp_procedure_x; 24 | 25 | struct wasp_instruction_data { 26 | // Each instruction in the procedure refers to the procedure object; this 27 | // permits a closures and the virtual machine to not bother with managing 28 | // both a procedure pointer and an instruction pointer. 29 | 30 | wasp_procedure_x proc; 31 | wasp_primitive prim; 32 | wasp_value a; 33 | wasp_value b; 34 | }; 35 | typedef struct wasp_instruction_data* wasp_instruction; 36 | 37 | WASP_BEGIN_TYPE( procedure ) 38 | wasp_word length; 39 | struct wasp_instruction_data inst[0]; 40 | WASP_END_TYPE( procedure ) 41 | #define REQ_PROCEDURE_ARG( vn ) REQ_TYPED_ARG( vn, procedure ) 42 | #define PROCEDURE_RESULT( vn ) TYPED_RESULT( procedure, vn ) 43 | #define OPT_PROCEDURE_ARG( vn ) OPT_TYPED_ARG( vn, procedure ) 44 | 45 | wasp_procedure wasp_make_procedure( wasp_word length ); 46 | void wasp_dump_procedure( wasp_procedure procedure ); 47 | wasp_procedure wasp_assemble( wasp_pair source ); 48 | 49 | static inline wasp_instruction wasp_procedure_ref( 50 | wasp_procedure procedure, wasp_word index 51 | ){ 52 | assert( index < procedure->length ); return procedure->inst + index; 53 | } 54 | 55 | static inline wasp_word wasp_procedure_set( 56 | wasp_procedure procedure, wasp_word index, wasp_primitive prim, 57 | wasp_value a, wasp_value b 58 | ){ 59 | wasp_instruction instr = wasp_procedure_ref( procedure, index ); 60 | instr->prim = prim; 61 | instr->a = a; 62 | instr->b = b; 63 | } 64 | 65 | void wasp_format_instruction( wasp_string buf, wasp_instruction x ); 66 | 67 | void wasp_init_procedure_subsystem( ); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /vm/waspvm/queue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_QUEUE_H 18 | #define WASP_QUEUE_H 1 19 | 20 | /* Queue input channels are input channels that fetch values from the wrapped 21 | * message queue. 22 | */ 23 | 24 | WASP_BEGIN_SUBTYPE( input, queue_input ) 25 | void* queue; 26 | WASP_END_SUBTYPE( queue_input ); 27 | 28 | /* Queue output channels are output channels that add values to the wrapped 29 | * message queue. 30 | */ 31 | 32 | WASP_BEGIN_SUBTYPE( output, queue_output ) 33 | void* queue; 34 | WASP_END_SUBTYPE( queue_output ); 35 | 36 | /* The queue, in waspvm, is the replacement for the old Mosquito channels; 37 | * it wraps a primitive message queue, and provides an input and output 38 | * channel that interacts with that queue. 39 | */ 40 | 41 | WASP_BEGIN_TYPE( queue ) 42 | wasp_mq mq; 43 | wasp_queue_input input; 44 | wasp_queue_output output; 45 | WASP_END_TYPE( queue ); 46 | 47 | #define REQ_QUEUE_ARG( x ) REQ_TYPED_ARG( x, queue ) 48 | #define OPT_QUEUE_ARG( x ) OPT_TYPED_ARG( x, queue ) 49 | #define QUEUE_RESULT( x ) TYPED_RESULT( queue, x ) 50 | 51 | /* Creates a new queue, and all of the ancilliary objects wrapped by the queue. 52 | */ 53 | 54 | wasp_queue wasp_make_queue( ); 55 | 56 | /* Initializes the queue type, and binds primitives that manage queues. */ 57 | 58 | void wasp_init_queue_subsystem( ); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /vm/waspvm/stamp-h: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /vm/waspvm/stamp-h.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swdunlop/WaspVM/e451e5db4fac36b5018dd8df2722ae4ce2d127d1/vm/waspvm/stamp-h.in -------------------------------------------------------------------------------- /vm/waspvm/tag.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_TAG_H 18 | #define WASP_TAG_H 19 | 20 | #include "memory.h" 21 | 22 | WASP_BEGIN_TYPE( tag ) 23 | wasp_symbol name; 24 | wasp_value info; 25 | WASP_END_TYPE( tag ) 26 | 27 | WASP_BEGIN_TYPE( cell ) 28 | wasp_tag tag; 29 | wasp_value repr; 30 | WASP_END_TYPE( cell ) 31 | 32 | #define REQ_TAG_ARG( vn ) REQ_TYPED_ARG( vn, tag ) 33 | #define TAG_RESULT( vn ) TYPED_RESULT( tag, vn ) 34 | #define OPT_TAG_ARG( vn ) OPT_TYPED_ARG( vn, tag ) 35 | 36 | #define REQ_CELL_ARG( vn ) REQ_TYPED_ARG( vn, cell ) 37 | #define CELL_RESULT( vn ) TYPED_RESULT( cell, vn ) 38 | #define OPT_CELL_ARG( vn ) OPT_TYPED_ARG( vn, cell ) 39 | 40 | void wasp_init_tag_subsystem( ); 41 | wasp_boolean wasp_isaq( wasp_value x, wasp_value t ); 42 | #endif 43 | -------------------------------------------------------------------------------- /vm/waspvm/time.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Scott W. Dunlop 2 | * 3 | * Portions Copyright (C) 2006, Ephemeral Security, furnished via the LGPL. 4 | * 5 | * This library is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License, version 2.1 7 | * as published by the Free Software Foundation. 8 | * 9 | * This library is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 12 | * for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this library; if not, write to the Free Software Foundation, 16 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | #ifndef WASP_TIME_H 19 | #define WASP_TIME_H 1 20 | 21 | #include "memory.h" 22 | #include 23 | 24 | struct wasp_task_data; 25 | typedef struct wasp_task_data* wasp_task; 26 | 27 | typedef int (*wasp_task_mt)( wasp_task task ); 28 | 29 | struct wasp_task_data{ 30 | struct wasp_object_data header; 31 | 32 | struct timeval time; 33 | struct event event; 34 | 35 | wasp_task_mt task_mt; 36 | wasp_value context; 37 | 38 | int pending :1; 39 | }; 40 | 41 | WASP_H_TYPE( task ) 42 | 43 | #define REQ_TASK_ARG( x ) REQ_TYPED_ARG( x, task ) 44 | #define OPT_TASK_ARG( x ) OPT_TYPED_ARG( x, task ) 45 | #define TASK_RESULT( x ) TYPED_RESULT( task, x ) 46 | 47 | extern wasp_symbol wasp_ss_task; 48 | 49 | wasp_task wasp_make_task( wasp_task_mt mt, wasp_value context ); 50 | wasp_task wasp_schedule_task( wasp_task task, wasp_quad ms ); 51 | void wasp_cancel_task( wasp_task task ); 52 | 53 | void wasp_init_time_subsystem( ); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /vm/waspvm/vector.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_VECTOR_H 18 | #define WASP_VECTOR_H 1 19 | 20 | #include "memory.h" 21 | 22 | WASP_BEGIN_TYPE( vector ) 23 | wasp_integer length; 24 | wasp_value data[0]; 25 | WASP_END_TYPE( vector ) 26 | #define REQ_VECTOR_ARG( vn ) REQ_TYPED_ARG( vn, vector ) 27 | #define VECTOR_RESULT( vn ) TYPED_RESULT( vn, vector ) 28 | #define OPT_VECTOR_ARG( vn ) OPT_TYPED_ARG( vn, vector ) 29 | 30 | wasp_vector wasp_make_vector( wasp_integer length ); 31 | static inline wasp_integer wasp_vector_length( wasp_vector v ){ 32 | return v->length; 33 | } 34 | static inline wasp_value *wasp_vector_ref( wasp_vector v, wasp_integer offset ){ 35 | assert( 0 <= offset ); 36 | assert( offset < v->length ); 37 | return v->data + offset; 38 | } 39 | static inline wasp_value wasp_vector_get( wasp_vector v, wasp_integer offset ){ 40 | return *(wasp_vector_ref( v, offset )); 41 | } 42 | static inline void wasp_vector_put( wasp_vector v, wasp_integer offset, 43 | wasp_value x ){ 44 | *(wasp_vector_ref( v, offset )) = x; 45 | } 46 | 47 | wasp_vector wasp_copy_vector( wasp_vector vo, wasp_integer ln ); 48 | 49 | wasp_boolean wasp_eqvv( wasp_vector v1, wasp_vector v2 ); 50 | wasp_boolean wasp_equalv( wasp_vector v1, wasp_vector v2 ); 51 | 52 | void wasp_show_vector_contents( wasp_vector p, wasp_word* ct ); 53 | void wasp_show_vector( wasp_vector p, wasp_word* ct ); 54 | 55 | void wasp_init_vector_subsystem( ); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /vm/waspvm/vm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006, Ephemeral Security, LLC 2 | * 3 | * This library is free software; you can redistribute it and/or modify it 4 | * under the terms of the GNU Lesser General Public License, version 2.1 5 | * as published by the Free Software Foundation. 6 | * 7 | * This library is distributed in the hope that it will be useful, but WITHOUT 8 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 10 | * for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public License 13 | * along with this library; if not, write to the Free Software Foundation, 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef WASP_VM_H 18 | #define WASP_VM_H 1 19 | 20 | #include "memory.h" 21 | #include "primitive.h" 22 | #include 23 | 24 | WASP_BEGIN_TYPE( callframe ) 25 | wasp_callframe ap, cp; 26 | wasp_pair gp, ep; 27 | wasp_instruction ip; 28 | wasp_word count; 29 | wasp_pair head, tail; 30 | WASP_END_TYPE( callframe ) 31 | 32 | wasp_callframe wasp_make_callframe( ); 33 | 34 | extern wasp_callframe WASP_AP; 35 | extern wasp_callframe WASP_CP; 36 | extern wasp_pair WASP_EP; 37 | extern wasp_pair WASP_GP; 38 | extern wasp_instruction WASP_IP; 39 | extern wasp_value WASP_RX; 40 | extern wasp_integer WASP_T; 41 | 42 | extern wasp_primitive wasp_instr_table[]; 43 | extern wasp_boolean wasp_uses_a[]; 44 | extern wasp_boolean wasp_uses_b[]; 45 | extern wasp_byte wasp_max_opcode; 46 | 47 | void wasp_inner_exec( ); 48 | void wasp_outer_exec( ); 49 | 50 | void wasp_trace_registers(); 51 | void wasp_init_vm_subsystem( ); 52 | 53 | extern wasp_symbol wasp_es_vm; 54 | 55 | jmp_buf* wasp_interp_xp; 56 | jmp_buf* wasp_proc_xp; 57 | 58 | void wasp_chain( wasp_pair data ); 59 | void wasp_chainf( wasp_value fn, wasp_word ct, ... ); 60 | void wasp_interp_loop( ); 61 | 62 | wasp_primitive wasp_lookup_op( wasp_symbol name ); 63 | wasp_value wasp_req_function( wasp_value v ); 64 | wasp_value wasp_reduce_function( wasp_value fn, wasp_list args ); 65 | #endif 66 | --------------------------------------------------------------------------------