├── test ├── files │ └── .gitkeep ├── executables │ ├── test_args │ ├── test_exit_status │ ├── test_io │ └── test_with_sleep ├── tests │ ├── basic │ │ ├── arithmetic │ │ │ ├── test.out │ │ │ └── test.in │ │ ├── object │ │ │ ├── test.out │ │ │ └── test.in │ │ ├── list │ │ │ ├── test.out │ │ │ └── test.in │ │ ├── property │ │ │ ├── test.out │ │ │ └── test.in │ │ ├── value │ │ │ ├── test.out │ │ │ └── test.in │ │ └── string │ │ │ ├── test.out │ │ │ └── test.in │ ├── lib │ │ ├── moo_err.rb │ │ ├── moo_obj.rb │ │ ├── test_helper.rb │ │ ├── fast_error_parser.rb │ │ ├── fuzz.rb │ │ └── general_expression_parser.rb │ ├── Broken4.db │ ├── Broken5.db │ ├── test_basic.rb │ ├── Broken3.db │ ├── test_equality.rb │ ├── Broken1.db │ ├── test_system_builtins.rb │ ├── test_verb_cache.rb │ ├── test_things_that_used_to_crash_the_server.rb │ ├── test_eval.rb │ ├── Broken2.db │ ├── test_miscellaneous.rb │ ├── Anon6.db │ ├── test_switch_player.rb │ ├── Anon3.db │ ├── Anon1.db │ ├── Anon5.db │ ├── Anon2.db │ ├── Anon4.db │ ├── Suspended.db │ └── test_huh.rb ├── test.yml ├── Gemfile ├── Gemfile.lock ├── Makefile ├── README.tests └── Test.db ├── src ├── include │ ├── curl.h │ ├── system.h │ ├── db_tune.h │ ├── fileio.h │ ├── str_intern.h │ ├── pcre_moo.h │ ├── collection.h │ ├── quota.h │ ├── tokens.h │ ├── match.h │ ├── code_gen.h │ ├── verbs.h │ ├── my-math.h │ ├── disassemble.h │ ├── decompile.h │ ├── random.h │ ├── parser.h │ ├── keywords.h │ ├── pattern.h │ ├── sqlite.h │ ├── eval_env.h │ ├── timers.h │ ├── numbers.h │ ├── log.h │ ├── json.h │ ├── crypto.h │ ├── unparse.h │ ├── parse_cmd.h │ ├── garbage.h │ ├── eval_vm.h │ ├── exec.h │ ├── background.h │ ├── bf_register.h │ ├── program.h │ ├── waif.h │ ├── sym_table.h │ ├── streams.h │ ├── config.h.cmake │ ├── base64.h │ ├── net_mplex.h │ ├── map.h │ ├── utils.h │ ├── functions.h │ ├── version.h │ └── list.h ├── dependencies │ ├── yajl │ │ ├── yajl_version.c │ │ ├── yajl_version.h │ │ ├── COPYING │ │ ├── yajl_alloc.h │ │ ├── yajl_encode.h │ │ ├── yajl_alloc.c │ │ ├── yajl_buf.h │ │ ├── yajl_parser.h │ │ ├── yajl_bytestack.h │ │ ├── yajl_common.h │ │ └── yajl_buf.c │ ├── crypt │ │ ├── LINKS │ │ ├── crypt_blowfish.h │ │ ├── crypt_gensalt.h │ │ ├── PERFORMANCE │ │ └── README │ ├── LICENSE_THPOOL │ ├── strnatcmp.h │ ├── linenoise.h │ └── xtrapbits.h ├── .astylerc ├── net_mplex.cc ├── quota.cc ├── net_mp_selct.cc ├── system.cc ├── spellcheck.cc ├── keywords.gperf ├── net_mp_poll.cc ├── collection.cc └── program.cc ├── .gitignore ├── CMakeModules ├── Findgperf.cmake ├── FindArgon2.cmake ├── FindSQLite3.cmake ├── FindNettle.cmake ├── FindPCRE.cmake └── version.cmake ├── docs ├── ServerDevelopment │ ├── HACKING │ └── AddingNewMOOTypes.txt ├── Contributors.md ├── Legacy │ └── ChangeLogs │ │ └── ChangeLog-FileIO.txt └── Features │ ├── new_options.md │ ├── new_miscellaneous.md │ └── new_builtins.md ├── Minimal.db └── restart.sh /test/files/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/executables/test_args: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo -n $* 3 | -------------------------------------------------------------------------------- /test/executables/test_exit_status: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | exit $1 3 | -------------------------------------------------------------------------------- /test/executables/test_io: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | read i 3 | echo -n $i >&1 4 | echo -n $i >&2 5 | -------------------------------------------------------------------------------- /test/tests/basic/arithmetic/test.out: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | 35 4 | -3 5 | 2 6 | 1 7 | 5.5 8 | 12 9 | 2.0 10 | -------------------------------------------------------------------------------- /test/test.yml: -------------------------------------------------------------------------------- 1 | host: localhost 2 | port: 9898 3 | verbose: false 4 | ownership_quota: false 5 | 64bit: true 6 | -------------------------------------------------------------------------------- /test/executables/test_with_sleep: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sleep 1 3 | echo 1 4 | sleep 2 5 | echo 2 6 | sleep 3 7 | echo 3 8 | -------------------------------------------------------------------------------- /src/include/curl.h: -------------------------------------------------------------------------------- 1 | #ifndef CURL_H 2 | #define CURL_H 3 | 4 | extern void curl_shutdown(void); 5 | 6 | #endif /* CURL_H */ 7 | -------------------------------------------------------------------------------- /test/tests/lib/moo_err.rb: -------------------------------------------------------------------------------- 1 | class MooErr < Struct.new(:err) 2 | 3 | alias inspect err 4 | alias to_s err 5 | 6 | end 7 | -------------------------------------------------------------------------------- /test/tests/lib/moo_obj.rb: -------------------------------------------------------------------------------- 1 | class MooObj < Struct.new(:obj) 2 | 3 | alias inspect obj 4 | alias to_s obj 5 | 6 | end 7 | -------------------------------------------------------------------------------- /test/tests/basic/object/test.out: -------------------------------------------------------------------------------- 1 | #2 2 | "" 3 | #-1 4 | {} 5 | 0 6 | 0 7 | 0 8 | 0 9 | 0 10 | 0 11 | 0 12 | 1 13 | {} 14 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_version.c: -------------------------------------------------------------------------------- 1 | #include "yajl_version.h" 2 | 3 | int yajl_version(void) 4 | { 5 | return YAJL_VERSION; 6 | } 7 | -------------------------------------------------------------------------------- /src/include/system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * system.h 3 | * 4 | */ 5 | 6 | #ifndef EXT_SYS_H 7 | 8 | #define EXT_SYS_H 1 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /test/tests/basic/arithmetic/test.in: -------------------------------------------------------------------------------- 1 | 1 + 1 2 | 4 - 2 3 | 5 * 7 4 | 8 - 11 5 | 12 / 6 6 | 12 / 7 7 | 11.0 - 5.5 8 | (2 + 2) * 3 9 | sqrt(4.0) 10 | -------------------------------------------------------------------------------- /test/tests/basic/list/test.out: -------------------------------------------------------------------------------- 1 | 3 2 | {1, 2, 3} 3 | {1, 3, 2} 4 | {1, 3, 2} 5 | {3, 1, 2} 6 | {1, 3} 7 | {1, 4, 3} 8 | {1, 2, 3} 9 | {1, 2} 10 | -------------------------------------------------------------------------------- /test/Gemfile: -------------------------------------------------------------------------------- 1 | # -*- ruby -*- 2 | 3 | source 'http://rubygems.org' 4 | 5 | ruby '>= 2.3.1' 6 | 7 | group :test do 8 | gem 'parslet' 9 | gem 'minitest' 10 | gem 'test-unit' 11 | end 12 | -------------------------------------------------------------------------------- /test/tests/basic/property/test.out: -------------------------------------------------------------------------------- 1 | {1, 0} 2 | {1, 0} 3 | {1, #1} 4 | {1, 1} 5 | {1, 0} 6 | 1 7 | 1 8 | {1, 2} 9 | 0 10 | 2 11 | {"test"} 12 | {} 13 | {1, 0} 14 | 1 15 | 1 16 | {1, 0} 17 | {1, 0} 18 | -------------------------------------------------------------------------------- /src/include/db_tune.h: -------------------------------------------------------------------------------- 1 | /* This is just a stub for now; various db-layer-specific tuning functions 2 | * will eventually live here. 3 | */ 4 | 5 | extern void db_log_cache_stats(void); 6 | extern Var db_verb_cache_stats(void); 7 | -------------------------------------------------------------------------------- /src/.astylerc: -------------------------------------------------------------------------------- 1 | --indent=spaces=4 2 | --indent-preproc-block 3 | --pad-oper 4 | --pad-comma 5 | --pad-header 6 | # --align-pointer=name 7 | # --align-reference=name 8 | --keep-one-line-statements 9 | --convert-tabs 10 | --indent-switches 11 | --suffix=none 12 | -------------------------------------------------------------------------------- /test/tests/lib/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | 3 | require 'moo_support' 4 | require 'fuzz' 5 | 6 | if defined?(Test::Unit::TestCase) 7 | 8 | class Test::Unit::TestCase 9 | include MooSupport 10 | include Fuzz 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /test/tests/basic/list/test.in: -------------------------------------------------------------------------------- 1 | length({1, 2, 3}) 2 | listappend({1, 2}, 3) 3 | listappend({1, 2}, 3, 1) 4 | listinsert({1, 2}, 3, 2) 5 | listinsert({1, 2}, 3, 1) 6 | listdelete({1, 2, 3}, 2) 7 | listset({1, 2, 3}, 4, 2) 8 | setadd({1, 2}, 3) 9 | setadd({1, 2}, 2) 10 | -------------------------------------------------------------------------------- /test/tests/basic/value/test.out: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 1 4 | 1 5 | 1 6 | "17" 7 | "3.0" 8 | "#0" 9 | "{list}" 10 | "17" 11 | "3.0" 12 | "#0" 13 | "{1, 2}" 14 | 10 15 | 3 16 | 2 17 | -34 18 | #2 19 | #2 20 | #0 21 | 34.0 22 | 34.7 23 | 7.3 24 | 1 25 | 0 26 | 1 27 | 1 28 | 0 29 | -------------------------------------------------------------------------------- /test/tests/basic/object/test.in: -------------------------------------------------------------------------------- 1 | parent(create(#2)) 2 | create(#2).name 3 | create(#2).location 4 | create(#2).contents 5 | create(#2).programmer 6 | create(#2).wizard 7 | create(#2).r 8 | create(#2).w 9 | create(#2).f 10 | is_player(create(#2)) 11 | valid(#-1) 12 | valid(#0) 13 | children(#0) 14 | -------------------------------------------------------------------------------- /test/tests/basic/string/test.out: -------------------------------------------------------------------------------- 1 | 3 2 | "fooquxxbaz" 3 | 4 4 | 0 5 | 4 6 | 0 7 | 0 8 | 7 9 | 0 10 | 7 11 | 1 12 | 1 13 | 1 14 | 0 15 | {"foo"} 16 | {"foo", 13, 10} 17 | {"foo", 10, "bar", 10} 18 | {102, 111, 111, 13, 10} 19 | "~7Efoo" 20 | "foo~0Abar~0D" 21 | "foo~0Abar~0D" 22 | "SAEmC5UwrAl2A" 23 | -------------------------------------------------------------------------------- /src/include/fileio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileio.h 3 | * 4 | */ 5 | 6 | #ifndef EXT_FILE_IO_H 7 | 8 | #define EXT_FILE_IO_H 1 9 | 10 | static char *line_read; 11 | size_t line_size = 0; 12 | extern const char *file_subdir; 13 | 14 | extern const char *file_resolve_path(const char *pathname); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /test/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | minitest (5.20.0) 5 | parslet (2.0.0) 6 | power_assert (2.0.3) 7 | test-unit (3.6.1) 8 | power_assert 9 | 10 | PLATFORMS 11 | ruby 12 | 13 | DEPENDENCIES 14 | minitest 15 | parslet 16 | test-unit 17 | 18 | RUBY VERSION 19 | ruby 2.4.7p357 20 | 21 | BUNDLED WITH 22 | 2.3.26 23 | -------------------------------------------------------------------------------- /test/tests/lib/fast_error_parser.rb: -------------------------------------------------------------------------------- 1 | require 'parslet' 2 | 3 | require 'moo_err' 4 | 5 | class FastErrorParser < Parslet::Parser 6 | 7 | rule(:error) { 8 | str('{2, {') >> (str('E_') >> match('[A-Z]').repeat(1)).as(:err) >> any.repeat 9 | } 10 | 11 | root :error 12 | 13 | end 14 | 15 | class FastErrorTransform < Parslet::Transform 16 | 17 | rule(:err => simple(:err)) { MooErr.new(err) } 18 | 19 | end 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | configure 3 | autom4te.cache 4 | config.h 5 | config.log 6 | config.status 7 | y.tab.h 8 | version_options.h 9 | version_src*.h 10 | keywords.c 11 | *.o 12 | moo 13 | \#*\# 14 | .\#* 15 | backups 16 | removed_code 17 | a.out 18 | ctags 19 | configure 20 | xcode 21 | Makefile.in.bak 22 | keywords.cc 23 | build 24 | .vscode 25 | test/executables/true 26 | test/executables/sleep 27 | test/executables/echo 28 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all tests clean 2 | 3 | TEST_FILES := $(wildcard tests/*.rb) 4 | 5 | tests: $(TEST_FILES) 6 | @for test in $^; do \ 7 | echo -e "\n\nRunning $$test..." ; \ 8 | ruby -r rubygems -Itests/lib $$test ; \ 9 | done 10 | 11 | %: tests/%.rb 12 | @echo -e "\n\nRunning $<..." ; \ 13 | ruby -r rubygems -Itests/lib $< 14 | 15 | clean: 16 | @rm -f /tmp/Bar.db /tmp/Baz.db /tmp/Foo.db 17 | @rm -f ./moo 18 | 19 | .DEFAULT_GOAL := tests 20 | -------------------------------------------------------------------------------- /test/tests/lib/fuzz.rb: -------------------------------------------------------------------------------- 1 | module Fuzz 2 | 3 | G = ' !#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~' 4 | 5 | def with_mutating_binary_string(s) 6 | g = Enumerator.new do |g| 7 | while true 8 | t = s.dup 9 | rand(t.length / 5).times do 10 | t[rand(t.length)] = G[rand(G.length)] 11 | end 12 | g.yield t 13 | end 14 | end 15 | yield g 16 | end 17 | 18 | end 19 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_version.h: -------------------------------------------------------------------------------- 1 | #ifndef YAJL_VERSION_H_ 2 | #define YAJL_VERSION_H_ 3 | 4 | #include "yajl_common.h" 5 | 6 | #define YAJL_MAJOR 1 7 | #define YAJL_MINOR 0 8 | #define YAJL_MICRO 12 9 | 10 | #define YAJL_VERSION ((YAJL_MAJOR * 10000) + (YAJL_MINOR * 100) + YAJL_MICRO) 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | extern int YAJL_API yajl_version(void); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif /* YAJL_VERSION_H_ */ 23 | -------------------------------------------------------------------------------- /CMakeModules/Findgperf.cmake: -------------------------------------------------------------------------------- 1 | # - Find gperf 2 | # gperf_EXECUTABLE - Path to the gperf executable 3 | # gperf_FOUND - True if gperf found. 4 | 5 | IF (gperf_FOUND) 6 | # Already in cache, be silent 7 | SET(gperf_FIND_QUIETLY TRUE) 8 | ENDIF () 9 | 10 | FIND_PROGRAM(gperf_EXECUTABLE gperf) 11 | 12 | # handle the QUIETLY and REQUIRED arguments and set gperf_FOUND to TRUE if 13 | # all listed variables are TRUE 14 | INCLUDE(FindPackageHandleStandardArgs) 15 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(gperf DEFAULT_MSG gperf_EXECUTABLE) 16 | -------------------------------------------------------------------------------- /test/tests/basic/value/test.in: -------------------------------------------------------------------------------- 1 | typeof(3) == INT 2 | typeof("abc") == STR 3 | typeof(1.0) == FLOAT 4 | typeof({"foo"}) == LIST 5 | typeof(#0) == OBJ 6 | tostr(17) 7 | tostr(3.0) 8 | tostr(#0) 9 | tostr({1, 2}) 10 | toliteral(17) 11 | toliteral(3.0) 12 | toliteral(#0) 13 | toliteral({1, 2}) 14 | toint(10) 15 | toint(3.0) 16 | toint(#2) 17 | toint("-34") 18 | toobj("2") 19 | toobj(2) 20 | toobj("foo") 21 | tofloat(34) 22 | tofloat("34.7") 23 | tofloat(7.3) 24 | equal(1 + 1, 2) 25 | equal("Foo", "foo") 26 | equal("foo", "foo") 27 | equal({1, 2}, {1, 2}) 28 | equal({1, 2}, {1, 3}) 29 | -------------------------------------------------------------------------------- /test/tests/basic/string/test.in: -------------------------------------------------------------------------------- 1 | length("foo") 2 | strsub("foobarbaz", "bar", "quxx") 3 | index("foobar", "bar") 4 | index("foobar", "baz") 5 | index("fooBar", "bar") 6 | index("fooBar", "baz") 7 | index("fooBar", "bar", 1) 8 | rindex("bazbarbazfoo", "baz") 9 | rindex("bazbarbazfoo", "quxx") 10 | rindex("bazbarBazfoo", "baz") 11 | rindex("bazbarBazfoo", "baz", 1) 12 | strcmp("abc", "abd") < 0 13 | strcmp("abd", "abc") > 0 14 | strcmp("abc", "abc") 15 | decode_binary("foo") 16 | decode_binary("foo~0D~0A") 17 | decode_binary("foo~0Abar~0A") 18 | decode_binary("foo~0D~0A", 1) 19 | encode_binary("~foo") 20 | encode_binary({"foo", 10}, {"bar", 13}) 21 | encode_binary("foo", 10, "bar", 13) 22 | crypt("foobar", "SA") 23 | -------------------------------------------------------------------------------- /docs/ServerDevelopment/HACKING: -------------------------------------------------------------------------------- 1 | Those inclined to hack the server sources 2 | may wish to read some or all of the following: 3 | 4 | (1) version_src.txt 5 | 6 | How source information gets included into the executable, and 7 | What you need to do if you are a package maintainer or 8 | are running a public server with sources modified beyond 9 | the usual (un)setting of options.h macros. 10 | 11 | (2) AddingNewMOOTypes.txt 12 | 13 | A list of all of the places that need to be modified if you are adding 14 | a new value type to the MOO language/server. 15 | 16 | (3) MOOCodeSequences.txt 17 | 18 | How all of the statement/expression constructs in the language 19 | translate to byte code. 20 | 21 | -------------------------------------------------------------------------------- /test/tests/Broken4.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 5 ** 2 | 4 3 | 1 4 | 0 5 | 1 6 | 3 7 | #0 8 | System Object 9 | 16 10 | 3 11 | 1 12 | 2 13 | 4 14 | 0 15 | 4 16 | 1 17 | 1 18 | 1 19 | 4 20 | 0 21 | 1 22 | server_started 23 | 3 24 | 173 25 | -1 26 | 0 27 | 0 28 | #1 29 | Root Class 30 | 16 31 | 3 32 | 1 33 | 2 34 | 4 35 | 0 36 | 4 37 | 1 38 | 1 39 | -1 40 | 4 41 | 0 42 | 0 43 | 0 44 | 0 45 | #2 46 | The First Room 47 | 0 48 | 3 49 | 1 50 | -1 51 | 4 52 | 0 53 | 4 54 | 1 55 | 1 56 | 1 57 | 4 58 | 0 59 | 1 60 | eval 61 | 3 62 | 88 63 | -2 64 | 0 65 | 0 66 | #3 67 | Wizard 68 | 7 69 | 3 70 | 1 71 | 2 72 | 4 73 | 0 74 | 4 75 | 1 76 | 1 77 | 1 78 | 4 79 | 0 80 | 0 81 | 0 82 | 0 83 | #0:0 84 | shutdown(); 85 | . 86 | 0 clocks 87 | 0 queued tasks 88 | 0 suspended tasks 89 | -------------------------------------------------------------------------------- /test/tests/basic/property/test.in: -------------------------------------------------------------------------------- 1 | eval("add_property(#0, \"temp\", 0, { #3, \"rwc\" }); return 0;") 2 | eval("add_property(#0, \"temp0\", 0, { #3, \"rwc\" }); return 0;") 3 | eval("$temp = create(#1); return parent($temp);") 4 | eval("$temp0 = create($temp); return parent($temp0) == $temp;") 5 | eval("add_property($temp, \"test\", 1, { #3, \"rwc\" }); return 0;") 6 | $temp.test 7 | is_clear_property($temp0, "test") 8 | eval("$temp0.test = 2; return $temp0.test;") 9 | is_clear_property($temp0, "test") 10 | $temp0.test 11 | properties($temp) 12 | properties($temp0) 13 | eval("clear_property($temp0, \"test\"); return 0;") 14 | is_clear_property($temp0, "test") 15 | $temp0.test 16 | eval("delete_property(#0, \"temp\"); return 0;") 17 | eval("delete_property(#0, \"temp0\"); return 0;") 18 | -------------------------------------------------------------------------------- /test/tests/Broken5.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 5 ** 2 | 4 3 | 1 4 | 0 5 | 1 6 | 3 7 | #0 8 | System Object 9 | 16 10 | 3 11 | 1 12 | -1 13 | 4 14 | 0 15 | 4 16 | 0 17 | 4 18 | 0 19 | 1 20 | server_started 21 | 3 22 | 173 23 | -1 24 | 0 25 | 0 26 | #1 27 | Root Class 28 | 16 29 | 3 30 | 1 31 | -1 32 | 4 33 | 0 34 | 4 35 | 1 36 | 1 37 | -1 38 | 4 39 | 3 40 | 1 41 | 0 42 | 1 43 | 2 44 | 1 45 | 3 46 | 0 47 | 0 48 | 0 49 | #2 50 | The First Room 51 | 0 52 | 3 53 | 1 54 | -1 55 | 4 56 | 1 57 | 1 58 | 3 59 | 4 60 | 0 61 | 4 62 | 0 63 | 1 64 | eval 65 | 3 66 | 88 67 | -2 68 | 0 69 | 0 70 | #3 71 | Wizard 72 | 7 73 | 3 74 | 1 75 | -1 76 | 4 77 | 0 78 | 4 79 | 0 80 | 4 81 | 0 82 | 0 83 | 0 84 | 0 85 | #0:0 86 | shutdown(); 87 | . 88 | 0 clocks 89 | 0 queued tasks 90 | 0 suspended tasks 91 | -------------------------------------------------------------------------------- /test/tests/test_basic.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | # Run the tests in test/basic 4 | # Props to Elly Fong-Jones (https://github.com/elly) for the 5 | # test files. 6 | 7 | class TestBasic < Test::Unit::TestCase 8 | 9 | Dir['test/basic/*'].each do |dir| 10 | define_method((['test', 'everything', 'in'] + dir.split('/')[1..-1]).join('_')) do 11 | run_test_as('wizard') do 12 | Dir["#{dir}/*in"].each do |test| 13 | inp = open(test) 14 | outp = open(test.gsub(/in$/, 'out')) 15 | while (inl = inp.gets) 16 | assert_equal outp.gets.chomp, simplify(command(%Q|; return toliteral(#{inl.chomp});|)) 17 | end 18 | inp.close 19 | outp.close 20 | end 21 | end 22 | end 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /Minimal.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 1 ** 2 | 4 3 | 2 4 | 0 5 | 1 6 | 3 7 | #0 8 | System Object 9 | 10 | 16 11 | 3 12 | -1 13 | -1 14 | -1 15 | 1 16 | -1 17 | 2 18 | 2 19 | do_start_script 20 | 3 21 | 173 22 | -1 23 | do_login_command 24 | 3 25 | 173 26 | -1 27 | 0 28 | 0 29 | #1 30 | Root Class 31 | 32 | 16 33 | 3 34 | -1 35 | -1 36 | -1 37 | -1 38 | 0 39 | -1 40 | 0 41 | 0 42 | 0 43 | #2 44 | The First Room 45 | 46 | 0 47 | 3 48 | -1 49 | 3 50 | -1 51 | 1 52 | -1 53 | 3 54 | 1 55 | eval 56 | 3 57 | 89 58 | -2 59 | 0 60 | 0 61 | #3 62 | Wizard 63 | 64 | 7 65 | 3 66 | 2 67 | -1 68 | -1 69 | 1 70 | -1 71 | -1 72 | 0 73 | 0 74 | 0 75 | #0:0 76 | callers() && raise(E_PERM); 77 | return eval(@args); 78 | . 79 | #0:1 80 | return #3; 81 | . 82 | 0 clocks 83 | 0 queued tasks 84 | 0 suspended tasks 85 | -------------------------------------------------------------------------------- /test/tests/Broken3.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 5 ** 2 | 4 3 | 1 4 | 0 5 | 1 6 | 3 7 | #0 8 | System Object 9 | 16 10 | 3 11 | 1 12 | 1 13 | 4 14 | 0 15 | 1 16 | 1 17 | 4 18 | 0 19 | 1 20 | server_started 21 | 3 22 | 173 23 | -1 24 | 0 25 | 0 26 | #1 27 | Root Class 28 | 16 29 | 3 30 | 1 31 | 3 32 | 4 33 | 0 34 | 4 35 | 1 36 | 1 37 | 3 38 | 4 39 | 3 40 | 1 41 | 0 42 | 1 43 | 2 44 | 1 45 | 3 46 | 0 47 | 0 48 | 0 49 | #2 50 | The First Room 51 | 0 52 | 3 53 | 1 54 | 0 55 | 4 56 | 1 57 | 1 58 | 3 59 | 4 60 | 1 61 | 1 62 | 0 63 | 4 64 | 0 65 | 1 66 | eval 67 | 3 68 | 88 69 | -2 70 | 0 71 | 0 72 | #3 73 | Wizard 74 | 7 75 | 3 76 | 1 77 | 2 78 | 4 79 | 0 80 | 4 81 | 1 82 | 1 83 | 2 84 | 4 85 | 0 86 | 0 87 | 0 88 | 0 89 | #0:0 90 | shutdown(); 91 | . 92 | 0 clocks 93 | 0 queued tasks 94 | 0 suspended tasks 95 | -------------------------------------------------------------------------------- /src/include/str_intern.h: -------------------------------------------------------------------------------- 1 | 2 | /* A string intern table. 3 | * 4 | * The intern table holds a list of strings. Given a new string, we 5 | * either str_dup it and add it to the table or return a ref to the 6 | * existing copy of the string from the table if present. 7 | * 8 | * This implementation has one big intern table that's designed to be 9 | * used during db load then freed all at once. It might be 10 | * interesting to intern all strings even during runtime. Somebody 11 | * else can do this. 12 | * */ 13 | 14 | #ifndef Str_Intern_h 15 | #define Str_Intern_h 16 | 17 | /* 0 for a default size */ 18 | extern void str_intern_open(int table_size); 19 | extern void str_intern_close(void); 20 | 21 | /* Make an immutable copy of s. If there's an intern table open, 22 | possibly share storage. */ 23 | extern const char *str_intern(const char *s); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /CMakeModules/FindArgon2.cmake: -------------------------------------------------------------------------------- 1 | # - Find Argon2 2 | # Find the Argon2 include directory and library 3 | # 4 | # ARGON2_INCLUDE_DIR - where to find , etc. 5 | # ARGON2_LIBRARIES - List of libraries when using libnettle. 6 | # ARGON2_FOUND - True if libnettle found. 7 | 8 | IF (ARGON2_INCLUDE_DIR) 9 | # Already in cache, be silent 10 | SET(ARGON2_FIND_QUIETLY TRUE) 11 | ENDIF (ARGON2_INCLUDE_DIR) 12 | 13 | FIND_PATH(ARGON2_INCLUDE_DIR argon2.h) 14 | FIND_LIBRARY(ARGON2_LIBRARY argon2) 15 | 16 | # handle the QUIETLY and REQUIRED arguments and set ARGON2_FOUND to TRUE if 17 | # all listed variables are TRUE 18 | INCLUDE(FindPackageHandleStandardArgs) 19 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Argon2 DEFAULT_MSG ARGON2_LIBRARY ARGON2_INCLUDE_DIR) 20 | 21 | IF(ARGON2_FOUND) 22 | SET(ARGON2_LIBRARIES ${ARGON2_LIBRARY}) 23 | ENDIF(ARGON2_FOUND) 24 | -------------------------------------------------------------------------------- /docs/Contributors.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | LambdaMOO, Stunt, and now ToastStunt are the cumulative work of dozens of 3 | developers over several decades. The original contributors include: 4 | 5 | - Pavel Curtis 6 | - Erik Ostrom 7 | - Jay Carlson (nop) 8 | - Ben Jackson (bjj) 9 | - James Deikun (xplat) 10 | - Ken Fox (xythian) 11 | - Roger Crew (wrog) 12 | - Phil Schwan (pschwan) 13 | 14 | Contributors to Stunt include: 15 | 16 | - [Todd Sundsted](http://www.google.com/search?q=todd+sundsted) 17 | - Steve Wainstead 18 | - Tim van Dijen 19 | 20 | Contributors to ToastStunt include: 21 | 22 | - [lisdude](https://lisdude.com) 23 | - [DistantOrigin](https://github.com/distantorigin) 24 | - [Tyler Littlefield](http:/tysdomain.com) 25 | - [Seven Ecks](https://github.com/sevenecks) 26 | 27 | To see all contributions, refer to the [GitHub Contributors](https://github.com/lisdude/toaststunt/graphs/contributors) page. 28 | -------------------------------------------------------------------------------- /CMakeModules/FindSQLite3.cmake: -------------------------------------------------------------------------------- 1 | # - Find SQLite3 2 | # Find the SQLite3 include directory and library 3 | # 4 | # SQLITE3_INCLUDE_DIR - where to find , etc. 5 | # SQLITE3_LIBRARIES - List of libraries when using sqlite. 6 | # SQLITE3_FOUND - True if sqlite found. 7 | 8 | IF (SQLITE3_INCLUDE_DIR) 9 | # Already in cache, be silent 10 | SET(SQLITE3_FIND_QUIETLY TRUE) 11 | ENDIF (SQLITE3_INCLUDE_DIR) 12 | 13 | FIND_PATH(SQLITE3_INCLUDE_DIR NAMES sqlite3.h) 14 | FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3) 15 | 16 | # handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE if 17 | # all listed variables are TRUE 18 | INCLUDE(FindPackageHandleStandardArgs) 19 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLite3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR) 20 | 21 | IF(SQLITE3_FOUND) 22 | SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY}) 23 | ENDIF(SQLITE3_FOUND) 24 | -------------------------------------------------------------------------------- /test/tests/test_equality.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestEquality < Test::Unit::TestCase 4 | 5 | def test_that_tests_for_equality_work 6 | run_test_as('programmer') do 7 | assert_equal 1, eval(%|return 10 == 5 + 5;|) 8 | assert_equal 1, eval(%|return 10.0 == 5.0 + 5.0;|) 9 | assert_equal 1, eval(%|return "10" == "1" + "0";|) 10 | assert_equal 1, eval(%|return #10 == #10;|) 11 | assert_equal 1, eval(%|return E_NONE == E_NONE;|) 12 | assert_equal 1, eval(%|x = {1, 2.0}; y = {#3, "four"}; return {1, 2.0, #3, "four"} == {@x, @y};|) 13 | assert_equal 1, eval(%|x = []; x[1] = 2.0; x[#3] = "four"; return [1 -> 2.0, #3 -> "four"] == x;|) 14 | 15 | assert_equal 0, eval(%|return 1 == 1.0;|) 16 | assert_equal 0, eval(%|return 1.0 == #1;|) 17 | assert_equal 0, eval(%|return #1 == "1";|) 18 | assert_equal 0, eval(%|return [] == {};|) 19 | end 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /CMakeModules/FindNettle.cmake: -------------------------------------------------------------------------------- 1 | # - Find Nettle 2 | # Find the Nettle include directory and library 3 | # 4 | # NETTLE_INCLUDE_DIR - where to find , etc. 5 | # NETTLE_LIBRARIES - List of libraries when using libnettle. 6 | # NETTLE_FOUND - True if libnettle found. 7 | 8 | IF (NETTLE_INCLUDE_DIR) 9 | # Already in cache, be silent 10 | SET(NETTLE_FIND_QUIETLY TRUE) 11 | ENDIF (NETTLE_INCLUDE_DIR) 12 | 13 | FIND_PATH(NETTLE_INCLUDE_DIR nettle/md5.h nettle/ripemd160.h nettle/sha.h) 14 | FIND_LIBRARY(NETTLE_LIBRARY NAMES nettle libnettle) 15 | 16 | # handle the QUIETLY and REQUIRED arguments and set NETTLE_FOUND to TRUE if 17 | # all listed variables are TRUE 18 | INCLUDE(FindPackageHandleStandardArgs) 19 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Nettle DEFAULT_MSG NETTLE_LIBRARY NETTLE_INCLUDE_DIR) 20 | 21 | IF(NETTLE_FOUND) 22 | SET(NETTLE_LIBRARIES ${NETTLE_LIBRARY}) 23 | ENDIF(NETTLE_FOUND) 24 | -------------------------------------------------------------------------------- /test/tests/Broken1.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 5 ** 2 | 4 3 | 1 4 | 0 5 | 1 6 | 3 7 | #0 8 | System Object 9 | 16 10 | 3 11 | 1 12 | 101 13 | 4 14 | 1 15 | 1 16 | 102 17 | 4 18 | 2 19 | 1 20 | 1 21 | 1 22 | 103 23 | 4 24 | 1 25 | 1 26 | 104 27 | 1 28 | server_started 29 | 3 30 | 173 31 | -1 32 | 0 33 | 0 34 | #1 35 | Root Class 36 | 16 37 | 3 38 | 1 39 | -1 40 | 4 41 | 0 42 | 4 43 | 1 44 | 1 45 | -1 46 | 4 47 | 3 48 | 1 49 | 0 50 | 1 51 | 2 52 | 1 53 | 3 54 | 0 55 | 0 56 | 0 57 | #2 58 | The First Room 59 | 0 60 | 3 61 | 1 62 | -1 63 | 4 64 | 1 65 | 1 66 | 3 67 | 4 68 | 1 69 | 1 70 | 1 71 | 4 72 | 0 73 | 1 74 | eval 75 | 3 76 | 88 77 | -2 78 | 0 79 | 0 80 | #3 81 | Wizard 82 | 7 83 | 3 84 | 1 85 | 2 86 | 4 87 | 0 88 | 4 89 | 1 90 | 1 91 | 1 92 | 4 93 | 0 94 | 0 95 | 0 96 | 0 97 | #0:0 98 | shutdown(); 99 | . 100 | 0 clocks 101 | 0 queued tasks 102 | 0 suspended tasks 103 | -------------------------------------------------------------------------------- /src/include/pcre_moo.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTENSION_PCRE_H 2 | #define EXTENSION_PCRE_H 3 | 4 | #ifndef _PCRE_H 5 | #include 6 | #endif 7 | 8 | #include "structures.h" 9 | 10 | #define DEFAULT_LOOPS 1000 11 | #define RETURN_INDEXES 2 12 | #define RETURN_GROUPS 4 13 | #define FIND_ALL 8 14 | 15 | struct pcre_cache_entry { 16 | char *error; 17 | pcre *re; 18 | pcre_extra *extra; 19 | int captures; 20 | unsigned int cache_hits; 21 | std::atomic_uint refcount; 22 | }; 23 | 24 | typedef std::pair cache_type; 25 | 26 | static void free_entry(pcre_cache_entry *); 27 | static void delete_cache_entry(const char *pattern, unsigned char options); 28 | static Var result_indices(int ovector[], int n); 29 | extern void pcre_shutdown(void); 30 | 31 | #ifdef SQLITE3_FOUND 32 | #include 33 | extern void sqlite_regexp(sqlite3_context *ctx, int argc, sqlite3_value **argv); 34 | #endif 35 | 36 | #endif /* EXTENSION_PCRE_H */ 37 | -------------------------------------------------------------------------------- /test/README.tests: -------------------------------------------------------------------------------- 1 | Tests are written in the Ruby programming language using the 2 | Test::Unit framework. The Parslet library is used to parse responses 3 | from the ToastStunt server under test. 4 | 5 | To run the tests: 6 | 7 | 1) Ensure you have Ruby 1.9.3 or later installed. 8 | 9 | 2) Ensure you have Bundler installed. 10 | 11 | 3) Install dependencies. 12 | bundle install 13 | 14 | 4) Create the following symlinks in the executables/ directory: 15 | ln -s `which echo` echo 16 | ln -s `which sleep` sleep 17 | ln -s `which true` true 18 | 19 | 5) Build the server and copy the executable into the test directory. 20 | 21 | 6) Verify the settings in test.yml are accurate for your configuration. 22 | 23 | 7) In one console/terminal/window, run the ToastStunt server in the test directory: 24 | ./moo Test.db /dev/null 9898 25 | 26 | 8) In another console/terminal/window, run the tests: 27 | make 28 | 29 | 9) Clean up the moo executable and the files created in /tmp: 30 | make clean 31 | -------------------------------------------------------------------------------- /src/dependencies/crypt/LINKS: -------------------------------------------------------------------------------- 1 | New versions of this package (crypt_blowfish): 2 | 3 | http://www.openwall.com/crypt/ 4 | 5 | A paper on the algorithm that explains its design decisions: 6 | 7 | http://www.usenix.org/events/usenix99/provos.html 8 | 9 | Unix Seventh Edition Manual, Volume 2: the password scheme (1978): 10 | 11 | http://plan9.bell-labs.com/7thEdMan/vol2/password 12 | 13 | The Openwall GNU/*/Linux (Owl) tcb suite implementing the alternative 14 | password shadowing scheme. This includes a PAM module which 15 | supersedes pam_unix and uses the password hashing framework provided 16 | with crypt_blowfish when setting new passwords. 17 | 18 | http://www.openwall.com/tcb/ 19 | 20 | pam_passwdqc, a password strength checking and policy enforcement 21 | module for PAM-aware password changing programs: 22 | 23 | http://www.openwall.com/passwdqc/ 24 | 25 | John the Ripper password cracker: 26 | 27 | http://www.openwall.com/john/ 28 | 29 | $Owl: Owl/packages/glibc/crypt_blowfish/LINKS,v 1.4 2005/11/16 13:09:47 solar Exp $ 30 | -------------------------------------------------------------------------------- /test/tests/test_system_builtins.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestSystemBuiltins < Test::Unit::TestCase 4 | 5 | def test_that_getenv_requires_wizperms 6 | run_test_as('wizard') do 7 | assert_not_equal E_PERM, getenv('PATH') 8 | end 9 | run_test_as('programmer') do 10 | assert_equal E_PERM, getenv('PATH') 11 | end 12 | end 13 | 14 | def test_that_getenv_fails_on_invalid_arguments 15 | run_test_as('wizard') do 16 | assert_equal E_ARGS, simplify(command(%Q|; getenv(); |)) 17 | assert_equal E_TYPE, getenv(1) 18 | assert_equal E_TYPE, getenv(1.1) 19 | end 20 | end 21 | 22 | def test_that_getenv_returns_the_environment_variable_value 23 | run_test_as('wizard') do 24 | assert_equal ENV['PATH'], getenv('PATH') 25 | assert_equal ENV['USER'], getenv('USER') 26 | end 27 | end 28 | 29 | def test_that_getenv_returns_zero_if_the_environment_variable_does_not_exist 30 | run_test_as('wizard') do 31 | assert_equal 0, getenv('XYZZY') 32 | end 33 | end 34 | 35 | end 36 | -------------------------------------------------------------------------------- /src/include/collection.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "structures.h" 19 | 20 | extern int ismember(Var value, Var list, int case_matters); 21 | -------------------------------------------------------------------------------- /src/include/quota.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "structures.h" 19 | 20 | extern int decr_quota(Objid player); 21 | extern void incr_quota(Objid player); 22 | -------------------------------------------------------------------------------- /src/include/tokens.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1994 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef tENDWHILE 19 | 20 | #include "ast.h" 21 | #include "structures.h" 22 | 23 | #include "parser.hh" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/include/match.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "config.h" 19 | #include "structures.h" 20 | 21 | extern Objid match_object(Objid player, const char *name); 22 | -------------------------------------------------------------------------------- /docs/Legacy/ChangeLogs/ChangeLog-FileIO.txt: -------------------------------------------------------------------------------- 1 | Version 1.5p3 - Jul 11 2 | ---------------------- 3 | - Added return value check on calls to binary_to_raw_bytes (via out_filter) 4 | - Replaced use of fgets to better handle files with null bytes 5 | - No longer accept the tab character as valid clean input data 6 | 7 | Version 1.5p2 - Jun 11 8 | ---------------------- 9 | - Fixed mismatch mymalloc/free 10 | - Removed restriction that the final line in text mode must be terminated by a newline 11 | - Reset errno before each call 12 | - Removed vestigial file_send 13 | - Replaced "E_FILE" error with true E_FILE 14 | 15 | Version 1.5p1 - Dec 97 16 | ---------------------- 17 | - Fixed bug where tabs were not included in the input stream 18 | - Added CHANGELOG to the distribution 19 | - Added README 20 | 21 | Version 1.5 22 | ----------- 23 | - First version maintained by Andy Bakun. 24 | - Fixed bugs where file_eof and file_tell didn't return meaningful results 25 | didn't raise errors on invalid file descriptors. 26 | 27 | Versions < 1.5 28 | -------------- 29 | Maintained by Ken Fox. Really, the initial public version. 30 | -------------------------------------------------------------------------------- /src/include/code_gen.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1994, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "ast.h" 19 | #include "program.h" 20 | #include "version.h" 21 | 22 | extern Program *generate_code(Stmt *, DB_Version); 23 | -------------------------------------------------------------------------------- /src/dependencies/crypt/crypt_blowfish.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by Solar Designer in 2000-2011. 3 | * No copyright is claimed, and the software is hereby placed in the public 4 | * domain. In case this attempt to disclaim copyright and place the software 5 | * in the public domain is deemed null and void, then the software is 6 | * Copyright (c) 2000-2011 Solar Designer and it is hereby released to the 7 | * general public under the following terms: 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted. 11 | * 12 | * There's ABSOLUTELY NO WARRANTY, express or implied. 13 | * 14 | * See crypt_blowfish.c for more information. 15 | */ 16 | 17 | #ifndef _CRYPT_BLOWFISH_H 18 | #define _CRYPT_BLOWFISH_H 19 | 20 | extern int _crypt_output_magic(const char *setting, char *output, int size); 21 | extern char *_crypt_blowfish_rn(const char *key, const char *setting, 22 | char *output, int size); 23 | extern char *_crypt_gensalt_blowfish_rn(const char *prefix, 24 | unsigned long count, 25 | const char *input, int size, char *output, int output_size); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/include/verbs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "db.h" 19 | #include "structures.h" 20 | 21 | extern enum error validate_verb_descriptor(Var desc); 22 | extern db_verb_handle find_described_verb(Var obj, Var desc); 23 | -------------------------------------------------------------------------------- /src/include/my-math.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Math_h 19 | #define Math_h 1 20 | 21 | #include 22 | #include 23 | 24 | #define IS_REAL(x) (-DBL_MAX <= (x) && (x) <= DBL_MAX) 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/include/disassemble.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include 19 | 20 | #include "program.h" 21 | 22 | extern void disassemble_to_file(FILE * fp, Program * program); 23 | extern void disassemble_to_stderr(Program * program); 24 | -------------------------------------------------------------------------------- /src/dependencies/LICENSE_THPOOL: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Johan Hanssen Seferidis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/include/decompile.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "ast.h" 19 | #include "program.h" 20 | 21 | extern Stmt *decompile_program(Program * program, int vector); 22 | extern unsigned find_line_number(Program * program, int vector, unsigned pc); 23 | -------------------------------------------------------------------------------- /src/net_mplex.cc: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1994, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "options.h" 19 | 20 | # if MPLEX_STYLE == MP_SELECT 21 | # include "net_mp_selct.cc" 22 | # endif 23 | 24 | # if MPLEX_STYLE == MP_POLL 25 | # include "net_mp_poll.cc" 26 | # endif 27 | -------------------------------------------------------------------------------- /test/tests/test_verb_cache.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestVerbCache < Test::Unit::TestCase 4 | 5 | def test_that_renumbering_an_object_does_not_affect_the_verb_cache 6 | run_test_as('wizard') do 7 | a = simplify(command(%Q|; a = create($nothing); return renumber(a); |)) 8 | b = simplify(command(%Q|; b = create($nothing); return renumber(b); |)) 9 | add_verb(b, [player, 'xd', 'test'], ['this', 'none', 'this']) 10 | set_verb_code(b, 'test', ['return "test";']) 11 | 12 | recycle(a) # should clear the cache 13 | x = verb_cache_stats() 14 | assert_equal E_INVIND, call(a, 'test') 15 | assert_equal 'test', call(b, 'test') 16 | 17 | renumber(b) # should not clear the cache 18 | y = verb_cache_stats() 19 | assert_equal 'test', call(a, 'test') 20 | assert_equal E_INVIND, call(b, 'test') 21 | 22 | z = verb_cache_stats() 23 | 24 | subtract = lambda { |el| el[0] - el[1] } 25 | assert_equal [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], x[4].zip(y[4]).map(&subtract) 26 | assert_equal [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], y[4].zip(z[4]).map(&subtract) 27 | end 28 | end 29 | 30 | end 31 | -------------------------------------------------------------------------------- /test/tests/test_things_that_used_to_crash_the_server.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestThingsThatUsedToCrashTheServer < Test::Unit::TestCase 4 | 5 | def setup 6 | run_test_as('wizard') do 7 | evaluate('add_property($server_options, "max_concat_catchable", 1, {player, "r"})') 8 | evaluate('load_server_options();') 9 | end 10 | end 11 | 12 | def teardown 13 | run_test_as('wizard') do 14 | evaluate('delete_property($server_options, "max_concat_catchable")') 15 | evaluate('load_server_options();') 16 | end 17 | end 18 | 19 | def test_that_building_a_long_nested_list_does_not_crash_the_server 20 | run_test_as('programmer') do 21 | assert_equal E_QUOTA, simplify(command('; x = {}; while (1); ticks_left() < 2000 || seconds_left() < 2 && suspend(0); x = {x, x, x, x, x, x, x, x, x, x}; endwhile;')) 22 | end 23 | end 24 | 25 | def test_that_building_a_long_nested_map_does_not_crash_the_server 26 | run_test_as('programmer') do 27 | assert_equal E_QUOTA, simplify(command('; x = []; while (1); ticks_left() < 2000 || seconds_left() < 2 && suspend(0); x[1] = {x, x, x, x, x, x, x, x, x, x}; endwhile;')) 28 | end 29 | end 30 | 31 | end 32 | -------------------------------------------------------------------------------- /src/dependencies/crypt/crypt_gensalt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by Solar Designer in 2000-2011. 3 | * No copyright is claimed, and the software is hereby placed in the public 4 | * domain. In case this attempt to disclaim copyright and place the software 5 | * in the public domain is deemed null and void, then the software is 6 | * Copyright (c) 2000-2011 Solar Designer and it is hereby released to the 7 | * general public under the following terms: 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted. 11 | * 12 | * There's ABSOLUTELY NO WARRANTY, express or implied. 13 | * 14 | * See crypt_blowfish.c for more information. 15 | */ 16 | 17 | #ifndef _CRYPT_GENSALT_H 18 | #define _CRYPT_GENSALT_H 19 | 20 | extern unsigned char _crypt_itoa64[]; 21 | extern char *_crypt_gensalt_traditional_rn(const char *prefix, 22 | unsigned long count, 23 | const char *input, int size, char *output, int output_size); 24 | extern char *_crypt_gensalt_extended_rn(const char *prefix, 25 | unsigned long count, 26 | const char *input, int size, char *output, int output_size); 27 | extern char *_crypt_gensalt_md5_rn(const char *prefix, unsigned long count, 28 | const char *input, int size, char *output, int output_size); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 1992, 1994, 1995, 1996 Xerox Corporation. All rights reserved. 4 | # Portions of this code were written by Stephen White, aka ghond. 5 | # Use and copying of this software and preparation of derivative works based 6 | # upon this software are permitted. Any distribution of this software or 7 | # derivative works must comply with all applicable United States export 8 | # control laws. This software is made available AS IS, and Xerox Corporation 9 | # makes no warranty about the software, its performance or its conformity to 10 | # any specification. Any person obtaining a copy of this software is requested 11 | # to send their name and post office or electronic mail address to: 12 | # Pavel Curtis 13 | # Xerox PARC 14 | # 3333 Coyote Hill Rd. 15 | # Palo Alto, CA 94304 16 | # Pavel@Xerox.Com 17 | 18 | if [ $# -lt 1 -o $# -gt 2 ]; then 19 | echo 'Usage: restart dbase-prefix [port]' 20 | exit 1 21 | fi 22 | 23 | if [ ! -r $1.db ]; then 24 | echo "Unknown database: $1.db" 25 | exit 1 26 | fi 27 | 28 | if [ -r $1.db.new ]; then 29 | mv $1.db $1.db.old 30 | mv $1.db.new $1.db 31 | rm -f $1.db.old.Z 32 | compress $1.db.old & 33 | fi 34 | 35 | if [ -f $1.log ]; then 36 | cat $1.log >> $1.log.old 37 | rm $1.log 38 | fi 39 | 40 | echo `date`: RESTARTED >> $1.log 41 | nohup ./moo $1.db $1.db.new $2 >> $1.log 2>&1 & 42 | -------------------------------------------------------------------------------- /test/tests/test_eval.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestEval < Test::Unit::TestCase 4 | 5 | def test_that_eval_cannot_be_called_by_non_programmers 6 | run_test_as('wizard') do 7 | set(player, 'programmer', 0) 8 | assert_equal E_PERM, simplify(command(%Q|; return eval("return 5;");|)) 9 | end 10 | end 11 | 12 | def test_that_eval_requires_at_least_one_argument 13 | run_test_as('wizard') do 14 | assert_equal E_ARGS, simplify(command(%Q|; return eval();|)) 15 | end 16 | end 17 | 18 | def test_that_eval_requires_string_arguments 19 | run_test_as('wizard') do 20 | assert_equal E_TYPE, simplify(command(%Q|; return eval(1);|)) 21 | assert_equal E_TYPE, simplify(command(%Q|; return eval(1, 2);|)) 22 | assert_equal E_TYPE, simplify(command(%Q|; return eval({});|)) 23 | assert_equal E_TYPE, simplify(command(%Q|; return eval([]);|)) 24 | end 25 | end 26 | 27 | def test_that_eval_evaluates_multiple_strings 28 | run_test_as('wizard') do 29 | assert_equal [1, 15], simplify(command(%Q|; return eval("x = 0;", "for i in [1..5]", "x = x + i;", "endfor", "return x;");|)) 30 | end 31 | end 32 | 33 | def test_that_eval_evaluates_a_single_string 34 | run_test_as('wizard') do 35 | assert_equal [1, 5], simplify(command(%Q|; return eval("return 5;");|)) 36 | end 37 | end 38 | 39 | end 40 | -------------------------------------------------------------------------------- /test/tests/Broken2.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 5 ** 2 | 5 3 | 2 4 | 0 5 | 2 6 | 3 7 | 4 8 | #0 9 | System Object 10 | 16 11 | 3 12 | 0 13 | -1 14 | 4 15 | 2 16 | 1 17 | -1 18 | 0 19 | -1 20 | 4 21 | 1 22 | 0 23 | 1 24 | 0 25 | 1 26 | 1 27 | server_started 28 | 3 29 | 173 30 | -1 31 | 2 32 | nothing 33 | object 34 | 2 35 | 1 36 | -1 37 | 4 38 | 1 39 | 1 40 | 1 41 | 4 42 | 1 43 | #1 44 | Root Class 45 | 16 46 | 3 47 | 4 48 | 1 49 | 1 50 | -1 51 | 1 52 | -1 53 | 0 54 | -1 55 | 4 56 | 4 57 | 0 58 | 0 59 | 1 60 | 2 61 | 1 62 | 3 63 | 1 64 | 4 65 | 0 66 | 0 67 | 0 68 | #2 69 | The First Room 70 | 0 71 | 3 72 | 1 73 | -1 74 | 4 75 | 2 76 | 1 77 | 3 78 | 1 79 | 4 80 | 1 81 | 1 82 | 4 83 | 0 84 | 1 85 | eval 86 | 3 87 | 88 88 | -2 89 | 0 90 | 0 91 | #3 92 | wizard 93 | 7 94 | 3 95 | 1 96 | 2 97 | 4 98 | 0 99 | 4 100 | 1 101 | 1 102 | 1 103 | 4 104 | 0 105 | 0 106 | 0 107 | 0 108 | #4 109 | programmer 110 | 3 111 | 4 112 | 1 113 | 2 114 | 4 115 | 0 116 | 4 117 | 1 118 | 1 119 | 1 120 | 4 121 | 0 122 | 0 123 | 0 124 | 0 125 | #0:0 126 | shutdown(); 127 | . 128 | #2:0 129 | set_task_perms(player); 130 | try 131 | notify(player, toliteral(eval(argstr))); 132 | except e (ANY) 133 | notify(player, toliteral({2, e})); 134 | endtry 135 | . 136 | 0 clocks 137 | 0 queued tasks 138 | 0 suspended tasks 139 | -------------------------------------------------------------------------------- /src/include/random.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "config.h" 19 | 20 | #if HAVE_LRAND48 21 | extern long lrand48(void); 22 | extern void srand48(long); 23 | # define RANDOM lrand48 24 | # define SRANDOM srand48 25 | #else 26 | # include 27 | # if HAVE_RANDOM 28 | # define RANDOM random 29 | # define SRANDOM srandom 30 | # else 31 | # define RANDOM rand 32 | # define SRANDOM srand 33 | # endif 34 | #endif 35 | -------------------------------------------------------------------------------- /src/dependencies/strnatcmp.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "k&r" -*- 2 | 3 | strnatcmp.c -- Perform 'natural order' comparisons of strings in C. 4 | Copyright (C) 2000, 2004 by Martin Pool 5 | 6 | This software is provided 'as-is', without any express or implied 7 | warranty. In no event will the authors be held liable for any damages 8 | arising from the use of this software. 9 | 10 | Permission is granted to anyone to use this software for any purpose, 11 | including commercial applications, and to alter it and redistribute it 12 | freely, subject to the following restrictions: 13 | 14 | 1. The origin of this software must not be misrepresented; you must not 15 | claim that you wrote the original software. If you use this software 16 | in a product, an acknowledgment in the product documentation would be 17 | appreciated but is not required. 18 | 2. Altered source versions must be plainly marked as such, and must not be 19 | misrepresented as being the original software. 20 | 3. This notice may not be removed or altered from any source distribution. 21 | */ 22 | 23 | 24 | /* CUSTOMIZATION SECTION 25 | * 26 | * You can change this typedef, but must then also change the inline 27 | * functions in strnatcmp.c */ 28 | typedef char nat_char; 29 | 30 | int strnatcmp(nat_char const *a, nat_char const *b); 31 | int strnatcasecmp(nat_char const *a, nat_char const *b); 32 | -------------------------------------------------------------------------------- /src/dependencies/crypt/PERFORMANCE: -------------------------------------------------------------------------------- 1 | These numbers are for 32 iterations ("$2a$05"): 2 | 3 | OpenBSD 3.0 bcrypt(*) crypt_blowfish 0.4.4 4 | Pentium III, 840 MHz 99 c/s 121 c/s (+22%) 5 | Alpha 21164PC, 533 MHz 55.5 c/s 76.9 c/s (+38%) 6 | UltraSparc IIi, 400 MHz 49.9 c/s 52.5 c/s (+5%) 7 | Pentium, 120 MHz 8.8 c/s 20.1 c/s (+128%) 8 | PA-RISC 7100LC, 80 MHz 8.5 c/s 16.3 c/s (+92%) 9 | 10 | (*) built with -fomit-frame-pointer -funroll-loops, which I don't 11 | think happens for libcrypt. 12 | 13 | Starting with version 1.1 released in June 2011, default builds of 14 | crypt_blowfish invoke a quick self-test on every hash computation. 15 | This has roughly a 4.8% performance impact at "$2a$05", but only a 0.6% 16 | impact at a more typical setting of "$2a$08". 17 | 18 | The large speedup for the original Pentium is due to the assembly 19 | code and the weird optimizations this processor requires. 20 | 21 | The numbers for password cracking are 2 to 10% higher than those for 22 | crypt_blowfish as certain things may be done out of the loop and the 23 | code doesn't need to be reentrant. 24 | 25 | Recent versions of John the Ripper (1.6.25-dev and newer) achieve an 26 | additional 15% speedup on the Pentium Pro family of processors (which 27 | includes Pentium III) with a separate version of the assembly code and 28 | run-time CPU detection. 29 | 30 | $Owl: Owl/packages/glibc/crypt_blowfish/PERFORMANCE,v 1.6 2011/06/21 12:09:20 solar Exp $ 31 | -------------------------------------------------------------------------------- /src/include/parser.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Parser_h 19 | #define Parser_h 1 20 | 21 | #include "config.h" 22 | #include "program.h" 23 | #include "version.h" 24 | 25 | typedef struct { 26 | void (*error) (void *, const char *); 27 | void (*warning) (void *, const char *); 28 | int (*getch) (void *); 29 | } Parser_Client; 30 | 31 | extern Program *parse_program(DB_Version, Parser_Client, void *); 32 | extern Program *parse_list_as_program(Var code, Var * errors); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /CMakeModules/FindPCRE.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007-2009 LuaDist. 2 | # Created by Peter Kapec 3 | # Redistribution and use of this file is allowed according to the terms of the MIT license. 4 | # Note: 5 | # Searching headers and libraries is very simple and is NOT as powerful as scripts 6 | # distributed with CMake, because LuaDist defines directories to search for. 7 | # Everyone is encouraged to contact the author with improvements. Maybe this file 8 | # becomes part of CMake distribution sometimes. 9 | 10 | # - Find pcre 11 | # Find the native PCRE headers and libraries. 12 | # 13 | # PCRE_INCLUDE_DIRS - where to find pcre.h, etc. 14 | # PCRE_LIBRARIES - List of libraries when using pcre. 15 | # PCRE_FOUND - True if pcre found. 16 | 17 | # Look for the header file. 18 | FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h) 19 | 20 | # Look for the library. 21 | FIND_LIBRARY(PCRE_LIBRARY NAMES pcre) 22 | 23 | # Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE. 24 | INCLUDE(FindPackageHandleStandardArgs) 25 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR) 26 | 27 | # Copy the results to the output variables. 28 | IF(PCRE_FOUND) 29 | SET(PCRE_LIBRARIES ${PCRE_LIBRARY}) 30 | SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) 31 | ELSE(PCRE_FOUND) 32 | SET(PCRE_LIBRARIES) 33 | SET(PCRE_INCLUDE_DIRS) 34 | ENDIF(PCRE_FOUND) 35 | 36 | MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES) 37 | -------------------------------------------------------------------------------- /src/include/keywords.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "config.h" 19 | #include "structures.h" 20 | #include "version.h" 21 | 22 | struct keyword { 23 | const char *name; /* the canonical spelling of the keyword */ 24 | DB_Version version; /* the DB version when it was introduced */ 25 | int token; /* the type of token the scanner should use */ 26 | enum error error; /* for token == ERROR, the value */ 27 | }; 28 | 29 | typedef const struct keyword Keyword; 30 | 31 | extern Keyword *find_keyword(const char *); 32 | -------------------------------------------------------------------------------- /src/include/pattern.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "config.h" 19 | 20 | typedef struct { 21 | int start, end; 22 | } Match_Indices; 23 | 24 | typedef struct { 25 | void *ptr; 26 | } Pattern; 27 | 28 | typedef enum { 29 | MATCH_SUCCEEDED, MATCH_FAILED, MATCH_ABORTED 30 | } Match_Result; 31 | 32 | extern Pattern new_pattern(const char *pattern, int case_matters); 33 | extern Match_Result match_pattern(Pattern p, const char *string, 34 | Match_Indices * indices, int is_reverse); 35 | extern void free_pattern(Pattern p); 36 | -------------------------------------------------------------------------------- /src/include/sqlite.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTENSION_SQLITE_H 2 | #define EXTENSION_SQLITE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "structures.h" 8 | 9 | #define SQLITE_MAX_HANDLES 20 /* Maximum number of SQLite databases that can be open 10 | * at a single time. Can be overridden with an INT in 11 | * $server_options.sqlite_max_handles */ 12 | 13 | #define SQLITE_PARSE_TYPES 2 // Return all strings if unset 14 | #define SQLITE_PARSE_OBJECTS 4 // Turn "#100" into OBJ 15 | #define SQLITE_SANITIZE_STRINGS 8 // Strip newlines from returned strings. 16 | 17 | typedef struct sqlite_conn 18 | { 19 | sqlite3 *id; 20 | char *path; 21 | unsigned char options; 22 | std::atomic_uint locks; 23 | } sqlite_conn; 24 | 25 | /* In order to ensure thread safety, the last result should be unique 26 | * to each running thread. So we pass this temporary struct around instead 27 | * of the connection itself. */ 28 | typedef struct sqlite_result 29 | { 30 | sqlite_conn *connection; 31 | Var last_result; 32 | bool include_headers; 33 | } sqlite_result; 34 | 35 | // Forward declarations 36 | extern const char *file_resolve_path(const char *); // from fileio.cc 37 | extern int parse_number(const char *, int *, int); // from numbers.cc 38 | extern int parse_float(const char *, double *); // from numbers.cc 39 | 40 | #endif /* EXTENSION_SQLITE_H */ 41 | -------------------------------------------------------------------------------- /test/tests/test_miscellaneous.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestMiscellaneous < Test::Unit::TestCase 4 | 5 | def test_that_isa_returns_true_or_false_given_an_object_number 6 | run_test_as('programmer') do 7 | a = create(:nothing) 8 | b = create(a) 9 | 10 | assert_equal 0, isa(a, b) 11 | assert_equal 1, isa(b, a) 12 | 13 | assert_equal 0, isa(b, :nothing) 14 | assert_equal 0, isa(:nothing, a) 15 | assert_equal 0, isa(:nothing, :nothing) 16 | 17 | assert_equal 0, simplify(command(%Q|; return isa(#100000, #1); |)) 18 | assert_equal 0, simplify(command(%Q|; return isa(#1, #100000); |)) 19 | assert_equal 0, simplify(command(%Q|; return isa(#1000000, #1000000); |)) 20 | assert_equal 0, simplify(command(%Q|; return isa(#-2, #2); |)) 21 | assert_equal 0, simplify(command(%Q|; return isa(#1, #-1); |)) 22 | end 23 | end 24 | 25 | def test_that_isa_returns_true_or_false_given_an_object 26 | run_test_as('programmer') do 27 | o = create(:nothing) 28 | add_property(o, 'b', 0, ['player', '']) 29 | add_property(o, 'c', 0, ['player', '']) 30 | 31 | [0, 1].each do |opt| 32 | simplify(command(%Q|; #{o}.b = create($nothing); |)) 33 | simplify(command(%Q|; #{o}.c = create(#{o}.b, #{opt}); |)) 34 | assert_equal 0, simplify(command(%Q|; return isa(#{o}.b, #{o}.c); |)) 35 | assert_equal 1, simplify(command(%Q|; return isa(#{o}.c, #{o}.b); |)) 36 | end 37 | end 38 | end 39 | 40 | end 41 | -------------------------------------------------------------------------------- /src/include/eval_env.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Eval_env_h 19 | #define Eval_env_h 1 20 | 21 | #include "config.h" 22 | #include "structures.h" 23 | #include "version.h" 24 | 25 | extern Var *new_rt_env(unsigned size); 26 | extern void free_rt_env(Var * rt_env, unsigned size); 27 | extern Var *copy_rt_env(Var * from, unsigned size); 28 | 29 | void set_rt_env_obj(Var * env, int slot, Objid o); 30 | void set_rt_env_str(Var * env, int slot, const char *s); 31 | void set_rt_env_var(Var * env, int slot, Var v); 32 | 33 | void fill_in_rt_consts(Var * env, DB_Version); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/dependencies/yajl/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2010, Lloyd Hilaiel. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | 3. Neither the name of Lloyd Hilaiel nor the names of its 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/include/timers.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Timers_H 19 | #define Timers_H 1 20 | 21 | #include 22 | 23 | typedef int Timer_ID; 24 | typedef void *Timer_Data; 25 | typedef void (*Timer_Proc) (Timer_ID, Timer_Data); 26 | 27 | extern Timer_ID set_timer(unsigned, Timer_Proc, Timer_Data); 28 | extern Timer_ID set_virtual_timer(unsigned, Timer_Proc, Timer_Data); 29 | extern int cancel_timer(Timer_ID); 30 | extern void reenable_timers(void); 31 | extern unsigned timer_wakeup_interval(Timer_ID); 32 | extern void timer_sleep(unsigned seconds); 33 | extern int virtual_timer_available(); 34 | 35 | #endif /* !Timers_H */ 36 | -------------------------------------------------------------------------------- /src/include/numbers.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "sosemanuk.h" 19 | #include "structures.h" 20 | 21 | extern int parse_number(const char *str, Num *result, int try_floating_point); 22 | extern enum error become_integer(Var, Num *, int); 23 | 24 | extern int do_equals(Var, Var); 25 | extern int compare_integers(Num, Num); 26 | extern Var compare_numbers(Var, Var); 27 | 28 | extern Var do_add(Var, Var); 29 | extern Var do_subtract(Var, Var); 30 | extern Var do_multiply(Var, Var); 31 | extern Var do_divide(Var, Var); 32 | extern Var do_modulus(Var, Var); 33 | extern Var do_power(Var, Var); 34 | 35 | extern sosemanuk_key_context key_context; 36 | extern sosemanuk_run_context run_context; 37 | -------------------------------------------------------------------------------- /test/tests/Anon6.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 17 ** 2 | 1 3 | 3 4 | 1 values pending finalization 5 | 12 6 | -1 7 | 0 clocks 8 | 0 queued tasks 9 | 0 suspended tasks 10 | 0 interrupted tasks 11 | 0 active connections with listeners 12 | 4 13 | #0 14 | System Object 15 | 16 16 | 3 17 | 1 18 | -1 19 | 0 20 | 0 21 | 4 22 | 0 23 | 1 24 | 1 25 | 4 26 | 0 27 | 1 28 | server_started 29 | 3 30 | 173 31 | -1 32 | 0 33 | 0 34 | #1 35 | Root Class 36 | 16 37 | 3 38 | 1 39 | -1 40 | 0 41 | 0 42 | 4 43 | 0 44 | 1 45 | -1 46 | 4 47 | 3 48 | 1 49 | 0 50 | 1 51 | 2 52 | 1 53 | 3 54 | 0 55 | 0 56 | 0 57 | #2 58 | The First Room 59 | 0 60 | 3 61 | 1 62 | -1 63 | 0 64 | 0 65 | 4 66 | 1 67 | 1 68 | 3 69 | 1 70 | 1 71 | 4 72 | 0 73 | 1 74 | eval 75 | 3 76 | 88 77 | -2 78 | 0 79 | 0 80 | #3 81 | Wizard 82 | 7 83 | 3 84 | 1 85 | 2 86 | 0 87 | 0 88 | 4 89 | 0 90 | 1 91 | 1 92 | 4 93 | 0 94 | 0 95 | 0 96 | 0 97 | 0 98 | 1 99 | #0:0 100 | server_log("----------------------------------------------------------------------"); 101 | server_log("Merely tries to load a database with a value pending finalization."); 102 | server_log("The value is an invalid anonymous object. This test should output a"); 103 | server_log("simple message."); 104 | server_log("----------------------------------------------------------------------"); 105 | suspend(0); 106 | try 107 | try 108 | server_log("shazam"); 109 | except ex (ANY) 110 | server_log(toliteral(ex)); 111 | endtry 112 | finally 113 | run_gc(); 114 | suspend(0); 115 | shutdown(); 116 | kill_task(task_id()); 117 | endtry 118 | . 119 | -------------------------------------------------------------------------------- /test/tests/test_switch_player.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestSwitchPlayer < Test::Unit::TestCase 4 | 5 | def test_that_switch_player_does_not_work_for_non_wizards 6 | run_test_as('programmer') do 7 | assert_equal E_PERM, simplify(switch_player(player, player)) 8 | end 9 | end 10 | 11 | def test_that_switch_player_switches_player 12 | run_test_as('wizard') do 13 | old_player = player 14 | new_player = make_new_player 15 | switch_player(player, new_player) 16 | assert_not_equal old_player, simplify(command %Q|;return player;|) 17 | assert_equal new_player, simplify(command %Q|;return player;|) 18 | end 19 | end 20 | 21 | def test_that_switching_back_and_forth_works 22 | run_test_as('wizard') do 23 | old_player = player 24 | new_player = make_new_player 25 | switch_player(player, new_player) 26 | assert_not_equal old_player, simplify(command %Q|;return player;|) 27 | assert_equal new_player, simplify(command %Q|;return player;|) 28 | switch_player(new_player, player) 29 | assert_equal old_player, simplify(command %Q|;return player;|) 30 | assert_not_equal new_player, simplify(command %Q|;return player;|) 31 | switch_player(player, new_player) 32 | assert_not_equal old_player, simplify(command %Q|;return player;|) 33 | assert_equal new_player, simplify(command %Q|;return player;|) 34 | end 35 | end 36 | 37 | private 38 | 39 | def make_new_player 40 | simplify command %Q|;o = create($nothing); move(o, player.location); set_player_flag(o, 1); o.programmer = 1; o.wizard = 1; return o;| 41 | end 42 | 43 | end 44 | -------------------------------------------------------------------------------- /src/include/log.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include 19 | 20 | #include "config.h" 21 | #include "structures.h" 22 | 23 | extern void set_log_file(FILE *); 24 | FILE* get_log_file(); 25 | extern void set_log_file_name(const char *name); 26 | const char* get_log_file_name(); 27 | 28 | enum {LOG_NONE, LOG_INFO1, LOG_INFO2, LOG_INFO3, LOG_INFO4, 29 | LOG_NOTICE, LOG_WARNING, LOG_ERROR}; 30 | 31 | extern void oklog(const char *,...); 32 | extern void errlog(const char *,...); 33 | extern void applog(int, const char *,...); 34 | extern void log_perror(const char *); 35 | 36 | extern void reset_command_history(void); 37 | extern void log_command_history(void); 38 | extern void add_command_to_history(Objid player, const char *command); -------------------------------------------------------------------------------- /docs/Features/new_options.md: -------------------------------------------------------------------------------- 1 | - Options.h configuration: 2 | - LOG_CODE_CHANGES (causes .program and set_verb_code to add a line to the server log indicating the object, verb, and programmer) 3 | - OWNERSHIP_QUOTA (disable the server's builtin quota management) 4 | - USE_ANCESTOR_CACHE (enable a cache of an object's ancestors to speed up property lookups) 5 | - UNSAFE_FIO (skip character by character line verification, trading off potential safety for speed) 6 | - LOG_EVALS (add an entry to the server log any time eval is called) 7 | - ONLY_32_BITS (switch from 64-bit integers back to 32-bit) 8 | - MAX_LINE_BYTES (unceremoniously close connections that send lines exceeding this value to prevent memory allocation panics) 9 | - DEFAULT_LAG_THRESHOLD (the number of seconds allowed before a task is considered laggy and triggers #0:handle_lagging_task) 10 | - SAVE_FINISHED_TASKS (enable the finished_tasks function and define how many tasks get saved by default) [default can be overridden with $server_options.finished_tasks_limit] 11 | - THREAD_ARGON2 (enable threading of Argon2 functions) 12 | - TOTAL_BACKGROUND_THREADS (number of threads created at runtime) 13 | - DEFAULT_THREAD_MODE (default mode of threaded functions) 14 | - SAFE_RECYCLE (change ownership of everything an object owns before recycling it) 15 | - NO_NAME_LOOKUP (disable automatic DNS name resolution on new connections. Can be overridden with $server_options.no_name_lookup) 16 | - PCRE_PATTERN_CACHE_SIZE (specifies how many PCRE patterns are cached) 17 | - INCLUDE_RT_VARS (Include runtime environment variables in the stack argument for `handle_uncaught_error`, `handle_task_timeout`, and `handle_lagging_task`) 18 | -------------------------------------------------------------------------------- /test/tests/Anon3.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 17 ** 2 | 1 3 | 3 4 | 0 values pending finalization 5 | 0 clocks 6 | 0 queued tasks 7 | 0 suspended tasks 8 | 0 interrupted tasks 9 | 0 active connections with listeners 10 | 4 11 | #0 12 | System Object 13 | 16 14 | 3 15 | 1 16 | -1 17 | 0 18 | 0 19 | 4 20 | 0 21 | 1 22 | 1 23 | 4 24 | 0 25 | 1 26 | server_started 27 | 3 28 | 173 29 | -1 30 | 0 31 | 0 32 | #1 33 | Root Class 34 | 16 35 | 3 36 | 1 37 | -1 38 | 0 39 | 0 40 | 4 41 | 0 42 | 1 43 | -1 44 | 4 45 | 3 46 | 1 47 | 0 48 | 1 49 | 2 50 | 1 51 | 3 52 | 0 53 | 0 54 | 0 55 | #2 56 | The First Room 57 | 0 58 | 3 59 | 1 60 | -1 61 | 0 62 | 0 63 | 4 64 | 1 65 | 1 66 | 3 67 | 1 68 | 1 69 | 4 70 | 0 71 | 1 72 | eval 73 | 3 74 | 88 75 | -2 76 | 0 77 | 0 78 | #3 79 | Wizard 80 | 7 81 | 3 82 | 1 83 | 2 84 | 0 85 | 0 86 | 4 87 | 0 88 | 1 89 | 1 90 | 4 91 | 0 92 | 0 93 | 0 94 | 0 95 | 0 96 | 1 97 | #0:0 98 | server_log("----------------------------------------------------------------------"); 99 | server_log("Creates garbage and runs gc. The garbage should be freed. When"); 100 | server_log("the server restarts from the dumped database, there should be no"); 101 | server_log("evidence of the garbage."); 102 | server_log("----------------------------------------------------------------------"); 103 | suspend(0); 104 | try 105 | try 106 | l = {o = create(#-1, 1)}; 107 | add_verb(o, {task_perms(), "xd", "recycle"}, {"this", "none", "this"}); 108 | set_verb_code(o, "recycle", {"server_log(\"recycle called\");"}); 109 | except ex (ANY) 110 | server_log(toliteral(ex)); 111 | endtry 112 | finally 113 | l = o = 0; 114 | suspend(0); 115 | shutdown(); 116 | endtry 117 | . 118 | -------------------------------------------------------------------------------- /src/include/json.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2010 Todd Sundsted. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY TODD SUNDSTED ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL TODD SUNDSTED OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 20 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are 26 | those of the authors and should not be interpreted as representing official 27 | policies, either expressed or implied, of Todd Sundsted. 28 | *****************************************************************************/ 29 | -------------------------------------------------------------------------------- /CMakeModules/version.cmake: -------------------------------------------------------------------------------- 1 | execute_process(COMMAND git log --pretty=format:%H -n 1 2 | OUTPUT_VARIABLE GIT_REV 3 | ERROR_QUIET) 4 | 5 | # Check whether we got any revision (which isn't 6 | # always the case, e.g. when someone downloaded a zip 7 | # file from Github instead of a checkout) 8 | if ("${GIT_REV}" STREQUAL "") 9 | set(GIT_REV "N/A") 10 | set(GIT_DIFF "") 11 | set(GIT_BRANCH "N/A") 12 | else() 13 | execute_process( 14 | COMMAND "$SHELL" -c "git diff --quiet --exit-code || echo +" 15 | OUTPUT_VARIABLE GIT_DIFF) 16 | execute_process( 17 | COMMAND git rev-parse --abbrev-ref HEAD 18 | OUTPUT_VARIABLE GIT_BRANCH) 19 | execute_process( 20 | COMMAND git --version 21 | OUTPUT_VARIABLE GIT_VERSION) 22 | 23 | string(STRIP "${GIT_REV}" GIT_REV) 24 | # string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV) 25 | string(STRIP "${GIT_DIFF}" GIT_DIFF) 26 | string(STRIP "${GIT_BRANCH}" GIT_BRANCH) 27 | string(STRIP "${GIT_VERSION}" GIT_VERSION) 28 | string(SUBSTRING "${GIT_VERSION}" 12 -1 GIT_VERSION) 29 | endif() 30 | 31 | # Why the following values? They're pulled from LambdaMOO's version_src guidelines in /docs 32 | 33 | set(VERSION " 34 | #define VERSION_SOURCE(DEF) \\ 35 | DEF(vcs,\"git\") \\ 36 | DEF(vcs_version,\"${GIT_VERSION}\") \\ 37 | DEF(commit,\"${GIT_REV}${GIT_DIFF}\") \\ 38 | DEF(branch,\"${GIT_BRANCH}\") \\ 39 | DEF(url,\"https://github.com/lisdude/toaststunt\") 40 | ") 41 | 42 | if(EXISTS ${CMAKE_BINARY_DIR}/version_src.h) 43 | file(READ ${CMAKE_BINARY_DIR}/version_src.h VERSION_) 44 | else() 45 | set(VERSION_ "") 46 | endif() 47 | 48 | if (NOT "${VERSION}" STREQUAL "${VERSION_}") 49 | file(WRITE ${CMAKE_BINARY_DIR}/version_src.h "${VERSION}") 50 | endif() 51 | -------------------------------------------------------------------------------- /src/include/crypto.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2013 Todd Sundsted. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY TODD SUNDSTED ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL TODD SUNDSTED OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 20 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are 26 | those of the authors and should not be interpreted as representing official 27 | policies, either expressed or implied, of Todd Sundsted. 28 | *****************************************************************************/ 29 | 30 | extern void register_crypto(void); 31 | -------------------------------------------------------------------------------- /test/tests/Anon1.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 17 ** 2 | 1 3 | 3 4 | 0 values pending finalization 5 | 0 clocks 6 | 0 queued tasks 7 | 0 suspended tasks 8 | 0 interrupted tasks 9 | 0 active connections with listeners 10 | 4 11 | #0 12 | System Object 13 | 16 14 | 3 15 | 1 16 | -1 17 | 0 18 | 0 19 | 4 20 | 0 21 | 1 22 | 1 23 | 4 24 | 0 25 | 1 26 | server_started 27 | 3 28 | 173 29 | -1 30 | 0 31 | 0 32 | #1 33 | Root Class 34 | 16 35 | 3 36 | 1 37 | -1 38 | 0 39 | 0 40 | 4 41 | 0 42 | 1 43 | -1 44 | 4 45 | 3 46 | 1 47 | 0 48 | 1 49 | 2 50 | 1 51 | 3 52 | 0 53 | 0 54 | 0 55 | #2 56 | The First Room 57 | 0 58 | 3 59 | 1 60 | -1 61 | 0 62 | 0 63 | 4 64 | 1 65 | 1 66 | 3 67 | 1 68 | 1 69 | 4 70 | 0 71 | 1 72 | eval 73 | 3 74 | 88 75 | -2 76 | 0 77 | 0 78 | #3 79 | Wizard 80 | 7 81 | 3 82 | 1 83 | 2 84 | 0 85 | 0 86 | 4 87 | 0 88 | 1 89 | 1 90 | 4 91 | 0 92 | 0 93 | 0 94 | 0 95 | 0 96 | 1 97 | #0:0 98 | server_log("----------------------------------------------------------------------"); 99 | server_log("Creates garbage and shuts down. The garbage will be in the pending "); 100 | server_log("anonymous objects as #4. There will also be an object #4. When the "); 101 | server_log("server restarts from the dumped database, the pending object will be "); 102 | server_log("recycled. "); 103 | server_log("----------------------------------------------------------------------"); 104 | suspend(0); 105 | try 106 | try 107 | l = {o = create(#-1, 1)}; 108 | add_verb(o, {task_perms(), "xd", "recycle"}, {"this", "none", "this"}); 109 | set_verb_code(o, "recycle", {"server_log(\"recycle called\");"}); 110 | except ex (ANY) 111 | server_log(toliteral(ex)); 112 | endtry 113 | finally 114 | shutdown(); 115 | endtry 116 | . 117 | -------------------------------------------------------------------------------- /docs/Features/new_miscellaneous.md: -------------------------------------------------------------------------------- 1 | - Miscellaneous changes: 2 | - .last_move (a map of an object's last location and the time() it moved) 3 | - Sub-second fork and suspend 4 | - Call 'do_blank_command' on listening objects when a blank command is issued 5 | - Allow `"string" in "some other string"` as a shortcut for index() 6 | - Allow exec to set environment variables with a new argument 7 | - Change the server log message when calling switch_player() 8 | - Deprecation of `tonum()` in favor of `toint()` 9 | - Move #0.dump_interval to $server_options.dump_interval 10 | - New argument to `notify()` to suppress the newline 11 | - Support object lists in `isa()` as well as an optional third argument to return the matching parent rather than simply true or false 12 | - New argument to `move()` to effectively `listinsert()` the object into the destination's .contents 13 | - New argument to `is_member()` for controlling case sensitivity of equality comparisons. No third argument or a true value results in standard functionality; a false value as the third argument results in case not mattering at all 14 | - Update `random()` to accept a second optional argument for setting the maximum value returned. Including the second argument will treat the first argument as the minimum. 15 | - Update `shutdown()` to accept a second optional argument for triggering an unclean shutdown (panic). This effectively replaces the `panic()` builtin, previously available in versions 2.7.3 and earlier. 16 | - SIGUSR1 will close and reopen the logfile, allowing it to be rotated without restarting the server. 17 | - '-m' command line option to clear all last_move properties in your database (and not set them again for the lifetime of the process). 18 | - Build system is now CMake 19 | - Boolean (BOOL) type 20 | - Allow handling of SIGUSR signals in the database with `#0:handle_signal()` 21 | -------------------------------------------------------------------------------- /src/include/unparse.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Unparse_h 19 | #define Unparse_h 1 20 | 21 | #include 22 | 23 | #include "config.h" 24 | #include "program.h" 25 | #include "structures.h" 26 | 27 | typedef void (*Unparser_Receiver) (void *, const char *); 28 | 29 | extern void unparse_program(Program *, Unparser_Receiver, void *, 30 | int fully_parenthesize, 31 | int indent_lines, int f_index); 32 | 33 | extern void unparse_to_file(FILE * fp, Program *, 34 | int fully_parenthesize, 35 | int indent_lines, int f_index); 36 | extern void unparse_to_stderr(Program *, int fully_parenthesize, 37 | int indent_lines, int f_index); 38 | 39 | extern const char *error_name(enum error); /* E_NONE -> "E_NONE" */ 40 | extern const char *unparse_error(enum error); /* E_NONE -> "No error" */ 41 | 42 | extern int parse_error(const char *error); /* "E_NONE" -> E_NONE */ 43 | extern const char* parse_type(var_type); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/include/parse_cmd.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Parse_Cmd_H 19 | #define Parse_Cmd_H 1 20 | 21 | #include "config.h" 22 | #include "db.h" 23 | #include "structures.h" 24 | 25 | typedef struct { 26 | const char *verb; /* verb (as typed by player) */ 27 | const char *argstr; /* arguments to verb */ 28 | Var args; /* arguments to the verb */ 29 | 30 | const char *dobjstr; /* direct object string */ 31 | Objid dobj; /* direct object */ 32 | 33 | const char *prepstr; /* preposition string */ 34 | db_prep_spec prep; /* preposition identifier */ 35 | 36 | const char *iobjstr; /* indirect object string */ 37 | Objid iobj; /* indirect object */ 38 | } Parsed_Command; 39 | 40 | extern char **parse_into_words(char *input, int *nwords); 41 | extern Var parse_into_wordlist(const char *command); 42 | extern Parsed_Command *parse_command(const char *command, Objid user); 43 | extern void free_parsed_command(Parsed_Command *); 44 | 45 | #endif /* !Parse_Cmd_H */ 46 | -------------------------------------------------------------------------------- /src/include/garbage.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2012 Todd Sundsted. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY TODD SUNDSTED ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL TODD SUNDSTED OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 20 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are 26 | those of the authors and should not be interpreted as representing official 27 | policies, either expressed or implied, of Todd Sundsted. 28 | *****************************************************************************/ 29 | 30 | #include "structures.h" 31 | 32 | extern int gc_roots_count; 33 | extern int gc_run_called; 34 | 35 | extern void gc_possible_root(Var); 36 | extern void gc_collect(void); 37 | -------------------------------------------------------------------------------- /src/include/eval_vm.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "config.h" 19 | #include "execute.h" 20 | #include "structures.h" 21 | 22 | extern vm read_vm(int task_id); 23 | extern void write_vm(vm); 24 | 25 | extern vm new_vm(int task_id, Var local, int stack_size); /* Creates a new vm. 26 | * Stores task id and 27 | * task local value. 28 | * Consumes `local'. 29 | */ 30 | extern void free_vm(vm the_vm, int stack_too); /* Frees vm. Free 31 | * associated allocations 32 | * if `stack_too' is 1. 33 | */ 34 | extern activation top_activ(vm); 35 | extern Objid progr_of_cur_verb(vm); 36 | extern unsigned suspended_lineno_of_vm(vm); 37 | -------------------------------------------------------------------------------- /test/tests/Anon5.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 17 ** 2 | 1 3 | 3 4 | 0 values pending finalization 5 | 0 clocks 6 | 0 queued tasks 7 | 0 suspended tasks 8 | 0 interrupted tasks 9 | 0 active connections with listeners 10 | 4 11 | #0 12 | System Object 13 | 16 14 | 3 15 | 1 16 | -1 17 | 0 18 | 0 19 | 4 20 | 0 21 | 1 22 | 1 23 | 4 24 | 0 25 | 1 26 | server_started 27 | 3 28 | 173 29 | -1 30 | 0 31 | 0 32 | #1 33 | Root Class 34 | 16 35 | 3 36 | 1 37 | -1 38 | 0 39 | 0 40 | 4 41 | 0 42 | 1 43 | -1 44 | 4 45 | 3 46 | 1 47 | 0 48 | 1 49 | 2 50 | 1 51 | 3 52 | 0 53 | 0 54 | 0 55 | #2 56 | The First Room 57 | 0 58 | 3 59 | 1 60 | -1 61 | 0 62 | 0 63 | 4 64 | 1 65 | 1 66 | 3 67 | 1 68 | 1 69 | 4 70 | 0 71 | 1 72 | eval 73 | 3 74 | 88 75 | -2 76 | 0 77 | 0 78 | #3 79 | Wizard 80 | 7 81 | 3 82 | 1 83 | 2 84 | 0 85 | 0 86 | 4 87 | 0 88 | 1 89 | 1 90 | 4 91 | 0 92 | 0 93 | 0 94 | 0 95 | 0 96 | 1 97 | #0:0 98 | server_log("----------------------------------------------------------------------"); 99 | server_log("Creates an object that indirectly references an anonymous object"); 100 | server_log("that has a reference to itself. Each iteration of the database"); 101 | server_log("should preserve these objects."); 102 | server_log("----------------------------------------------------------------------"); 103 | suspend(0); 104 | try 105 | try 106 | if (!("one" in properties(#0))) 107 | add_property(#0, "one", create(#-1, 0), {$owner, ""}); 108 | add_property($one, "two", ["foo" -> create(#-1, 1)], {$one.owner, ""}); 109 | add_property($one.two["foo"], "foo", $one.two["foo"], {$one.owner, ""}); 110 | else 111 | "take references and lose them, to make the object purple"; 112 | a = $one.two["foo"]; 113 | b = $one.two["foo"]; 114 | a = 0; 115 | b = 0; 116 | endif 117 | except ex (ANY) 118 | server_log(toliteral(ex)); 119 | endtry 120 | finally 121 | run_gc(); 122 | suspend(0); 123 | shutdown(); 124 | kill_task(task_id()); 125 | endtry 126 | . 127 | -------------------------------------------------------------------------------- /src/include/exec.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2011 Todd Sundsted. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY TODD SUNDSTED ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL TODD SUNDSTED OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 20 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are 26 | those of the authors and should not be interpreted as representing official 27 | policies, either expressed or implied, of Todd Sundsted. 28 | *****************************************************************************/ 29 | 30 | #ifndef Exec_H 31 | #define Exec_H 1 32 | 33 | #include "config.h" 34 | 35 | extern char *exec_subdir; 36 | 37 | extern void deal_with_child_exit(void); 38 | 39 | extern pid_t exec_complete(pid_t p, int code); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/include/background.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTENSION_BACKGROUND_H 2 | #define EXTENSION_BACKGROUND_H 1 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "functions.h" 9 | #include "thpool.h" // thread pool 10 | 11 | #define MAX_BACKGROUND_THREADS 20 /* The total number threads allowed to be queued from within the MOO. 12 | Can be overridden with $server_options.max_background_threads */ 13 | 14 | typedef struct background_waiter { 15 | Var return_value; // The final return value that gets sucked up by the network callback. 16 | Var data; // Any MOO data the callback function should be aware of. (Typically arglist.) 17 | vm the_vm; // Where we resume when we're done. 18 | void (*callback)(Var, Var*, void*); // The callback function that does the actual work. 19 | void (*cleanup)(void*); // Optional function to perform cleanup after success or error. Receives extra_data. 20 | void *extra_data; // Additional non-Var-specific data for the callback function. 21 | // NOTE: You must manage the memory of this yourself. 22 | int fd[2]; // The pipe used to resume the task immediately. 23 | uint16_t handle; // Our position in the process table. 24 | bool active; // @kill will set active to false and the callback should handle it accordingly. 25 | } background_waiter; 26 | 27 | extern pthread_mutex_t shutdown_mutex; 28 | extern pthread_cond_t shutdown_condition; 29 | extern uint16_t shutdown_complete; 30 | 31 | // User-visible functions 32 | extern package background_thread(void (*callback)(Var, Var*, void*), Var* data, void *extra_data = nullptr, void (*cleanup)(void*) = nullptr); 33 | extern void make_error_map(enum error error_type, const char *msg, Var *ret); 34 | extern void background_shutdown(); 35 | 36 | #endif /* EXTENSION_BACKGROUND_H */ 37 | -------------------------------------------------------------------------------- /src/include/bf_register.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | extern void register_gc(void); 19 | extern void register_collection(void); 20 | extern void register_disassemble(void); 21 | extern void register_extensions(void); 22 | extern void register_execute(void); 23 | extern void register_functions(void); 24 | extern void register_list(void); 25 | extern void register_log(void); 26 | extern void register_map(void); 27 | extern void register_numbers(void); 28 | extern void register_objects(void); 29 | extern void register_property(void); 30 | extern void register_server(void); 31 | extern void register_tasks(void); 32 | extern void register_verbs(void); 33 | extern void register_yajl(void); 34 | extern void register_base64(void); 35 | extern void register_fileio(void); 36 | extern void register_system(void); 37 | extern void register_exec(void); 38 | extern void register_crypto(void); 39 | extern void register_sqlite(void); 40 | extern void register_pcre(void); 41 | extern void register_background(void); 42 | extern void register_waif(void); 43 | extern void register_simplexnoise(void); 44 | extern void register_argon2(void); 45 | extern void register_spellcheck(void); 46 | extern void register_curl(void); -------------------------------------------------------------------------------- /src/include/program.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Program_H 19 | #define Program_H 20 | 21 | #include "structures.h" 22 | #include "version.h" 23 | 24 | typedef uint8_t Byte; 25 | 26 | typedef struct { 27 | Byte numbytes_label, numbytes_literal, numbytes_fork, numbytes_var_name, 28 | numbytes_stack; 29 | Byte *vector; 30 | unsigned size; 31 | unsigned max_stack; 32 | } Bytecodes; 33 | 34 | typedef struct { 35 | DB_Version version; 36 | unsigned first_lineno; 37 | unsigned ref_count; 38 | 39 | Bytecodes main_vector; 40 | 41 | unsigned num_literals; 42 | Var *literals; 43 | 44 | unsigned fork_vectors_size; 45 | Bytecodes *fork_vectors; 46 | 47 | unsigned num_var_names; 48 | const char **var_names; 49 | 50 | unsigned cached_lineno; 51 | unsigned cached_lineno_pc; 52 | int cached_lineno_vec; 53 | } Program; 54 | 55 | #define MAIN_VECTOR -1 /* As opposed to an index into fork_vectors */ 56 | 57 | extern Program *new_program(void); 58 | extern Program *null_program(void); 59 | extern Program *program_ref(Program *); 60 | extern int program_bytes(Program *); 61 | extern void free_program(Program *); 62 | 63 | #endif /* !Program_H */ 64 | -------------------------------------------------------------------------------- /src/quota.cc: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "config.h" 19 | #include "db.h" 20 | #include "quota.h" 21 | #include "structures.h" 22 | 23 | #ifdef OWNERSHIP_QUOTA 24 | static const char *quota_name = "ownership_quota"; 25 | #endif 26 | 27 | int 28 | decr_quota(Objid player) 29 | { 30 | #ifdef OWNERSHIP_QUOTA 31 | db_prop_handle h; 32 | Var v; 33 | 34 | if (!valid(player)) 35 | return 1; 36 | 37 | h = db_find_property(Var::new_obj(player), quota_name, &v); 38 | if (!h.ptr) 39 | return 1; 40 | 41 | if (v.type != TYPE_INT) 42 | return 1; 43 | 44 | if (v.v.num <= 0) 45 | return 0; 46 | 47 | v.v.num--; 48 | db_set_property_value(h, v); 49 | #endif /* OWNERSHIP_QUOTA */ 50 | return 1; 51 | } 52 | 53 | void 54 | incr_quota(Objid player) 55 | { 56 | #ifdef OWNERSHIP_QUOTA 57 | db_prop_handle h; 58 | Var v; 59 | 60 | if (!valid(player)) 61 | return; 62 | 63 | h = db_find_property(Var::new_obj(player), quota_name, &v); 64 | if (!h.ptr) 65 | return; 66 | 67 | if (v.type != TYPE_INT) 68 | return; 69 | 70 | v.v.num++; 71 | db_set_property_value(h, v); 72 | #endif /* OWNERSHIP_QUOTA */ 73 | } 74 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /** 34 | * \file yajl_alloc.h 35 | * default memory allocation routines for yajl which use malloc/realloc and 36 | * free 37 | */ 38 | 39 | #ifndef __YAJL_ALLOC_H__ 40 | #define __YAJL_ALLOC_H__ 41 | 42 | #include "yajl_common.h" 43 | 44 | #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz)) 45 | #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr)) 46 | #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz)) 47 | 48 | void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/tests/Anon2.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 17 ** 2 | 1 3 | 3 4 | 0 values pending finalization 5 | 0 clocks 6 | 0 queued tasks 7 | 0 suspended tasks 8 | 0 interrupted tasks 9 | 0 active connections with listeners 10 | 4 11 | #0 12 | System Object 13 | 16 14 | 3 15 | 1 16 | -1 17 | 0 18 | 0 19 | 4 20 | 0 21 | 1 22 | 1 23 | 4 24 | 0 25 | 1 26 | server_started 27 | 3 28 | 173 29 | -1 30 | 0 31 | 0 32 | #1 33 | Root Class 34 | 16 35 | 3 36 | 1 37 | -1 38 | 0 39 | 0 40 | 4 41 | 0 42 | 1 43 | -1 44 | 4 45 | 3 46 | 1 47 | 0 48 | 1 49 | 2 50 | 1 51 | 3 52 | 0 53 | 0 54 | 0 55 | #2 56 | The First Room 57 | 0 58 | 3 59 | 1 60 | -1 61 | 0 62 | 0 63 | 4 64 | 1 65 | 1 66 | 3 67 | 1 68 | 1 69 | 4 70 | 0 71 | 1 72 | eval 73 | 3 74 | 88 75 | -2 76 | 0 77 | 0 78 | #3 79 | Wizard 80 | 7 81 | 3 82 | 1 83 | 2 84 | 0 85 | 0 86 | 4 87 | 0 88 | 1 89 | 1 90 | 4 91 | 0 92 | 0 93 | 0 94 | 0 95 | 0 96 | 1 97 | #0:0 98 | server_log("----------------------------------------------------------------------"); 99 | server_log("Creates cyclic garbage and shuts down. The garbage will be in the "); 100 | server_log("pending anonymous objects as #4 and #5. There will also be objects #4"); 101 | server_log("and #5. When the server restarts from the dumped database, the "); 102 | server_log("pending objects will be recycled. "); 103 | server_log("----------------------------------------------------------------------"); 104 | suspend(0); 105 | try 106 | try 107 | a = create(#-1, 1); 108 | add_property(a, "next", 0, {task_perms(), ""}); 109 | add_verb(a, {task_perms(), "xd", "recycle"}, {"this", "none", "this"}); 110 | set_verb_code(a, "recycle", {"server_log(\"recycle called on A\");"}); 111 | b = create(#-1, 1); 112 | add_property(b, "next", 0, {task_perms(), ""}); 113 | add_verb(b, {task_perms(), "xd", "recycle"}, {"this", "none", "this"}); 114 | set_verb_code(b, "recycle", {"server_log(\"recycle called on B\");"}); 115 | a.name = "A"; 116 | b.name = "B"; 117 | a.next = b; 118 | b.next = a; 119 | except ex (ANY) 120 | server_log(toliteral(ex)); 121 | endtry 122 | finally 123 | shutdown(); 124 | endtry 125 | . 126 | -------------------------------------------------------------------------------- /src/include/waif.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1998-2002 Ben Jackson (ben@ben.com). All rights reserved. 2 | * 3 | * Use and copying of this software and preparation of derivative works based 4 | * upon this software are permitted provided this copyright notice remains 5 | * intact. 6 | * 7 | * THIS SOFTWARE IS PROVIDED BY BEN J JACKSON ``AS IS'' AND ANY 8 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 9 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 10 | * PURPOSE ARE DISCLAIMED. IN NO EVENT BEN J JACKSON BE LIABLE FOR 11 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 12 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 13 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 14 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 15 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 16 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 17 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 | */ 19 | 20 | /* $Id$ */ 21 | 22 | #ifndef WAIF_h 23 | #define WAIF_h 24 | 25 | #include 26 | 27 | #define WAIF_PROP_PREFIX ':' 28 | #define WAIF_VERB_PREFIX ':' 29 | 30 | extern std::unordered_map destroyed_waifs; 31 | 32 | #ifdef WAIF_DICT 33 | #define WAIF_INDEX_VERB ":_index" 34 | #define WAIF_INDEXSET_VERB ":_set_index" 35 | #endif /* WAIF_DICT */ 36 | 37 | #include "db_private.h" 38 | 39 | typedef struct WaifPropdefs { 40 | int refcount; 41 | int length; 42 | struct Propdef defs[1]; 43 | } WaifPropdefs; 44 | 45 | extern void free_waif(Waif *); 46 | extern Waif *dup_waif(Waif *); 47 | extern enum error waif_get_prop(Waif *, const char *, Var *, Objid progr); 48 | extern enum error waif_put_prop(Waif *, const char *, Var, Objid progr); 49 | extern int waif_bytes(Waif *); 50 | extern void waif_before_saving(); 51 | extern void waif_after_saving(); 52 | extern void waif_before_loading(); 53 | extern void waif_after_loading(); 54 | extern void write_waif(Var); 55 | extern Var read_waif(); 56 | extern void free_waif_propdefs(WaifPropdefs *); 57 | extern void waif_rename_propdef(Object *, const char *, const char *); 58 | 59 | #endif /* WAIF_h */ 60 | -------------------------------------------------------------------------------- /docs/Features/new_builtins.md: -------------------------------------------------------------------------------- 1 | - Additional builtins: 2 | - frandom (random floats) 3 | - distance (calculate the distance between an arbitrary number of points) 4 | - relative_heading (a relative bearing between two coordinate sets) 5 | - memory_usage (total memory used, resident set size, shared pages, text, data + stack) 6 | - ftime (precise time, including an argument for monotonic timing) 7 | - locate_by_name (quickly locate objects by their .name property) 8 | - usage (returns {load averages}, user time, system time, page reclaims, page faults, block input ops, block output ops, voluntary context switches, involuntary context switches, signals received) 9 | - explode (serverified version of the LambdaCore verb on $string_utils) 10 | - slice (serverified version of the LambdaCore verb on $list_utils) 11 | - occupants (return a list of objects of parent parent, optionally with a player flag check) 12 | - spellcheck (uses Aspell to check spelling) 13 | - locations (recursive location function) 14 | - clear_ancestor_cache (clears the ancestor cache manually) 15 | - chr (return extended ASCII characters; characters that can corrupt your database are considered invalid) 16 | - reseed_random (reseed the random number generator) 17 | - yin (yield if needed. Replicates :suspend_if_needed and ticks_left() checks) 18 | - sort (a significantly faster replacement for the :sort verb. Also allows for natural sort order and reverse sorting) 19 | - recreate (fill holes created by recycle() by recreating valid objects with those object numbers) 20 | - recycled_objects (return a list of all objects destroyed by calling recycle()) 21 | - next_recycled_object (return the next object available for recreation) 22 | - reverse (reverse lists) 23 | - all_members (return the indices of all instances of a type in a list) 24 | - curl (return webpage as string) 25 | - owned_objects (returns all valid objects owned by an object) 26 | - connection_name_lookup (perform a DNS name lookup) 27 | - connection_info (show detailed information about a particular connection) 28 | - parse_ansi (parses color tags into their ANSI equivalents) 29 | - remove_ansi (strips ANSI tags from strings) 30 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __YAJL_ENCODE_H__ 34 | #define __YAJL_ENCODE_H__ 35 | 36 | #include "yajl_buf.h" 37 | #include "yajl_gen.h" 38 | 39 | void yajl_string_encode2(const yajl_print_t printer, 40 | void * ctx, 41 | const unsigned char * str, 42 | unsigned int length); 43 | 44 | void yajl_string_encode(yajl_buf buf, const unsigned char * str, 45 | unsigned int length); 46 | 47 | void yajl_string_decode(yajl_buf buf, const unsigned char * str, 48 | unsigned int length); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/include/sym_table.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Sym_Table_h 19 | #define Sym_Table_h 1 20 | 21 | #include "config.h" 22 | #include "version.h" 23 | 24 | typedef struct { 25 | unsigned max_size; 26 | unsigned size; 27 | const char **names; 28 | } Names; 29 | 30 | extern Names *new_builtin_names(DB_Version); 31 | extern int first_user_slot(DB_Version); 32 | extern unsigned find_or_add_name(Names **, const char *); 33 | extern int find_name(Names *, const char *); 34 | extern void free_names(Names *); 35 | 36 | /* Environment slots for built-in variables */ 37 | #define SLOT_NUM 0 38 | #define SLOT_OBJ 1 39 | #define SLOT_STR 2 40 | #define SLOT_LIST 3 41 | #define SLOT_ERR 4 42 | #define SLOT_PLAYER 5 43 | #define SLOT_THIS 6 44 | #define SLOT_CALLER 7 45 | #define SLOT_VERB 8 46 | #define SLOT_ARGS 9 47 | #define SLOT_ARGSTR 10 48 | #define SLOT_DOBJ 11 49 | #define SLOT_DOBJSTR 12 50 | #define SLOT_PREPSTR 13 51 | #define SLOT_IOBJ 14 52 | #define SLOT_IOBJSTR 15 53 | 54 | /* Added in DBV_Float: */ 55 | #define SLOT_INT 16 56 | #define SLOT_FLOAT 17 57 | 58 | /* Added in DBV_Map: */ 59 | #define SLOT_MAP 18 60 | 61 | /* Added in DBV_Anon */ 62 | #define SLOT_ANON 19 63 | 64 | /* Added in DBV_Waif */ 65 | #define SLOT_WAIF 20 66 | 67 | /* Added in DBV_Bool */ 68 | #define SLOT_BOOL 21 69 | #define SLOT_TRUE 22 70 | #define SLOT_FALSE 23 71 | 72 | #endif /* !Sym_Table_h */ 73 | -------------------------------------------------------------------------------- /src/include/streams.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Stream_h 19 | #define Stream_h 1 20 | 21 | #include 22 | 23 | #include "config.h" 24 | 25 | typedef struct { 26 | char *buffer; 27 | int buflen; 28 | int current; 29 | } Stream; 30 | 31 | extern Stream *new_stream(int size); 32 | extern void stream_add_char(Stream *, char); 33 | extern void stream_delete_char(Stream *); 34 | extern void stream_add_string(Stream *, const char *); 35 | extern void stream_printf(Stream *, const char *,...); 36 | extern void free_stream(Stream *); 37 | extern char *stream_contents(Stream *); 38 | extern char *reset_stream(Stream *); 39 | extern int stream_length(Stream *); 40 | 41 | class stream_too_big: public std::exception 42 | { 43 | public: 44 | 45 | stream_too_big() throw() {} 46 | 47 | ~stream_too_big() throw() override {} 48 | 49 | const char* what() const throw() override { 50 | return "stream too big"; 51 | } 52 | }; 53 | 54 | /* 55 | * Calls to enable_stream_exceptions() and disable_stream_exceptions() 56 | * must be paired and nest properly. 57 | * 58 | * If enable_stream_exceptions() is in effect, then, upon any attempt 59 | * to grow a stream beyond stream_alloc_maximum bytes, a 60 | * stream_too_big exception will be raised. 61 | */ 62 | extern void enable_stream_exceptions(); 63 | extern void disable_stream_exceptions(); 64 | 65 | extern size_t stream_alloc_maximum; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/include/config.h.cmake: -------------------------------------------------------------------------------- 1 | #cmakedefine ONLY_32_BITS @ONLY_32_BITS@ 2 | 3 | #ifdef ONLY_32_BITS 4 | # define PRId32 "d" 5 | # define PRIi32 "i" 6 | # define PRIo32 "o" 7 | # define PRIu32 "u" 8 | # define PRIx32 "x" 9 | # define PRIX32 "X" 10 | # define SCNd32 "d" 11 | # define SCNi32 "i" 12 | # define SCNo32 "o" 13 | # define SCNu32 "u" 14 | # define SCNx32 "x" 15 | #else 16 | # if !defined(__MACH__) && !defined(__arm__) 17 | # define PRId64 "ld" 18 | # define PRIi64 "li" 19 | # define PRIo64 "lo" 20 | # define PRIu64 "lu" 21 | # define PRIx64 "lx" 22 | # define PRIX64 "lX" 23 | # define SCNd64 "ld" 24 | # define SCNi64 "li" 25 | # define SCNo64 "lo" 26 | # define SCNu64 "lu" 27 | # define SCNx64 "lx" 28 | # else 29 | # define PRId64 "lld" 30 | # define PRIi64 "lli" 31 | # define PRIo64 "llo" 32 | # define PRIu64 "llu" 33 | # define PRIx64 "llx" 34 | # define PRIX64 "llX" 35 | # define SCNd64 "lld" 36 | # define SCNi64 "lli" 37 | # define SCNo64 "llo" 38 | # define SCNu64 "llu" 39 | # define SCNx64 "llx" 40 | # endif 41 | #endif 42 | 43 | #cmakedefine VERSION_MAJOR @VERSION_MAJOR@ 44 | #cmakedefine VERSION_MINOR @VERSION_MINOR@ 45 | #cmakedefine VERSION_RELEASE @VERSION_RELEASE@ 46 | #cmakedefine VERSION_EXT "@VERSION_EXT@" 47 | #ifndef VERSION_RELEASE 48 | // Work around VERSION_RELEASE not being defined when 0. 49 | # define VERSION_RELEASE 0 50 | #endif 51 | 52 | #cmakedefine01 HAVE_STRFTIME 53 | #cmakedefine01 HAVE_TM_ZONE 54 | #cmakedefine01 HAVE_TZNAME 55 | #cmakedefine01 HAVE_SELECT 56 | #cmakedefine01 HAVE_POLL 57 | #cmakedefine01 HAVE_RANDOM 58 | #cmakedefine01 HAVE_LRAND48 59 | #cmakedefine01 HAVE_WAITPID 60 | #cmakedefine01 HAVE_WAIT2 61 | #cmakedefine01 HAVE_WAIT3 62 | #cmakedefine01 HAVE_SIGEMPTYSET 63 | #cmakedefine01 HAVE_SIGRELSE 64 | #cmakedefine01 HAVE_ACCEPT4 65 | #cmakedefine IS_WSL 66 | 67 | #if @HAVE_STRTOIMAX@ 68 | # ifdef HAVE_LONG_LONG 69 | # define strtoimax strtoll 70 | # define strtoumax strtoull 71 | # else 72 | # define strtoimax strtol 73 | # define strtoumax strtoul 74 | # endif 75 | #endif 76 | 77 | #cmakedefine ARGON2_FOUND 78 | #cmakedefine ASPELL_FOUND 79 | #cmakedefine CURL_FOUND 80 | #cmakedefine PCRE_FOUND 81 | #cmakedefine SQLITE3_FOUND 82 | #cmakedefine OPENSSL_FOUND 83 | #cmakedefine JEMALLOC_FOUND 84 | 85 | #ifndef OPENSSL_FOUND 86 | #undef USE_TLS 87 | #endif 88 | -------------------------------------------------------------------------------- /src/net_mp_selct.cc: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | /* Multiplexing wait implementation using the BSD UNIX select() system call */ 19 | 20 | #include /* errno */ 21 | #include /* bzero() or memset(), used in FD_ZERO */ 22 | #include /* select(), struct timeval */ 23 | #include /* fd_set, FD_ZERO(), FD_SET(), FD_ISSET() */ 24 | 25 | #include "log.h" 26 | #include "net_mplex.h" 27 | 28 | static fd_set input, output; 29 | static int max_descriptor; 30 | 31 | void 32 | mplex_clear(void) 33 | { 34 | FD_ZERO(&input); 35 | FD_ZERO(&output); 36 | max_descriptor = -1; 37 | } 38 | 39 | void 40 | mplex_add_reader(int fd) 41 | { 42 | FD_SET(fd, &input); 43 | if (fd > max_descriptor) 44 | max_descriptor = fd; 45 | } 46 | 47 | void 48 | mplex_add_writer(int fd) 49 | { 50 | FD_SET(fd, &output); 51 | if (fd > max_descriptor) 52 | max_descriptor = fd; 53 | } 54 | 55 | int 56 | mplex_wait(unsigned timeout) 57 | { 58 | struct timeval tv; 59 | int n; 60 | 61 | tv.tv_sec = timeout / 1000000; 62 | tv.tv_usec = timeout % 1000000; 63 | 64 | n = select(max_descriptor + 1, &input, &output, nullptr, &tv); 65 | 66 | if (n < 0) { 67 | if (errno != EINTR) 68 | log_perror("Waiting for network I/O"); 69 | return 1; 70 | } else 71 | return (n == 0); 72 | } 73 | 74 | int 75 | mplex_is_readable(int fd) 76 | { 77 | return FD_ISSET(fd, &input); 78 | } 79 | 80 | int 81 | mplex_is_writable(int fd) 82 | { 83 | return FD_ISSET(fd, &output); 84 | } 85 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_alloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /** 34 | * \file yajl_alloc.h 35 | * default memory allocation routines for yajl which use malloc/realloc and 36 | * free 37 | */ 38 | 39 | #include "yajl_alloc.h" 40 | #include 41 | 42 | static void * yajl_internal_malloc(void *ctx, unsigned int sz) 43 | { 44 | return malloc(sz); 45 | } 46 | 47 | static void * yajl_internal_realloc(void *ctx, void * previous, 48 | unsigned int sz) 49 | { 50 | return realloc(previous, sz); 51 | } 52 | 53 | static void yajl_internal_free(void *ctx, void * ptr) 54 | { 55 | free(ptr); 56 | } 57 | 58 | void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf) 59 | { 60 | yaf->malloc = yajl_internal_malloc; 61 | yaf->free = yajl_internal_free; 62 | yaf->realloc = yajl_internal_realloc; 63 | yaf->ctx = NULL; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/include/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Base64 encoding/decoding (RFC1341) 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | /****************************************************************************** 15 | Copyright 2010 Todd Sundsted. All rights reserved. 16 | 17 | Redistribution and use in source and binary forms, with or without 18 | modification, are permitted provided that the following conditions are met: 19 | 20 | 1. Redistributions of source code must retain the above copyright notice, 21 | this list of conditions and the following disclaimer. 22 | 23 | 2. Redistributions in binary form must reproduce the above copyright notice, 24 | this list of conditions and the following disclaimer in the documentation 25 | and/or other materials provided with the distribution. 26 | 27 | THIS SOFTWARE IS PROVIDED BY TODD SUNDSTED ``AS IS'' AND ANY EXPRESS OR 28 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 29 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 30 | EVENT SHALL TODD SUNDSTED OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 31 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 33 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 34 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 36 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | 38 | The views and conclusions contained in the software and documentation are 39 | those of the authors and should not be interpreted as representing official 40 | policies, either expressed or implied, of Todd Sundsted. 41 | *****************************************************************************/ 42 | 43 | #ifndef BASE64_H 44 | #define BASE64_H 45 | 46 | char *base64_encode(const char *src, size_t len, size_t *out_len); 47 | char *base64_decode(const char *src, size_t len, size_t *out_len); 48 | 49 | #endif /* BASE64_H */ 50 | -------------------------------------------------------------------------------- /docs/ServerDevelopment/AddingNewMOOTypes.txt: -------------------------------------------------------------------------------- 1 | There are a number of places in the server that have to be changed when adding 2 | a new type of MOO value; this file attempts to list all of them for easy 3 | reference. 4 | 5 | First, though, it is important to realize that there are several types of MOO 6 | values that are invisible to MOO programmers; they are used for a variety of 7 | purposes internally in the virtual machine or database, and they can appear in 8 | the DB file on disk, but they are never the value of a MOO expression. Adding 9 | one of these `invisible' types involves only a few changes to the server. 10 | Adding one of the other kind, though, the `visible' types of values that *can* 11 | be the value of a MOO expression, involves a number of additional changes, as 12 | seen below. 13 | 14 | For all new types, both visible and invisible, you must: 15 | -- add an item *at the end* of the `var_type' enumeration in structures.h 16 | -- perhaps add a clause to the union in `struct Var' in structures.h 17 | -- add a case to each of dbio_read_var() and dbio_write_var(), in db_io.c 18 | -- if you're adding a refcounted type, modify var_refcount() and 19 | refcount_overhead() in storage.c 20 | -- also add a case to each of complex_free_var(), complex_var_ref(), 21 | and complex_var_dup() in utils.c 22 | 23 | In addition, for visible types, you must: 24 | -- consider adding a new built-in MOO variable like OBJ, STR, and LIST: 25 | -- add a new SLOT_XXX constant *at the end* of the list in sym_table.h 26 | -- add a new DB version number *just before the end* of the 27 | `DB_Version' enumeration in version.h 28 | -- add a version-contingent clause to fill_in_rt_consts(), 29 | in eval_env.c 30 | -- add a version-contingent clause to each of new_builtin_names() and 31 | first_user_slot(), in sym_table.c 32 | -- consider adding a new kind of MOO literal or expression that produces values 33 | of the new type. 34 | -- add a case to each of list2str() and print_to_stream(), in list.c; the 35 | former is used by the MOO function tostr() and the latter by toliteral(). 36 | -- add a case to to each of become_integer() and become_float(), in numbers.c; 37 | the former is used by toint() and toobj() and the latter by tofloat(). 38 | -- consider adding a clause to is_true(), equality(), and value_bytes(), 39 | in utils.c; the first implements MOO's notion of truth values, the second is 40 | used in the `==' and `!=' expressions and the equals() function, and the 41 | third is used in the MOO function of the same name. 42 | -------------------------------------------------------------------------------- /src/dependencies/linenoise.h: -------------------------------------------------------------------------------- 1 | /* linenoise.h -- guerrilla line editing library against the idea that a 2 | * line editing lib needs to be 20,000 lines of C code. 3 | * 4 | * See linenoise.c for more information. 5 | * 6 | * ------------------------------------------------------------------------ 7 | * 8 | * Copyright (c) 2010, Salvatore Sanfilippo 9 | * Copyright (c) 2010, Pieter Noordhuis 10 | * 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions are 15 | * met: 16 | * 17 | * * Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 20 | * * Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef __LINENOISE_H 38 | #define __LINENOISE_H 39 | 40 | typedef struct linenoiseCompletions { 41 | size_t len; 42 | char **cvec; 43 | } linenoiseCompletions; 44 | 45 | typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *); 46 | void linenoiseSetCompletionCallback(linenoiseCompletionCallback *); 47 | void linenoiseAddCompletion(linenoiseCompletions *, char *); 48 | 49 | char *linenoise(const char *prompt); 50 | int linenoiseHistoryAdd(const char *line); 51 | int linenoiseHistorySetMaxLen(int len); 52 | int linenoiseHistorySave(char *filename); 53 | int linenoiseHistoryLoad(char *filename); 54 | void linenoiseClearScreen(void); 55 | void linenoiseSetMultiLine(int ml); 56 | 57 | #endif /* __LINENOISE_H */ 58 | -------------------------------------------------------------------------------- /test/tests/lib/general_expression_parser.rb: -------------------------------------------------------------------------------- 1 | require 'parslet' 2 | 3 | require 'moo_obj' 4 | require 'moo_err' 5 | 6 | class GeneralExpressionParser < Parslet::Parser 7 | 8 | rule(:space) { match('\s').repeat(1) } 9 | rule(:space?) { space.maybe } 10 | 11 | rule(:digit) { match('[0-9]') } 12 | rule(:digits) { digit.repeat(1) } 13 | rule(:digits?) { digit.repeat(0) } 14 | 15 | rule(:sign?) { match('[-+]').maybe } 16 | 17 | rule(:exp?) { (match('[eE]') >> match('[-+]') >> digits).maybe } 18 | 19 | rule(:float) { ((sign? >> digits? >> str('.') >> digits >> exp?) | (sign? >> digits >> str('.') >> digits? >> exp?)).as(:float) >> space? } 20 | 21 | rule(:integer) { (sign? >> digits).as(:integer) >> space? } 22 | 23 | rule(:number) { float | integer } 24 | 25 | rule(:obj) { (str('#') >> sign? >> digits).as(:obj) >> space? } 26 | 27 | rule(:err) { (str('E_') >> match('[A-Z]').repeat(1)).as(:err) >> space? } 28 | 29 | rule(:string) { (str('"') >> (str('\\') >> any | str('"').absent? >> any).repeat >> str('"')).as(:string) >> space? } 30 | 31 | rule(:pair) { expression.as(:key) >> str('->') >> space? >> expression.as(:value) } 32 | 33 | rule(:map) { 34 | (str('[') >> space? >> str(']')).as(:empty_map) >> space? | 35 | (str('[') >> space? >> ((pair >> str(',') >> space?).repeat >> pair).maybe >> str(']')).as(:map) >> space? 36 | } 37 | 38 | rule(:list) { 39 | (str('{') >> space? >> str('}')).as(:empty_list) >> space? | 40 | (str('{') >> space? >> ((expression >> str(',') >> space?).repeat >> expression).maybe >> str('}')).as(:list) >> space? 41 | } 42 | 43 | rule(:expression) { map | list | string | obj | number | err } 44 | 45 | root :expression 46 | 47 | end 48 | 49 | class GeneralExpressionTransform < Parslet::Transform 50 | 51 | rule(:string => simple(:string)) { eval(string) } 52 | 53 | rule(:integer => simple(:integer)) { integer.to_i } 54 | 55 | rule(:float => simple(:float)) { float.to_f } 56 | 57 | rule(:obj => simple(:obj)) { MooObj.new(obj.to_s) } 58 | 59 | rule(:err => simple(:err)) { MooErr.new(err.to_s) } 60 | 61 | rule(:empty_list => simple(:dummy)) { [] } 62 | rule(:list => simple(:value)) { [value] } 63 | rule(:list => subtree(:list)) { list } 64 | 65 | rule(:empty_map => simple(:dummy)) { {} } 66 | rule(:map => {:key => simple(:key), :value => simple(:value)}) { {key => value} } 67 | rule(:map => subtree(:map)) { map.instance_of?(Array) ? map.inject({}) { |a, i| a[i[:key]] = i[:value] ; a } : {map[:key] => map[:value]}} 68 | 69 | end 70 | -------------------------------------------------------------------------------- /src/system.cc: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2013 Todd Sundsted. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY TODD SUNDSTED ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL TODD SUNDSTED OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 20 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are 26 | those of the authors and should not be interpreted as representing official 27 | policies, either expressed or implied, of Todd Sundsted. 28 | *****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | #include "functions.h" 34 | #include "storage.h" 35 | #include "streams.h" 36 | #include "structures.h" 37 | #include "utils.h" 38 | 39 | #include "system.h" 40 | 41 | /**** built in functions ****/ 42 | 43 | static package 44 | bf_getenv(Var arglist, Byte next, void *vdata, Objid progr) 45 | { 46 | package pack; 47 | 48 | if (!is_wizard(progr)) { 49 | pack = make_error_pack(E_PERM); 50 | } 51 | else { 52 | const char *str; 53 | 54 | if ((str = getenv(arglist.v.list[1].v.str)) != nullptr) { 55 | pack = make_var_pack(str_dup_to_var(raw_bytes_to_binary(str, strlen(str)))); 56 | } else { 57 | pack = no_var_pack(); 58 | } 59 | } 60 | 61 | free_var(arglist); 62 | 63 | return pack; 64 | } 65 | 66 | void 67 | register_system(void) 68 | { 69 | register_function("getenv", 1, 1, bf_getenv, TYPE_STR); 70 | } 71 | -------------------------------------------------------------------------------- /src/spellcheck.cc: -------------------------------------------------------------------------------- 1 | #include "options.h" 2 | 3 | #ifdef ASPELL_FOUND 4 | 5 | #include "bf_register.h" 6 | #include "functions.h" 7 | #include "log.h" 8 | #include "utils.h" 9 | #include "list.h" 10 | 11 | #include 12 | 13 | #define EXT_SPELLCHECK_VERSION "1.0" 14 | 15 | static package 16 | bf_spellcheck(Var arglist, Byte next, void *vdata, Objid progr) { 17 | Var r; 18 | static AspellConfig *spell_config; 19 | if (!spell_config) 20 | { 21 | spell_config = new_aspell_config(); 22 | aspell_config_replace(spell_config, "lang", "en_US"); 23 | } 24 | static AspellCanHaveError *possible_err; 25 | if (!possible_err) 26 | { 27 | possible_err = new_aspell_speller(spell_config); 28 | } 29 | static AspellSpeller *spell_checker = nullptr; 30 | if (aspell_error_number(possible_err) != 0) 31 | { 32 | free_var(arglist); 33 | errlog("SPELLCHECK: Failed to initialize aspell: %s\n", aspell_error_message(possible_err)); 34 | r.type = TYPE_ERR; 35 | return make_error_pack(E_INVARG); 36 | } 37 | else if (!spell_checker) 38 | { 39 | spell_checker = to_aspell_speller(possible_err); 40 | } 41 | 42 | const char *word = arglist.v.list[1].v.str; 43 | int word_size = memo_strlen(arglist.v.list[1].v.str); 44 | 45 | int correct = aspell_speller_check(spell_checker, word, word_size); 46 | if (!correct) { 47 | r = new_list(0); 48 | Var s; 49 | s.type = TYPE_STR; 50 | const AspellWordList *suggestions = aspell_speller_suggest(spell_checker, word, word_size); 51 | AspellStringEnumeration *elements = aspell_word_list_elements(suggestions); 52 | const char *word_suggestion; 53 | while ((word_suggestion = aspell_string_enumeration_next(elements)) != nullptr) 54 | { 55 | s.v.str = str_dup(word_suggestion); 56 | r = listappend(r, s); 57 | } 58 | delete_aspell_string_enumeration(elements); 59 | } else { 60 | r = Var::new_int(correct); 61 | } 62 | free_var(arglist); 63 | return make_var_pack(r); 64 | } 65 | 66 | void register_spellcheck(void) 67 | { 68 | // FreeBSD / macOS/REL aspell doesn't include version string for some reason. (Maybe just remove this?) 69 | #if !defined(__FreeBSD__) && !defined(__MACH__) && !defined(USING_REL) 70 | oklog("REGISTER_SPELLCHECK: v%s (Aspell Library v%s)\n", EXT_SPELLCHECK_VERSION, aspell_version_string()); 71 | #else 72 | oklog("REGISTER_SPELLCHECK: v%s\n", EXT_SPELLCHECK_VERSION); 73 | #endif 74 | 75 | register_function("spellcheck", 1, 1, bf_spellcheck, TYPE_STR); 76 | } 77 | 78 | #else /* ASPELL_FOUND */ 79 | void register_spellcheck(void) { } 80 | #endif /* ASPELL_FOUND */ 81 | -------------------------------------------------------------------------------- /test/tests/Anon4.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 17 ** 2 | 1 3 | 3 4 | 0 values pending finalization 5 | 0 clocks 6 | 0 queued tasks 7 | 0 suspended tasks 8 | 0 interrupted tasks 9 | 0 active connections with listeners 10 | 4 11 | #0 12 | System Object 13 | 16 14 | 3 15 | 1 16 | -1 17 | 0 18 | 0 19 | 4 20 | 0 21 | 1 22 | 1 23 | 4 24 | 0 25 | 1 26 | server_started 27 | 3 28 | 173 29 | -1 30 | 0 31 | 0 32 | #1 33 | Root Class 34 | 16 35 | 3 36 | 1 37 | -1 38 | 0 39 | 0 40 | 4 41 | 0 42 | 1 43 | -1 44 | 4 45 | 3 46 | 1 47 | 0 48 | 1 49 | 2 50 | 1 51 | 3 52 | 0 53 | 0 54 | 0 55 | #2 56 | The First Room 57 | 0 58 | 3 59 | 1 60 | -1 61 | 0 62 | 0 63 | 4 64 | 1 65 | 1 66 | 3 67 | 1 68 | 1 69 | 4 70 | 0 71 | 1 72 | eval 73 | 3 74 | 88 75 | -2 76 | 0 77 | 0 78 | #3 79 | Wizard 80 | 7 81 | 3 82 | 1 83 | 2 84 | 0 85 | 0 86 | 4 87 | 0 88 | 1 89 | 1 90 | 4 91 | 0 92 | 0 93 | 0 94 | 0 95 | 0 96 | 1 97 | #0:0 98 | server_log("----------------------------------------------------------------------"); 99 | server_log("Creates an anonymous object with a reference to another anonymous"); 100 | server_log("object, recycles the latter anonymous object (thus invalidating"); 101 | server_log("it), and dumps the database. On load, loses the reference to the"); 102 | server_log("first object, runs garbage collection, and dumps the database"); 103 | server_log("again. On load, there should be no reference to either object."); 104 | server_log("----------------------------------------------------------------------"); 105 | suspend(0); 106 | if (!("one" in properties(#0))) 107 | add_property(#0, "one", create(#-1, 1), {$owner, ""}); 108 | add_property($one, "two", create(#-1, 1), {$one.owner, ""}); 109 | $one.name = "One One One!"; 110 | $one.two.name = "Two Two Two!"; 111 | server_log(tostr("$one is ", `valid($one) ! E_PROPNF, E_TYPE' ? "valid" | "invalid")); 112 | server_log(tostr("$one.two is ", `valid($one.two) ! E_PROPNF, E_TYPE' ? "valid" | "invalid")); 113 | recycle($one.two); 114 | suspend(0); 115 | shutdown(); 116 | elseif (`valid($one) ! E_TYPE') 117 | server_log(tostr("$one is ", `valid($one) ! E_PROPNF, E_TYPE' ? "valid" | "invalid")); 118 | server_log(tostr("$one.two is ", `valid($one.two) ! E_PROPNF, E_TYPE' ? "valid" | "invalid")); 119 | "the following two lines trigger a bug in the garbage collector"; 120 | a = $one; 121 | b = $one; 122 | $one = 0; 123 | run_gc(); 124 | suspend(0); 125 | shutdown(); 126 | else 127 | server_log(tostr("$one is ", `valid($one) ! E_PROPNF, E_TYPE' ? "valid" | "invalid")); 128 | server_log(tostr("$one.two is ", `valid($one.two) ! E_PROPNF, E_TYPE' ? "valid" | "invalid")); 129 | delete_property(#0, "one"); 130 | run_gc(); 131 | suspend(0); 132 | shutdown(); 133 | endif 134 | . 135 | -------------------------------------------------------------------------------- /src/keywords.gperf: -------------------------------------------------------------------------------- 1 | %{ /* -*- C -*- */ 2 | 3 | /****************************************************************************** 4 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 5 | Portions of this code were written by Stephen White, aka ghond. 6 | Use and copying of this software and preparation of derivative works based 7 | upon this software are permitted. Any distribution of this software or 8 | derivative works must comply with all applicable United States export 9 | control laws. This software is made available AS IS, and Xerox Corporation 10 | makes no warranty about the software, its performance or its conformity to 11 | any specification. Any person obtaining a copy of this software is requested 12 | to send their name and post office or electronic mail address to: 13 | Pavel Curtis 14 | Xerox PARC 15 | 3333 Coyote Hill Rd. 16 | Palo Alto, CA 94304 17 | Pavel@Xerox.Com 18 | *****************************************************************************/ 19 | 20 | #include 21 | #include "config.h" 22 | #include "keywords.h" 23 | #include "tokens.h" 24 | #include "utils.h" 25 | 26 | %} 27 | struct keyword {}; /* bogus decl not copied into the output */ 28 | %% 29 | if, DBV_Prehistory, tIF 30 | else, DBV_Prehistory, tELSE 31 | elseif, DBV_Prehistory, tELSEIF 32 | endif, DBV_Prehistory, tENDIF 33 | for, DBV_Prehistory, tFOR 34 | in, DBV_Prehistory, tIN 35 | endfor, DBV_Prehistory, tENDFOR 36 | fork, DBV_Prehistory, tFORK 37 | endfork, DBV_Prehistory, tENDFORK 38 | return, DBV_Prehistory, tRETURN 39 | while, DBV_Prehistory, tWHILE 40 | endwhile, DBV_Prehistory, tENDWHILE 41 | try, DBV_Exceptions, tTRY 42 | except, DBV_Exceptions, tEXCEPT 43 | finally, DBV_Exceptions, tFINALLY 44 | endtry, DBV_Exceptions, tENDTRY 45 | ANY, DBV_Exceptions, tANY 46 | break, DBV_BreakCont, tBREAK 47 | continue, DBV_BreakCont, tCONTINUE 48 | E_NONE, DBV_Prehistory, tERROR, E_NONE 49 | E_TYPE, DBV_Prehistory, tERROR, E_TYPE 50 | E_DIV, DBV_Prehistory, tERROR, E_DIV 51 | E_PERM, DBV_Prehistory, tERROR, E_PERM 52 | E_PROPNF, DBV_Prehistory, tERROR, E_PROPNF 53 | E_VERBNF, DBV_Prehistory, tERROR, E_VERBNF 54 | E_VARNF, DBV_Prehistory, tERROR, E_VARNF 55 | E_INVIND, DBV_Prehistory, tERROR, E_INVIND 56 | E_RECMOVE, DBV_Prehistory, tERROR, E_RECMOVE 57 | E_MAXREC, DBV_Prehistory, tERROR, E_MAXREC 58 | E_RANGE, DBV_Prehistory, tERROR, E_RANGE 59 | E_ARGS, DBV_Prehistory, tERROR, E_ARGS 60 | E_NACC, DBV_Prehistory, tERROR, E_NACC 61 | E_INVARG, DBV_Prehistory, tERROR, E_INVARG 62 | E_QUOTA, DBV_Prehistory, tERROR, E_QUOTA 63 | E_FLOAT, DBV_Float, tERROR, E_FLOAT 64 | E_FILE, DBV_FileIO, tERROR, E_FILE 65 | E_EXEC, DBV_Exec, tERROR, E_EXEC 66 | E_INTRPT, DBV_Interrupt, tERROR, E_INTRPT 67 | %% 68 | 69 | const struct keyword * 70 | find_keyword(const char *word) 71 | { 72 | return Perfect_Hash::in_word_set(word, strlen(word)); 73 | } 74 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __YAJL_BUF_H__ 34 | #define __YAJL_BUF_H__ 35 | 36 | #include "yajl_alloc.h" 37 | #include "yajl_common.h" 38 | 39 | /* 40 | * Implementation/performance notes. If this were moved to a header 41 | * only implementation using #define's where possible we might be 42 | * able to sqeeze a little performance out of the guy by killing function 43 | * call overhead. YMMV. 44 | */ 45 | 46 | /** 47 | * yajl_buf is a buffer with exponential growth. the buffer ensures that 48 | * you are always null padded. 49 | */ 50 | typedef struct yajl_buf_t * yajl_buf; 51 | 52 | /* allocate a new buffer */ 53 | yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc); 54 | 55 | /* free the buffer */ 56 | void yajl_buf_free(yajl_buf buf); 57 | 58 | /* append a number of bytes to the buffer */ 59 | void yajl_buf_append(yajl_buf buf, const void * data, unsigned int len); 60 | 61 | /* empty the buffer */ 62 | void yajl_buf_clear(yajl_buf buf); 63 | 64 | /* get a pointer to the beginning of the buffer */ 65 | const unsigned char * yajl_buf_data(yajl_buf buf); 66 | 67 | /* get the length of the buffer */ 68 | unsigned int yajl_buf_len(yajl_buf buf); 69 | 70 | /* truncate the buffer */ 71 | void yajl_buf_truncate(yajl_buf buf, unsigned int len); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /test/tests/Suspended.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 4 ** 2 | 4 3 | 3 4 | 0 5 | 1 6 | 3 7 | #0 8 | System Object 9 | 10 | 16 11 | 3 12 | -1 13 | -1 14 | -1 15 | 1 16 | -1 17 | 2 18 | 2 19 | do_login_command 20 | 3 21 | 173 22 | -1 23 | server_started 24 | 3 25 | 172 26 | -1 27 | 0 28 | 0 29 | #1 30 | Root Class 31 | 32 | 16 33 | 3 34 | -1 35 | -1 36 | -1 37 | -1 38 | 0 39 | -1 40 | 0 41 | 0 42 | 0 43 | #2 44 | The First Room 45 | 46 | 0 47 | 3 48 | -1 49 | 3 50 | -1 51 | 1 52 | -1 53 | 3 54 | 1 55 | eval 56 | 3 57 | 88 58 | -2 59 | 0 60 | 0 61 | #3 62 | Wizard 63 | 64 | 7 65 | 3 66 | 2 67 | -1 68 | -1 69 | 1 70 | -1 71 | -1 72 | 0 73 | 0 74 | 0 75 | #0:0 76 | return #3; 77 | . 78 | #0:1 79 | server_log("This format version 4 database has a suspended task."); 80 | . 81 | #2:0 82 | answer = eval(("return " + argstr) + ";"); 83 | if (answer[1]) 84 | notify(player, tostr("=> ", toliteral(answer[2]))); 85 | else 86 | for line in (answer[2]) 87 | notify(player, line); 88 | endfor 89 | endif 90 | . 91 | 0 clocks 92 | 0 queued tasks 93 | 1 suspended tasks 94 | 2147483647 1900608168 0 95 | 0 96 | 1 -1 0 50 97 | language version 4 98 | answer = eval(("return " + argstr) + ";"); 99 | if (answer[1]) 100 | notify(player, tostr("=> ", toliteral(answer[2]))); 101 | else 102 | for line in (answer[2]) 103 | notify(player, line); 104 | endfor 105 | endif 106 | . 107 | 20 variables 108 | NUM 109 | 0 110 | 0 111 | OBJ 112 | 0 113 | 1 114 | STR 115 | 0 116 | 2 117 | LIST 118 | 0 119 | 4 120 | ERR 121 | 0 122 | 3 123 | player 124 | 1 125 | 3 126 | this 127 | 1 128 | 2 129 | caller 130 | 1 131 | 3 132 | verb 133 | 2 134 | eval 135 | args 136 | 4 137 | 1 138 | 2 139 | suspend() 140 | argstr 141 | 2 142 | suspend() 143 | dobj 144 | 1 145 | -3 146 | dobjstr 147 | 2 148 | suspend() 149 | prepstr 150 | 2 151 | 152 | iobj 153 | 1 154 | -1 155 | iobjstr 156 | 2 157 | 158 | INT 159 | 0 160 | 0 161 | FLOAT 162 | 0 163 | 9 164 | answer 165 | 6 166 | line 167 | 6 168 | 0 rt_stack slots in use 169 | 0 170 | -111 171 | 2 -7 -8 3 -9 3 2 -10 8 172 | No 173 | More 174 | Parse 175 | Infos 176 | eval 177 | eval 178 | 6 179 | 10 0 8 180 | language version 4 181 | return suspend(); 182 | . 183 | 18 variables 184 | NUM 185 | 0 186 | 0 187 | OBJ 188 | 0 189 | 1 190 | STR 191 | 0 192 | 2 193 | LIST 194 | 0 195 | 4 196 | ERR 197 | 0 198 | 3 199 | player 200 | 1 201 | 3 202 | this 203 | 1 204 | -1 205 | caller 206 | 1 207 | 2 208 | verb 209 | 2 210 | 211 | args 212 | 4 213 | 0 214 | argstr 215 | 2 216 | 217 | dobj 218 | 1 219 | -1 220 | dobjstr 221 | 2 222 | 223 | prepstr 224 | 2 225 | 226 | iobj 227 | 1 228 | -1 229 | iobjstr 230 | 2 231 | 232 | INT 233 | 0 234 | 0 235 | FLOAT 236 | 0 237 | 9 238 | 0 rt_stack slots in use 239 | 0 240 | -111 241 | -1 -7 -8 3 -9 3 -1 -10 1 242 | No 243 | More 244 | Parse 245 | Infos 246 | 247 | Input to EVAL 248 | 6 249 | 3 2 1 250 | eval 251 | 1 active connections with listeners 252 | 3 0 253 | -------------------------------------------------------------------------------- /src/net_mp_poll.cc: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | /* Multiplexing wait implementation using the System V poll() system call. */ 19 | 20 | #include 21 | #include 22 | 23 | #include "log.h" 24 | #include "net_mplex.h" 25 | #include "storage.h" 26 | 27 | typedef struct pollfd Port; 28 | 29 | static Port *ports = 0; 30 | static unsigned num_ports = 0; 31 | static unsigned max_fd; 32 | 33 | void 34 | mplex_clear(void) 35 | { 36 | int i; 37 | 38 | max_fd = 0; 39 | for (i = 0; i < num_ports; i++) { 40 | ports[i].fd = -1; 41 | ports[i].events = 0; 42 | } 43 | } 44 | 45 | static void 46 | add_common(int fd, unsigned dir) 47 | { 48 | if (fd >= num_ports) { /* Grow ports array */ 49 | int new_num = (fd + 9) / 10 * 10 + 1; 50 | Port *new_ports = (Port *)mymalloc(new_num * sizeof(Port), M_NETWORK); 51 | int i; 52 | 53 | for (i = 0; i < num_ports; i++) 54 | new_ports[i] = ports[i]; 55 | 56 | if (ports != 0) 57 | myfree(ports, M_NETWORK); 58 | 59 | ports = new_ports; 60 | num_ports = new_num; 61 | } 62 | ports[fd].fd = fd; 63 | ports[fd].events |= dir; 64 | if (fd > max_fd) 65 | max_fd = fd; 66 | } 67 | 68 | void 69 | mplex_add_reader(int fd) 70 | { 71 | add_common(fd, POLLIN); 72 | } 73 | 74 | void 75 | mplex_add_writer(int fd) 76 | { 77 | add_common(fd, POLLOUT); 78 | } 79 | 80 | int 81 | mplex_wait(unsigned timeout) 82 | { 83 | int result = poll(ports, max_fd + 1, timeout / 1000); 84 | 85 | if (result < 0) { 86 | if (errno != EINTR) 87 | log_perror("Waiting for network I/O"); 88 | return 1; 89 | } else 90 | return (result == 0); 91 | } 92 | 93 | int 94 | mplex_is_readable(int fd) 95 | { 96 | return fd <= max_fd && (ports[fd].revents & (POLLIN | POLLHUP)) != 0; 97 | } 98 | 99 | int 100 | mplex_is_writable(int fd) 101 | { 102 | return fd <= max_fd && (ports[fd].revents & POLLOUT) != 0; 103 | } 104 | -------------------------------------------------------------------------------- /src/include/net_mplex.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | /* This describes the complete set of procedures that a multiplexing wait 19 | * implementation must provide. 20 | * 21 | * The `mplex' abstraction provides a way to wait until it is possible to 22 | * perform an I/O operation on any of a set of file descriptors without 23 | * blocking. Uses of the abstraction always have the following form: 24 | * 25 | * mplex_clear(); 26 | * { mplex_add_reader(fd) or mplex_add_writer(fd) }* 27 | * timed_out = mplex_wait(timeout); 28 | * { mplex_is_readable(fd) or mplex_is_writable(fd) }* 29 | * 30 | * The set of file descriptors maintained by the abstraction is referred to 31 | * below as the `wait set'. Each file descriptor in the wait set is marked 32 | * with the kind of I/O (i.e., reading, writing, or both) desired. 33 | */ 34 | 35 | #ifndef Net_MPlex_H 36 | #define Net_MPlex_H 1 37 | 38 | extern void mplex_clear(void); 39 | /* Reset the wait set to be empty. */ 40 | 41 | extern void mplex_add_reader(int fd); 42 | /* Add the given file descriptor to the wait 43 | * set, marked for reading. 44 | */ 45 | 46 | extern void mplex_add_writer(int fd); 47 | /* Add the given file descriptor to the wait 48 | * set, marked for writing. 49 | */ 50 | 51 | extern int mplex_wait(unsigned timeout); 52 | /* Wait until it is possible either to do the 53 | * appropriate kind of I/O on some descriptor 54 | * in the wait set or until `timeout' seconds 55 | * have elapsed. Return true iff the timeout 56 | * expired without any I/O becoming possible. 57 | */ 58 | 59 | extern int mplex_is_readable(int fd); 60 | /* Return true iff the most recent mplex_wait() 61 | * call terminated (in part) because reading 62 | * had become possible on the given descriptor. 63 | */ 64 | 65 | extern int mplex_is_writable(int fd); 66 | /* Return true iff the most recent mplex_wait() 67 | * call terminated (in part) because reading 68 | * had become possible on the given descriptor. 69 | */ 70 | 71 | #endif /* !Net_MPlex_H */ 72 | -------------------------------------------------------------------------------- /src/collection.cc: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "bf_register.h" 19 | #include "collection.h" 20 | #include "functions.h" 21 | #include "list.h" 22 | #include "map.h" 23 | #include "utils.h" 24 | 25 | struct ismember_data { 26 | int i; 27 | Var value; 28 | int case_matters; 29 | }; 30 | 31 | static int 32 | do_map_iteration(Var key, Var value, void *data, int first) 33 | { 34 | struct ismember_data *ismember_data = (struct ismember_data *)data; 35 | 36 | if (equality(value, ismember_data->value, ismember_data->case_matters)) { 37 | return ismember_data->i; 38 | } 39 | 40 | ismember_data->i++; 41 | 42 | return 0; 43 | } 44 | 45 | int 46 | ismember(Var lhs, Var rhs, int case_matters) 47 | { 48 | if (rhs.type == TYPE_LIST) { 49 | int i; 50 | 51 | for (i = 1; i <= rhs.v.list[0].v.num; i++) { 52 | if (equality(lhs, rhs.v.list[i], case_matters)) { 53 | return i; 54 | } 55 | } 56 | 57 | return 0; 58 | } else if (rhs.type == TYPE_MAP) { 59 | struct ismember_data ismember_data; 60 | 61 | ismember_data.i = 1; 62 | ismember_data.value = lhs; 63 | ismember_data.case_matters = case_matters; 64 | 65 | return mapforeach(rhs, do_map_iteration, &ismember_data); 66 | } else { 67 | return 0; 68 | } 69 | } 70 | 71 | /**** built in functions ****/ 72 | 73 | static package 74 | bf_is_member(Var arglist, Byte next, void *vdata, Objid progr) 75 | { 76 | Var r; 77 | Var rhs = arglist.v.list[2]; 78 | 79 | if (rhs.type != TYPE_LIST && rhs.type != TYPE_MAP) { 80 | free_var(arglist); 81 | return make_error_pack(E_INVARG); 82 | } 83 | 84 | bool case_matters = arglist.v.list[0].v.num < 3 || (arglist.v.list[0].v.num >= 3 && is_true(arglist.v.list[3])); 85 | 86 | r.type = TYPE_INT; 87 | r.v.num = ismember(arglist.v.list[1], rhs, case_matters); 88 | free_var(arglist); 89 | return make_var_pack(r); 90 | } 91 | 92 | void 93 | register_collection(void) 94 | { 95 | register_function("is_member", 2, 3, bf_is_member, TYPE_ANY, TYPE_ANY, TYPE_INT); 96 | } 97 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __YAJL_PARSER_H__ 34 | #define __YAJL_PARSER_H__ 35 | 36 | #include "yajl_bytestack.h" 37 | #include "yajl_buf.h" 38 | #include "yajl_parse.h" 39 | 40 | 41 | typedef enum { 42 | yajl_state_start = 0, 43 | yajl_state_parse_complete, 44 | yajl_state_parse_error, 45 | yajl_state_lexical_error, 46 | yajl_state_map_start, 47 | yajl_state_map_sep, 48 | yajl_state_map_need_val, 49 | yajl_state_map_got_val, 50 | yajl_state_map_need_key, 51 | yajl_state_array_start, 52 | yajl_state_array_got_val, 53 | yajl_state_array_need_val 54 | } yajl_state; 55 | 56 | struct yajl_handle_t { 57 | const yajl_callbacks * callbacks; 58 | void * ctx; 59 | yajl_lexer lexer; 60 | const char * parseError; 61 | /* the number of bytes consumed from the last client buffer, 62 | * in the case of an error this will be an error offset, in the 63 | * case of an error this can be used as the error offset */ 64 | unsigned int bytesConsumed; 65 | /* temporary storage for decoded strings */ 66 | yajl_buf decodeBuf; 67 | /* a stack of states. access with yajl_state_XXX routines */ 68 | yajl_bytestack stateStack; 69 | /* memory allocation routines */ 70 | yajl_alloc_funcs alloc; 71 | }; 72 | 73 | yajl_status 74 | yajl_do_parse(yajl_handle handle, const unsigned char * jsonText, 75 | unsigned int jsonTextLen); 76 | 77 | unsigned char * 78 | yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, 79 | unsigned int jsonTextLen, int verbose); 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /test/tests/test_huh.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TestHuh < Test::Unit::TestCase 4 | 5 | def teardown 6 | run_test_as('wizard') do 7 | evaluate('delete_property($server_options, "player_huh")') 8 | end 9 | end 10 | 11 | def test_that_huh_works_on_players_when_server_option_player_huh_is_true 12 | run_test_with_prefix_and_suffix_as('programmer') do 13 | add_verb(player, [player, 'xd', 'huh'], ['this', 'none', 'this']) 14 | set_verb_code(player, 'huh') do |vc| 15 | vc << %Q|notify(player, "Huh?");| 16 | end 17 | move(player, :nothing) 18 | assert_not_equal 'huh', command(%Q|zip|) 19 | end 20 | run_test_with_prefix_and_suffix_as('wizard') do 21 | evaluate('add_property($server_options, "player_huh", 1, {player, "r"})') 22 | add_verb(player, [player, 'xd', 'huh'], ['this', 'none', 'this']) 23 | set_verb_code(player, 'huh') do |vc| 24 | vc << %Q|notify(player, "Huh?");| 25 | end 26 | move(player, :nothing) 27 | assert_equal 'Huh?', command(%Q|zap|) 28 | end 29 | run_test_with_prefix_and_suffix_as('wizard') do 30 | evaluate('$server_options.player_huh = 0') 31 | add_verb(player, [player, 'xd', 'huh'], ['this', 'none', 'this']) 32 | set_verb_code(player, 'huh') do |vc| 33 | vc << %Q|notify(player, "Huh?");| 34 | end 35 | move(player, :nothing) 36 | assert_not_equal 'huh', command(%Q|zop|) 37 | end 38 | end 39 | 40 | def test_that_huh_does_not_work_on_locations_when_server_option_player_huh_is_true 41 | run_test_with_prefix_and_suffix_as('programmer') do 42 | o = create(:nothing) 43 | add_verb(o, [player, 'xd', 'accept'], ['this', 'none', 'this']) 44 | set_verb_code(o, 'accept') do |vc| 45 | vc << %Q|return 1;| 46 | end 47 | add_verb(o, [player, 'xd', 'huh'], ['this', 'none', 'this']) 48 | set_verb_code(o, 'huh') do |vc| 49 | vc << %Q|notify(player, "Huh?");| 50 | end 51 | move(player, o) 52 | assert_equal 'Huh?', command(%Q|zip|) 53 | end 54 | run_test_with_prefix_and_suffix_as('wizard') do 55 | evaluate('add_property($server_options, "player_huh", 1, {player, "r"})') 56 | o = create(:nothing) 57 | add_verb(o, [player, 'xd', 'accept'], ['this', 'none', 'this']) 58 | set_verb_code(o, 'accept') do |vc| 59 | vc << %Q|return 1;| 60 | end 61 | add_verb(o, [player, 'xd', 'huh'], ['this', 'none', 'this']) 62 | set_verb_code(o, 'huh') do |vc| 63 | vc << %Q|notify(player, "Huh?");| 64 | end 65 | move(player, o) 66 | assert_not_equal 'Huh?', command(%Q|zap|) 67 | end 68 | run_test_with_prefix_and_suffix_as('wizard') do 69 | evaluate('$server_options.player_huh = 0') 70 | o = create(:nothing) 71 | add_verb(o, [player, 'xd', 'accept'], ['this', 'none', 'this']) 72 | set_verb_code(o, 'accept') do |vc| 73 | vc << %Q|return 1;| 74 | end 75 | add_verb(o, [player, 'xd', 'huh'], ['this', 'none', 'this']) 76 | set_verb_code(o, 'huh') do |vc| 77 | vc << %Q|notify(player, "Huh?");| 78 | end 79 | move(player, o) 80 | assert_equal 'Huh?', command(%Q|zop|) 81 | end 82 | end 83 | 84 | end 85 | -------------------------------------------------------------------------------- /src/dependencies/xtrapbits.h: -------------------------------------------------------------------------------- 1 | /* lovingly lifted, with mods, from the X sources */ 2 | /***************************************************************************** 3 | Copyright 1987, 1988, 1989, 1990, 1994 by Digital Equipment Corporation, 4 | Maynard, MA 5 | 6 | Permission to use, copy, modify, and distribute this software and its 7 | documentation for any purpose and without fee is hereby granted, 8 | provided that the above copyright notice appear in all copies and 9 | that both that copyright notice and this permission notice appear in 10 | supporting documentation, and that the name of Digital not be used in 11 | advertising or publicity pertaining to distribution of the software 12 | without specific, written prior permission. 13 | 14 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 16 | NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 18 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 19 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE 20 | USE OR PERFORMANCE OF THIS SOFTWARE. 21 | *****************************************************************************/ 22 | /* 23 | * 24 | * CONTRIBUTORS: 25 | * 26 | * Dick Annicchiarico 27 | * Robert Chesler 28 | * Dan Coutu 29 | * Gene Durso 30 | * Marc Evans 31 | * Alan Jamison 32 | * Mark Henry 33 | * Ken Miller 34 | * 35 | */ 36 | #ifndef __XTRAPBITS__ 37 | #define __XTRAPBITS__ 38 | 39 | #define BITS_IN_BYTE 8L /* The number of bits in a byte */ 40 | 41 | #define bit_in_byte(bit) /* Returns the bit mask of a byte */ \ 42 | (1L << (((bit) % BITS_IN_BYTE))) 43 | 44 | #define bit_in_word(bit) /* Returns the bit mask of a word */ \ 45 | (1L << (((bit) % (BITS_IN_BYTE * 2L)))) 46 | 47 | #define bit_in_long(bit) /* Returns the bit mask of a long */ \ 48 | (1L << (((bit) % (BITS_IN_BYTE * 4L)))) 49 | 50 | #define byte_in_array(array,bit) /* Returns the byte offset to get to a bit */ \ 51 | (((unsigned char *)(array))[(bit) / BITS_IN_BYTE]) 52 | 53 | #define bit_is_true(array,bit) /* Test to see if a specific bit is true */ \ 54 | (byte_in_array(array,bit) & bit_in_byte(bit)) 55 | 56 | #define bit_is_false(array,bit) /* Test to see if a specific bit is false */ \ 57 | (!(bit_is_true(array,bit))) 58 | 59 | #define bit_true(array,bit) /* Set a specific bit to be true */ \ 60 | (byte_in_array(array,bit) |= bit_in_byte(bit)) 61 | 62 | #define bit_false(array,bit) /* Set a specific bit to be false */ \ 63 | (byte_in_array(array,bit) &= ~bit_in_byte(bit)) 64 | 65 | #define bit_toggle(array,bit) /* Toggle a specific bit */ \ 66 | (byte_in_array(array,bit) ^= bit_in_byte(bit)) 67 | 68 | #define bit_copy(dest,src,bit) /* Copy a specific bit */ \ 69 | bit_is_true((src),(bit)) ? bit_true((dest),(bit)) : bit_false((dest),(bit)) 70 | 71 | #define bit_value(array,bit) /* Return true or false depending on bit */ \ 72 | (bit_is_true((array),(bit)) ? 1 : 0) 73 | 74 | #define bit_set(array,bit,value) /* Set bit to given value in array */ \ 75 | (value) ? bit_true((array),(bit)) : bit_false((array),(bit)) 76 | 77 | #endif /* __XTRAPBITS__ */ 78 | -------------------------------------------------------------------------------- /test/Test.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 4 ** 2 | 8 3 | 5 4 | 0 5 | 2 6 | 3 7 | 4 8 | #0 9 | System Object 10 | 11 | 16 12 | 3 13 | -1 14 | -1 15 | -1 16 | 1 17 | -1 18 | 2 19 | 3 20 | do_login_command 21 | 3 22 | 173 23 | -1 24 | handle_uncaught_error 25 | 3 26 | 172 27 | -1 28 | handle_task_timeout 29 | 3 30 | 172 31 | -1 32 | 6 33 | nothing 34 | system 35 | object 36 | anonymous 37 | server_options 38 | waif 39 | 6 40 | 1 41 | -1 42 | 4 43 | 1 44 | 1 45 | 0 46 | 4 47 | 1 48 | 1 49 | 1 50 | 4 51 | 1 52 | 1 53 | 5 54 | 3 55 | 1 56 | 1 57 | 6 58 | 3 59 | 1 60 | 1 61 | 7 62 | 3 63 | 1 64 | #1 65 | Root Class 66 | 67 | 144 68 | 3 69 | -1 70 | -1 71 | -1 72 | -1 73 | 0 74 | -1 75 | 0 76 | 0 77 | 0 78 | #2 79 | The First Room 80 | 81 | 0 82 | 3 83 | -1 84 | 3 85 | -1 86 | 1 87 | -1 88 | 3 89 | 1 90 | eval 91 | 3 92 | 88 93 | -2 94 | 0 95 | 0 96 | #3 97 | Wizard 98 | 99 | 7 100 | 3 101 | 2 102 | -1 103 | 4 104 | 1 105 | -1 106 | 4 107 | 0 108 | 0 109 | 0 110 | #4 111 | Programmer 112 | 113 | 3 114 | 4 115 | 2 116 | -1 117 | -1 118 | 1 119 | -1 120 | 5 121 | 0 122 | 0 123 | 0 124 | #5 125 | Anonymous Class 126 | 127 | 256 128 | 3 129 | -1 130 | -1 131 | -1 132 | 1 133 | -1 134 | 6 135 | 0 136 | 0 137 | 0 138 | #6 139 | Server Options 140 | 141 | 0 142 | 3 143 | -1 144 | -1 145 | -1 146 | 1 147 | -1 148 | 7 149 | 0 150 | 0 151 | 0 152 | #7 153 | Waif Class 154 | 155 | 128 156 | 3 157 | -1 158 | -1 159 | -1 160 | 1 161 | -1 162 | -1 163 | 1 164 | new 165 | 3 166 | 173 167 | -1 168 | 0 169 | 0 170 | #0:0 171 | if ((args && (length(args) == 1)) && (args[1] == "shutdown")) 172 | reset_max_object(); 173 | while (max_object() > #7) 174 | ticks_left() < 2000 || seconds_left() < 2 && suspend(0); 175 | `recycle(max_object()) ! ANY'; 176 | reset_max_object(); 177 | endwhile 178 | boot_player(player); 179 | shutdown(); 180 | endif 181 | if ((args && (length(args) > 1)) && (args[1] == "connect")) 182 | if (args[2] == "wizard") 183 | o = create($nothing); 184 | o.owner = o; 185 | set_player_flag(o, 1); 186 | o.programmer = 1; 187 | o.wizard = 1; 188 | move(o, #2); 189 | switch_player(player, o); 190 | return; 191 | elseif (args[2] == "programmer") 192 | o = create($nothing); 193 | o.owner = o; 194 | set_player_flag(o, 1); 195 | o.programmer = 1; 196 | move(o, #2); 197 | switch_player(player, o); 198 | return; 199 | elseif (args[2] == "player") 200 | o = create($nothing); 201 | o.owner = o; 202 | set_player_flag(o, 1); 203 | move(o, #2); 204 | switch_player(player, o); 205 | return; 206 | endif 207 | endif 208 | . 209 | #0:1 210 | callers() && raise(E_PERM, "Server task"); 211 | {code, message, value, traceback, formatted} = args; 212 | for line in (formatted) 213 | server_log(line); 214 | endfor 215 | . 216 | #0:2 217 | callers() && raise(E_PERM, "Server task"); 218 | {resource, traceback, formatted} = args; 219 | for line in (formatted) 220 | server_log(line); 221 | endfor 222 | . 223 | #2:0 224 | set_task_perms(player); 225 | try 226 | try 227 | notify(player, "-=!-^-!=-"); 228 | notify(player, toliteral(eval(argstr))); 229 | except e (ANY) 230 | notify(player, toliteral({2, e})); 231 | endtry 232 | finally 233 | notify(player, "-=!-v-!=-"); 234 | endtry 235 | . 236 | #7:0 237 | set_task_perms(caller_perms()); 238 | player = caller_perms(); 239 | return new_waif(); 240 | . 241 | 0 clocks 242 | 0 queued tasks 243 | 0 suspended tasks 244 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_bytestack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * A header only implementation of a simple stack of bytes, used in YAJL 35 | * to maintain parse state. 36 | */ 37 | 38 | #ifndef __YAJL_BYTESTACK_H__ 39 | #define __YAJL_BYTESTACK_H__ 40 | 41 | #include "yajl_common.h" 42 | 43 | #define YAJL_BS_INC 128 44 | 45 | typedef struct yajl_bytestack_t 46 | { 47 | unsigned char * stack; 48 | unsigned int size; 49 | unsigned int used; 50 | yajl_alloc_funcs * yaf; 51 | } yajl_bytestack; 52 | 53 | /* initialize a bytestack */ 54 | #define yajl_bs_init(obs, _yaf) { \ 55 | (obs).stack = NULL; \ 56 | (obs).size = 0; \ 57 | (obs).used = 0; \ 58 | (obs).yaf = (_yaf); \ 59 | } \ 60 | 61 | 62 | /* initialize a bytestack */ 63 | #define yajl_bs_free(obs) \ 64 | if ((obs).stack) (obs).yaf->free((obs).yaf->ctx, (obs).stack); 65 | 66 | #define yajl_bs_current(obs) \ 67 | (assert((obs).used > 0), (obs).stack[(obs).used - 1]) 68 | 69 | #define yajl_bs_push(obs, byte) { \ 70 | if (((obs).size - (obs).used) == 0) { \ 71 | (obs).size += YAJL_BS_INC; \ 72 | (obs).stack = (obs).yaf->realloc((obs).yaf->ctx,\ 73 | (void *) (obs).stack, (obs).size);\ 74 | } \ 75 | (obs).stack[((obs).used)++] = (byte); \ 76 | } 77 | 78 | /* removes the top item of the stack, returns nothing */ 79 | #define yajl_bs_pop(obs) { ((obs).used)--; } 80 | 81 | #define yajl_bs_set(obs, byte) \ 82 | (obs).stack[((obs).used) - 1] = (byte); 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/include/map.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2010 Todd Sundsted. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY TODD SUNDSTED ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL TODD SUNDSTED OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 20 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are 26 | those of the authors and should not be interpreted as representing official 27 | policies, either expressed or implied, of Todd Sundsted. 28 | *****************************************************************************/ 29 | 30 | #include "structures.h" 31 | 32 | extern Var new_map(void); 33 | extern void destroy_map(Var map); 34 | extern Var map_dup(Var map); 35 | 36 | extern Var mapinsert(Var map, Var key, Var value); 37 | extern const rbnode *maplookup(Var map, Var key, Var *value, int case_matters); 38 | extern const rbnode *mapstrlookup(Var map, const char *key, Var *value, int case_matters); 39 | extern int mapseek(Var map, Var key, Var *iter, int case_matters); 40 | extern int mapequal(Var lhs, Var rhs, int case_matters); 41 | extern Num maplength(Var map); 42 | extern int mapempty(Var map); 43 | 44 | extern int map_sizeof(rbtree *tree); 45 | 46 | extern int mapfirst(Var map, var_pair *pair); 47 | extern int maplast(Var map, var_pair *pair); 48 | 49 | extern Var new_iter(Var map); 50 | extern void destroy_iter(Var iter); 51 | extern Var iter_dup(Var iter); 52 | 53 | extern int iterget(Var iter, var_pair *pair); 54 | extern void iternext(Var iter); 55 | 56 | extern Var maprange(Var map, rbtrav *from, rbtrav *to); 57 | extern enum error maprangeset(Var map, rbtrav *from, rbtrav *to, Var value, Var *_new); 58 | 59 | typedef int (*mapfunc) (Var key, Var value, void *data, int first); 60 | extern int mapforeach(Var map, mapfunc func, void *data); 61 | 62 | /* You're never going to need to use this! 63 | * Clears a node in place by setting the associated value type to 64 | * `E_NONE'. This _destructively_ updates the associated tree. The 65 | * method is used in `execute.c' to clear a node's value in a map when 66 | * the vm knows that it will eventually replace that value. This 67 | * removes a `var_ref' and eventual `map_dup' when the vm can 68 | * guarantee that a nested map is not shared. 69 | */ 70 | extern void clear_node_value(const rbnode *node); 71 | -------------------------------------------------------------------------------- /src/include/utils.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Utils_h 19 | #define Utils_h 1 20 | 21 | #include 22 | 23 | #include "config.h" 24 | #include "execute.h" 25 | #include "streams.h" 26 | 27 | #undef MAX 28 | #undef MIN 29 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) 30 | #define MIN(A, B) ((A) < (B) ? (A) : (B)) 31 | 32 | #define Arraysize(x) (sizeof(x) / sizeof(*x)) 33 | 34 | extern int verbcasecmp(const char *verb, const char *word); 35 | 36 | extern unsigned str_hash(const char *); 37 | 38 | extern void complex_free_var(Var); 39 | extern Var complex_var_ref(Var); 40 | extern Var complex_var_dup(Var); 41 | extern int var_refcount(Var); 42 | 43 | extern void aux_free(Var); 44 | 45 | static inline void 46 | free_var(Var v) 47 | { 48 | if (v.is_complex()) 49 | complex_free_var(v); 50 | } 51 | 52 | static inline Var 53 | var_ref(Var v) 54 | { 55 | if (v.is_complex()) 56 | return complex_var_ref(v); 57 | else 58 | return v; 59 | } 60 | 61 | static inline Var 62 | var_dup(Var v) 63 | { 64 | if (v.is_complex()) 65 | return complex_var_dup(v); 66 | else 67 | return v; 68 | } 69 | 70 | extern int is_true(Var v); 71 | extern int compare(Var lhs, Var rhs, int case_matters); 72 | extern int equality(Var lhs, Var rhs, int case_matters); 73 | 74 | extern void stream_add_strsub(Stream *, const char *, const char *, const char *, int); 75 | extern int strindex(const char *, int, const char *, int, int); 76 | extern int strrindex(const char *, int, const char *, int, int); 77 | 78 | extern const char *strtr(const char *, int, const char *, int, const char *, int, int); 79 | 80 | extern Var get_system_property(const char *); 81 | extern Objid get_system_object(const char *); 82 | 83 | extern int value_bytes(Var); 84 | 85 | extern void stream_add_raw_bytes_to_clean(Stream *, const char *buffer, int buflen); 86 | extern const char *raw_bytes_to_clean(const char *buffer, int buflen); 87 | extern const char *clean_to_raw_bytes(const char *binary, int *rawlen); 88 | 89 | extern void stream_add_raw_bytes_to_binary(Stream *, const char *buffer, int buflen); 90 | extern const char *raw_bytes_to_binary(const char *buffer, int buflen); 91 | extern const char *binary_to_raw_bytes(const char *binary, int *rawlen); 92 | 93 | extern Var anonymizing_var_ref(Var v, Objid progr); 94 | /* To be used in places where you 95 | * need to copy (via `var_ref()') a 96 | * value and also need to ensure that 97 | * _if_ it's an anonymous object it 98 | * remains anonymous for 99 | * non-wizards/owners. 100 | */ 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /src/program.cc: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #include "ast.h" 19 | #include "list.h" 20 | #include "parser.h" 21 | #include "program.h" 22 | #include "server.h" 23 | #include "storage.h" 24 | #include "structures.h" 25 | #include "utils.h" 26 | 27 | Program * 28 | new_program(void) 29 | { 30 | Program *p = (Program *) mymalloc(sizeof(Program), M_PROGRAM); 31 | 32 | p->ref_count = 1; 33 | p->first_lineno = 1; 34 | p->cached_lineno = 1; 35 | p->cached_lineno_pc = 0; 36 | p->cached_lineno_vec = MAIN_VECTOR; 37 | return p; 38 | } 39 | 40 | Program * 41 | null_program(void) 42 | { 43 | static Program *p = nullptr; 44 | Var code, errors; 45 | 46 | if (!p) { 47 | code = new_list(0); 48 | p = parse_list_as_program(code, &errors); 49 | if (!p) 50 | panic_moo("Can't create the null program!"); 51 | free_var(code); 52 | free_var(errors); 53 | } 54 | return p; 55 | } 56 | 57 | Program * 58 | program_ref(Program * p) 59 | { 60 | p->ref_count++; 61 | 62 | return p; 63 | } 64 | 65 | int 66 | program_bytes(Program * p) 67 | { 68 | unsigned int i, count; 69 | 70 | count = sizeof(Program); 71 | count += p->main_vector.size; 72 | 73 | for (i = 0; i < p->num_literals; i++) 74 | count += value_bytes(p->literals[i]); 75 | 76 | count += sizeof(Bytecodes) * p->fork_vectors_size; 77 | for (i = 0; i < p->fork_vectors_size; i++) 78 | count += p->fork_vectors[i].size; 79 | 80 | count += sizeof(const char *) * p->num_var_names; 81 | for (i = 0; i < p->num_var_names; i++) 82 | count += memo_strlen(p->var_names[i]) + 1; 83 | 84 | return count; 85 | } 86 | 87 | void 88 | free_program(Program * p) 89 | { 90 | unsigned i; 91 | 92 | p->ref_count--; 93 | if (p->ref_count == 0) { 94 | 95 | for (i = 0; i < p->num_literals; i++) 96 | /* can't be a list--strings and floats need to be freed, though. */ 97 | free_var(p->literals[i]); 98 | if (p->literals) 99 | myfree(p->literals, M_LIT_LIST); 100 | 101 | for (i = 0; i < p->fork_vectors_size; i++) 102 | myfree(p->fork_vectors[i].vector, M_BYTECODES); 103 | if (p->fork_vectors_size) 104 | myfree(p->fork_vectors, M_FORK_VECTORS); 105 | 106 | for (i = 0; i < p->num_var_names; i++) 107 | free_str(p->var_names[i]); 108 | myfree(p->var_names, M_NAMES); 109 | 110 | myfree(p->main_vector.vector, M_BYTECODES); 111 | 112 | myfree(p, M_PROGRAM); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/dependencies/crypt/README: -------------------------------------------------------------------------------- 1 | This is an implementation of a password hashing method, provided via the 2 | crypt(3) and a reentrant interface. It is fully compatible with 3 | OpenBSD's bcrypt.c for prefix "$2b$", originally by Niels Provos and 4 | David Mazieres. (Please refer to the included crypt(3) man page for 5 | information on minor compatibility issues for other bcrypt prefixes.) 6 | 7 | I've placed this code in the public domain, with fallback to a 8 | permissive license. Please see the comment in crypt_blowfish.c for 9 | more information. 10 | 11 | You can use the provided routines in your own packages, or link them 12 | into a C library. I've provided hooks for linking into GNU libc, but 13 | it shouldn't be too hard to get this into another C library. Note 14 | that simply adding this code into your libc is probably not enough to 15 | make your system use the new password hashing algorithm. Changes to 16 | passwd(1), PAM modules, or whatever else your system uses will likely 17 | be needed as well. These are not a part of this package, but see 18 | LINKS for a pointer to our tcb suite. 19 | 20 | Instructions on using the routines in one of the two common ways are 21 | given below. It is recommended that you test the routines on your 22 | system before you start. Type "make check" or "make check_threads" 23 | (if you have the POSIX threads library), then "make clean". 24 | 25 | 26 | 1. Using the routines in your programs. 27 | 28 | The available interfaces are in ow-crypt.h, and this is the file you 29 | should include. You won't need crypt.h. When linking, add all of the 30 | C files and x86.S (you can compile and link it even on a non-x86, it 31 | will produce no code in this case). 32 | 33 | 34 | 2. Building the routines into GNU C library. 35 | 36 | For versions 2.13 and 2.14 (and likely other nearby ones), extract the 37 | library sources as usual. Apply the patch for glibc 2.14 provided in 38 | this package. Enter crypt/ and rename crypt.h to gnu-crypt.h within 39 | that directory. Copy the C sources, header, and assembly (x86.S) files 40 | from this package in there as well (but be sure you don't overwrite the 41 | Makefile). Configure, build, and install the library as usual. 42 | 43 | For versions 2.2 to 2.3.6 (and likely also for some newer ones), 44 | extract the library sources and maybe its optional add-ons as usual. 45 | Apply the patch for glibc 2.3.6 provided in this package. Enter 46 | crypt/ and rename crypt.h to gnu-crypt.h within that directory. Copy 47 | the C sources, header, and assembly (x86.S) files from this package in 48 | there as well (but be sure you don't overwrite the Makefile). 49 | Configure, build, and install the library as usual. 50 | 51 | For versions 2.1 to 2.1.3, extract the library sources and the crypt 52 | and linuxthreads add-ons as usual. Apply the patch for glibc 2.1.3 53 | provided in this package. Enter crypt/sysdeps/unix/, and rename 54 | crypt.h to gnu-crypt.h within that directory. Copy C sources, header, 55 | and assembly (x86.S) files from this package in there as well (but be 56 | sure you don't overwrite the Makefile). Configure, build, and install 57 | the library as usual. 58 | 59 | Programs that want to use the provided interfaces will need to include 60 | crypt.h (but not ow-crypt.h directly). By default, prototypes for the 61 | new routines aren't defined (but the extra functionality of crypt(3) 62 | is indeed available). You need to define _OW_SOURCE to obtain the new 63 | routines as well. 64 | 65 | -- 66 | Solar Designer 67 | 68 | $Owl: Owl/packages/glibc/crypt_blowfish/README,v 1.10 2014/07/07 15:19:04 solar Exp $ 69 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __YAJL_COMMON_H__ 34 | #define __YAJL_COMMON_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #define YAJL_MAX_DEPTH 128 41 | 42 | /* msft dll export gunk. To build a DLL on windows, you 43 | * must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared 44 | * DLL, you must define YAJL_SHARED and WIN32 */ 45 | #if defined(WIN32) && defined(YAJL_SHARED) 46 | # ifdef YAJL_BUILD 47 | # define YAJL_API __declspec(dllexport) 48 | # else 49 | # define YAJL_API __declspec(dllimport) 50 | # endif 51 | #else 52 | # if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 53 | # define YAJL_API __attribute__ ((visibility("default"))) 54 | # else 55 | # define YAJL_API 56 | # endif 57 | #endif 58 | 59 | /** pointer to a malloc function, supporting client overriding memory 60 | * allocation routines */ 61 | typedef void * (*yajl_malloc_func)(void *ctx, unsigned int sz); 62 | 63 | /** pointer to a free function, supporting client overriding memory 64 | * allocation routines */ 65 | typedef void (*yajl_free_func)(void *ctx, void * ptr); 66 | 67 | /** pointer to a realloc function which can resize an allocation. */ 68 | typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, unsigned int sz); 69 | 70 | /** A structure which can be passed to yajl_*_alloc routines to allow the 71 | * client to specify memory allocation functions to be used. */ 72 | typedef struct 73 | { 74 | /** pointer to a function that can allocate uninitialized memory */ 75 | yajl_malloc_func malloc; 76 | /** pointer to a function that can resize memory allocations */ 77 | yajl_realloc_func realloc; 78 | /** pointer to a function that can free memory allocated using 79 | * reallocFunction or mallocFunction */ 80 | yajl_free_func free; 81 | /** a context pointer that will be passed to above allocation routines */ 82 | void * ctx; 83 | } yajl_alloc_funcs; 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/include/functions.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Functions_h 19 | #define Functions_h 1 20 | 21 | #include 22 | 23 | #include "config.h" 24 | #include "execute.h" 25 | #include "program.h" 26 | #include "structures.h" 27 | 28 | typedef struct { 29 | enum { 30 | BI_RETURN, /* Normal function return */ 31 | BI_RAISE, /* Raising an error */ 32 | BI_CALL, /* Making a nested verb call */ 33 | BI_SUSPEND, /* Suspending the current task */ 34 | BI_KILL /* Killing the current task */ 35 | } kind; 36 | union { 37 | Var ret; 38 | struct { 39 | Var code; 40 | const char *msg; 41 | Var value; 42 | } raise; 43 | struct { 44 | Byte pc; 45 | void *data; 46 | } call; 47 | struct { 48 | enum error (*proc) (vm, void *); 49 | void *data; 50 | } susp; 51 | } u; 52 | } package; 53 | 54 | void register_bi_functions(void); 55 | 56 | enum abort_reason { 57 | ABORT_KILL = -1, /* kill_task(task_id()) */ 58 | ABORT_SECONDS = 0, /* out of seconds */ 59 | ABORT_TICKS = 1 /* out of ticks */ 60 | }; 61 | 62 | package make_abort_pack(enum abort_reason reason); 63 | package make_error_pack(enum error err); 64 | package make_raise_pack(enum error err, const char *msg, Var value); 65 | package make_x_not_found_pack(enum error err, const char *msg, Objid the_object); 66 | package make_var_pack(Var v); 67 | package no_var_pack(void); 68 | package make_call_pack(Byte pc, void *data); 69 | package tail_call_pack(void); 70 | package make_suspend_pack(enum error (*)(vm, void *), void *); 71 | package make_int_pack(Num v); 72 | package make_float_pack(double v); 73 | 74 | typedef package(*bf_type) (Var, Byte, void *, Objid); 75 | typedef void (*bf_write_type) (void *vdata); 76 | typedef void *(*bf_read_type) (void); 77 | 78 | #define MAX_FUNC 256 79 | #define FUNC_NOT_FOUND MAX_FUNC 80 | /* valid function numbers are 0 - 255, or a total of 256 of them. 81 | function number 256 is reserved for func_not_found signal. 82 | hence valid function numbers will fit in one byte but the 83 | func_not_found signal will not */ 84 | 85 | extern const char *name_func_by_num(unsigned); 86 | extern unsigned number_func_by_name(const char *); 87 | 88 | extern unsigned register_function(const char *, int, int, bf_type,...); 89 | extern unsigned register_function_with_read_write(const char *, int, int, 90 | bf_type, bf_read_type, 91 | bf_write_type,...); 92 | 93 | extern package call_bi_func(unsigned, Var, Byte, Objid, void *); 94 | /* will free or use Var arglist */ 95 | 96 | extern void write_bi_func_data(void *vdata, Byte f_id); 97 | extern int read_bi_func_data(Byte f_id, void **bi_func_state, 98 | Byte * bi_func_pc); 99 | extern Byte *pc_for_bi_func_data(void); 100 | 101 | extern void load_server_options(void); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /src/include/version.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef Version_H 19 | #define Version_H 1 20 | 21 | #include "config.h" 22 | #include "structures.h" 23 | 24 | /***************************************************************** 25 | * Server Executable Version 26 | */ 27 | 28 | extern const char *server_version; 29 | extern Var server_version_full(Var); 30 | 31 | 32 | /***************************************************************** 33 | * Language / Database-Format Version 34 | */ 35 | 36 | /* The following list must never be reordered, only appended to. There is one 37 | * element per version of the database format (including incompatible changes 38 | * to the language, such as the addition of new keywords). The integer value 39 | * of each element is used in the DB header on disk to identify the format 40 | * version in use in that file. 41 | */ 42 | typedef enum { 43 | DBV_Prehistory, /* Before format versions */ 44 | DBV_Exceptions, /* Addition of the `try', `except', `finally', 45 | * and `endtry' keywords. 46 | */ 47 | DBV_BreakCont, /* Addition of the `break' and `continue' 48 | * keywords. 49 | */ 50 | DBV_Float, /* Addition of `FLOAT' and `INT' variables and 51 | * the `E_FLOAT' keyword, along with version 52 | * numbers on each frame of a suspended task. 53 | */ 54 | DBV_BFBugFixed, /* Bug in built-in function overrides fixed by 55 | * making it use tail-calling. This DB_Version 56 | * change exists solely to turn off special 57 | * bug handling in read_bi_func_data(). 58 | */ 59 | DBV_NextGen, /* Introduced the next-generation database 60 | * format which fixes the data locality 61 | * problems in the v4 format. 62 | */ 63 | DBV_TaskLocal, /* Addition of task local value. 64 | */ 65 | DBV_Map, /* Addition of `MAP' variables 66 | */ 67 | DBV_FileIO, /* Includes addition of the 'E_FILE' keyword. 68 | */ 69 | DBV_Exec, /* Includes addition of the 'E_EXEC' keyword. 70 | */ 71 | DBV_Interrupt, /* Includes addition of the 'E_INTRPT' keyword. 72 | */ 73 | DBV_This, /* Varification of `this'. 74 | */ 75 | DBV_Iter, /* Addition of map iterator 76 | */ 77 | DBV_Anon, /* Addition of anonymous objects 78 | */ 79 | DBV_Waif, /* Addition of waifs 80 | */ 81 | DBV_Last_Move, /* Addition of the 'last_move' built-in property 82 | */ 83 | DBV_Threaded, /* Store threading information 84 | */ 85 | DBV_Bool, /* Boolean type 86 | */ 87 | Num_DB_Versions /* Special: the current version is this - 1. */ 88 | } DB_Version; 89 | 90 | #define current_db_version ((DB_Version) (Num_DB_Versions - 1)) 91 | 92 | extern int check_db_version(DB_Version); 93 | /* Returns true iff given version is within the 94 | * known range. 95 | */ 96 | 97 | #endif /* !Version_H */ 98 | -------------------------------------------------------------------------------- /src/dependencies/yajl/yajl_buf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, Lloyd Hilaiel. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. Neither the name of Lloyd Hilaiel nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include "yajl_buf.h" 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #define YAJL_BUF_INIT_SIZE 2048 40 | 41 | struct yajl_buf_t { 42 | unsigned int len; 43 | unsigned int used; 44 | unsigned char * data; 45 | yajl_alloc_funcs * alloc; 46 | }; 47 | 48 | static 49 | void yajl_buf_ensure_available(yajl_buf buf, unsigned int want) 50 | { 51 | unsigned int need; 52 | 53 | assert(buf != NULL); 54 | 55 | /* first call */ 56 | if (buf->data == NULL) { 57 | buf->len = YAJL_BUF_INIT_SIZE; 58 | buf->data = (unsigned char *) YA_MALLOC(buf->alloc, buf->len); 59 | buf->data[0] = 0; 60 | } 61 | 62 | need = buf->len; 63 | 64 | while (want >= (need - buf->used)) need <<= 1; 65 | 66 | if (need != buf->len) { 67 | buf->data = (unsigned char *) YA_REALLOC(buf->alloc, buf->data, need); 68 | buf->len = need; 69 | } 70 | } 71 | 72 | yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc) 73 | { 74 | yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t)); 75 | memset((void *) b, 0, sizeof(struct yajl_buf_t)); 76 | b->alloc = alloc; 77 | return b; 78 | } 79 | 80 | void yajl_buf_free(yajl_buf buf) 81 | { 82 | assert(buf != NULL); 83 | if (buf->data) YA_FREE(buf->alloc, buf->data); 84 | YA_FREE(buf->alloc, buf); 85 | } 86 | 87 | void yajl_buf_append(yajl_buf buf, const void * data, unsigned int len) 88 | { 89 | yajl_buf_ensure_available(buf, len); 90 | if (len > 0) { 91 | assert(data != NULL); 92 | memcpy(buf->data + buf->used, data, len); 93 | buf->used += len; 94 | buf->data[buf->used] = 0; 95 | } 96 | } 97 | 98 | void yajl_buf_clear(yajl_buf buf) 99 | { 100 | buf->used = 0; 101 | if (buf->data) buf->data[buf->used] = 0; 102 | } 103 | 104 | const unsigned char * yajl_buf_data(yajl_buf buf) 105 | { 106 | return buf->data; 107 | } 108 | 109 | unsigned int yajl_buf_len(yajl_buf buf) 110 | { 111 | return buf->used; 112 | } 113 | 114 | void 115 | yajl_buf_truncate(yajl_buf buf, unsigned int len) 116 | { 117 | assert(len <= buf->used); 118 | buf->used = len; 119 | } 120 | -------------------------------------------------------------------------------- /src/include/list.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 | Portions of this code were written by Stephen White, aka ghond. 4 | Use and copying of this software and preparation of derivative works based 5 | upon this software are permitted. Any distribution of this software or 6 | derivative works must comply with all applicable United States export 7 | control laws. This software is made available AS IS, and Xerox Corporation 8 | makes no warranty about the software, its performance or its conformity to 9 | any specification. Any person obtaining a copy of this software is requested 10 | to send their name and post office or electronic mail address to: 11 | Pavel Curtis 12 | Xerox PARC 13 | 3333 Coyote Hill Rd. 14 | Palo Alto, CA 94304 15 | Pavel@Xerox.Com 16 | *****************************************************************************/ 17 | 18 | #ifndef EXT_LIST_H 19 | #define EXT_LIST_H 1 20 | 21 | #include "structures.h" 22 | #include "streams.h" 23 | 24 | extern Var new_list(int size); 25 | extern void destroy_list(Var list); 26 | extern Var list_dup(Var list); 27 | 28 | extern Var listappend(Var list, Var value); 29 | extern Var listinsert(Var list, Var value, int pos); 30 | extern Var listdelete(Var list, int pos); 31 | extern Var listset(Var list, Var value, int pos); 32 | extern Var listrangeset(Var list, int from, int to, Var value); 33 | extern Var listconcat(Var first, Var second); 34 | extern Var setadd(Var list, Var value); 35 | extern Var setremove(Var list, Var value); 36 | extern Var sublist(Var list, int lower, int upper); 37 | extern int listequal(Var lhs, Var rhs, int case_matters); 38 | 39 | extern int list_sizeof(Var *list); 40 | 41 | typedef int (*listfunc) (Var value, void *data, int first); 42 | extern int listforeach(Var list, listfunc func, void *data); 43 | 44 | extern Var strrangeset(Var list, int from, int to, Var value); 45 | extern Var substr(Var str, int lower, int upper); 46 | extern Var strget(Var str, int i); 47 | 48 | extern const char *value2str(Var); 49 | extern void unparse_value(Stream *, Var); 50 | 51 | extern Var emptylist; /* Bandaid: See list.cc */ 52 | 53 | /* 54 | * Returns the length of the given list `l'. Does *not* check to 55 | * ensure `l' is, in fact, a list. 56 | */ 57 | static inline Num 58 | listlength(Var l) 59 | { 60 | return l.v.list[0].v.num; 61 | } 62 | 63 | /* 64 | * Wraps `v' in a list if it is not already a list. Consumes `v', so 65 | * you may want to var_ref/var_dup `v'. Currently, this function is 66 | * called by functions that operate on an object's parents, which can 67 | * be either an object reference (TYPE_OBJ) or a list of object 68 | * references (TYPE_LIST). 69 | */ 70 | static inline Var 71 | enlist_var(Var v) 72 | { 73 | if (TYPE_LIST == v.type) 74 | return v; 75 | 76 | Var r = new_list(1); 77 | r.v.list[1] = v; 78 | return r; 79 | } 80 | 81 | /* 82 | * Iterate over the values in the list `lst'. Sets `val' to each 83 | * value, in turn. `itr' and `cnt' must be int variables. In the 84 | * body of the statement, they hold the current index and total count, 85 | * respectively. Use the macro as follows (assuming you already have 86 | * a list in `items'): 87 | * Var item; 88 | * int i, c; 89 | * FOR_EACH(item, items, i, c) { 90 | * printf("%d of %d, item = %s\n", i, c, value_to_literal(item)); 91 | * } 92 | */ 93 | #define FOR_EACH(val, lst, idx, cnt) \ 94 | for (idx = 1, cnt = lst.v.list[0].v.num; \ 95 | idx <= cnt && (val = lst.v.list[idx], 1); \ 96 | idx++) 97 | 98 | /* 99 | * Pop the first value off `stck' and put it in `tp'. 100 | */ 101 | #define POP_TOP(tp, stck) \ 102 | tp = var_ref(stck.v.list[1]); \ 103 | stck = listdelete(stck, 1); 104 | #endif 105 | --------------------------------------------------------------------------------