├── .indent.pro ├── .cvsignore ├── Mindent ├── ac_include ├── moo_svf_mk0.mk ├── moo_svf_mk1.mk ├── moo_iconv.m4 ├── moo_cflags.m4 ├── moo_svf_mk.m4 ├── moo_git.m4 ├── moo_sys_ancient.m4 ├── moo_arguments.m4 └── moo_decl.m4 ├── db_tune.h ├── .gitignore ├── bf_register.c.in ├── Minimal.db ├── str_intern.h ├── db_tune.c ├── tokens.h ├── aclocal.m4 ├── my-ctype.h ├── verbs.h ├── code_gen.h ├── decompile.h ├── quota.h ├── ref_count.h ├── disassemble.h ├── net_mplex.c ├── my-wait.h ├── bf_register.h.in ├── my-stropts.h ├── net_proto.c ├── my-inet.h ├── pattern.h ├── my-poll.h ├── my-math.h ├── match.h ├── restart.sh ├── my-ioctl.h ├── getpagesize.h ├── keywords.h ├── timers.h ├── restart ├── my-stat.h ├── eval_env.h ├── AddingNewMOOTypes.txt ├── my-fcntl.h ├── name_lookup.h ├── eval_vm.h ├── log.h ├── list.h ├── my-tiuser.h ├── parser.h ├── utf-ctype.h ├── net_multi.h ├── random.h ├── network.c ├── my-sys-time.h ├── my-time.h ├── md5.h ├── my-stdarg.h ├── my-in.h ├── my-signal.h ├── unparse.h ├── quota.c ├── parse_cmd.h ├── sym_table.h ├── program.h ├── net_mp_selct.c ├── my-socket.h ├── keywords.gperf ├── README.Minimal ├── my-types.h ├── my-unistd.h ├── net_mp_poll.c ├── net_mplex.h ├── my-stdio.h ├── exceptions.c ├── client_bsd.c ├── my-stdlib.h ├── storage.h ├── version.h ├── extensions2_tutorial.ac ├── my-string.h ├── eval_env.c ├── program.c ├── numbers.h ├── utils.h ├── eval_vm.c └── net_tcp.c /.indent.pro: -------------------------------------------------------------------------------- 1 | -kr -ip4 -psl -nfca -lps 2 | -------------------------------------------------------------------------------- /.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | config.status 3 | config.h 4 | y.tab.h 5 | moo 6 | -------------------------------------------------------------------------------- /Mindent: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | indent -npro -kr -i4 -ts8 -sob -l80 -ss -ncs "$@" 3 | -------------------------------------------------------------------------------- /ac_include/moo_svf_mk0.mk: -------------------------------------------------------------------------------- 1 | version_make.h: Makefile 2 | cat /dev/null >"$@" 3 | -------------------------------------------------------------------------------- /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 | #ifndef DB_Tune_H 6 | #define DB_Tune_H 1 7 | 8 | #include "db_private.h" 9 | 10 | #ifdef VERB_CACHE 11 | 12 | extern void db_log_cache_stats(void); 13 | extern Var db_verb_cache_stats(void); 14 | 15 | #endif /* VERB_CACHE */ 16 | 17 | #endif /* !DB_Tune_H */ 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | autom4te.cache 3 | clean-keeps-keywords 4 | clean-keeps-moo 5 | clean-keeps-parser 6 | configure 7 | config.h 8 | options.h 9 | config.log 10 | config.status 11 | config.lastrun 12 | config.cache 13 | extensions2.ac 14 | keywords.c 15 | version_options.h 16 | version.lastck 17 | version_src.h 18 | version_make.h 19 | version_make.t 20 | y.tab.h 21 | *.o 22 | moo 23 | *.db 24 | \#*\# 25 | .\#* 26 | *.bak 27 | *.d 28 | -------------------------------------------------------------------------------- /bf_register.c.in: -------------------------------------------------------------------------------- 1 | /*************************** 2 | * bf_register.c.in 3 | */ 4 | 5 | #include "bf_register.h" 6 | 7 | #include "db.h" 8 | 9 | typedef void (*regfn) (void); 10 | 11 | static regfn all_regfns[] = { 12 | @@FUNCTIONS@@ 13 | }; 14 | 15 | void 16 | do_all_registrations(void) 17 | { 18 | regfn *rfn = all_regfns; 19 | regfn *rfn_after = rfn + sizeof(all_regfns) / sizeof(regfn); 20 | 21 | while (rfn < rfn_after) 22 | (*rfn++)(); 23 | 24 | db_init_hooks(); 25 | } 26 | -------------------------------------------------------------------------------- /Minimal.db: -------------------------------------------------------------------------------- 1 | ** LambdaMOO Database, Format Version 1 ** 2 | 4 3 | 1 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 | 1 19 | do_login_command 20 | 3 21 | 173 22 | -1 23 | 0 24 | 0 25 | #1 26 | Root Class 27 | 28 | 16 29 | 3 30 | -1 31 | -1 32 | -1 33 | -1 34 | 0 35 | -1 36 | 0 37 | 0 38 | 0 39 | #2 40 | The First Room 41 | 42 | 0 43 | 3 44 | -1 45 | 3 46 | -1 47 | 1 48 | -1 49 | 3 50 | 1 51 | eval 52 | 3 53 | 88 54 | -2 55 | 0 56 | 0 57 | #3 58 | Wizard 59 | 60 | 7 61 | 3 62 | 2 63 | -1 64 | -1 65 | 1 66 | -1 67 | -1 68 | 0 69 | 0 70 | 0 71 | #0:0 72 | return #3; 73 | . 74 | 0 clocks 75 | 0 queued tasks 76 | 0 suspended tasks 77 | -------------------------------------------------------------------------------- /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 1 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 /* !Str_Intern_H */ 26 | -------------------------------------------------------------------------------- /ac_include/moo_svf_mk1.mk: -------------------------------------------------------------------------------- 1 | empty:= 2 | space:= $(empty) $(empty) 3 | defbody=${firstword ${subst =,$(space),$(1)}},"${subst $(space),=,${wordlist 2,100000000,${subst =,$(space),$(1)}}}" 4 | _MAKEOV2:=${foreach X,\ 5 | ${subst \ ,_S, \ 6 | ${subst \\,_B, \ 7 | ${subst ",_D, \ 8 | ${subst ',_Q, \ 9 | ${subst $$$$,_C,\ 10 | ${subst _,_U,$(MAKEOVERRIDES)}}}}}},\ 11 | MDEF(${call defbody,$(X)})$\ 12 | }# keep emacs happy: '}"}}}} 13 | 14 | version_make.h: MFORCE 15 | @if test ! -e $(@:.h=.t) || ! { echo '$(_MAKEOV2)' | diff -q - $(@:.h=.t) >/dev/null 2>&1; }; then \ 16 | echo '$(_MAKEOV2)' > $(@:.h=.t); \ 17 | echo '#define VERSION_MAKEVARS(MDEF) \' >$@; \ 18 | sed \ 19 | -e 's/_S/ /g' \ 20 | -e 's/_B/\\\\/g' \ 21 | -e 's/_D/\\"/g' \ 22 | -e 's/_Q/'"'"'/g' \ 23 | -e 's/_C/\$$/g' \ 24 | -e 's/_U/_/g' \ 25 | < $(@:.h=.t) >> $@; \ 26 | fi 27 | 28 | MFORCE: 29 | -------------------------------------------------------------------------------- /ac_include/moo_iconv.m4: -------------------------------------------------------------------------------- 1 | # ************************************************* -*- autoconf -*- 2 | # MOO_ICONV_LIBS 3 | # sometimes -liconv is needed, sometimes not. 4 | # Adjusts LIBS as needed. 5 | # Sets moo_cv_iconv_lib to one of 'none needed', '-liconv', 'fail' 6 | # 7 | AC_DEFUN([MOO_ICONV_LIBS], 8 | [AC_REQUIRE([AC_C_BIGENDIAN]) 9 | AC_CACHE_CHECK([[for iconv needing additional flags]], 10 | [moo_cv_iconv_lib],[[ 11 | _moo_save_libs="$LIBS" 12 | moo_cv_iconv_lib= 13 | for _moo_lib in '' -liconv ; do 14 | LIBS="$_moo_lib $_moo_save_libs"] 15 | AC_LINK_IFELSE([AC_LANG_PROGRAM( 16 | [[@%:@include ]], [[(void)iconv_open("eat","me");]])],[[ 17 | moo_cv_iconv_lib="$_moo_lib" 18 | test "x$_moo_lib" = x && moo_cv_iconv_lib="none needed" 19 | break 20 | ]])[ 21 | done 22 | test "x$moo_cv_iconv_lib" = x && moo_cv_iconv_lib=fail 23 | LIBS="$_moo_save_libs" 24 | ]])[ 25 | test "x$moo_cv_iconv_lib" = "x-liconv" && 26 | LIBS="$moo_cv_iconv_lib $LIBS" 27 | ]])dnl 28 | -------------------------------------------------------------------------------- /db_tune.c: -------------------------------------------------------------------------------- 1 | /* This is just a stub for now; various db-layer-specific tuning functions 2 | * will eventually live here. 3 | */ 4 | 5 | 6 | #include "db_tune.h" 7 | #include "bf_register.h" 8 | 9 | #include "functions.h" 10 | #include "utils.h" 11 | 12 | #ifdef VERB_CACHE 13 | 14 | static package 15 | bf_verb_cache_stats(Var arglist, Byte next UNUSED_, void *vdata UNUSED_, Objid progr) 16 | { 17 | Var r; 18 | 19 | free_var(arglist); 20 | 21 | if (!is_wizard(progr)) { 22 | return make_error_pack(E_PERM); 23 | } 24 | r = db_verb_cache_stats(); 25 | 26 | return make_var_pack(r); 27 | } 28 | 29 | static package 30 | bf_log_cache_stats(Var arglist, Byte next UNUSED_, void *vdata UNUSED_, Objid progr) 31 | { 32 | free_var(arglist); 33 | 34 | if (!is_wizard(progr)) { 35 | return make_error_pack(E_PERM); 36 | } 37 | db_log_cache_stats(); 38 | 39 | return no_var_pack(); 40 | } 41 | 42 | #endif /* VERB_CACHE */ 43 | 44 | void 45 | register_db_tune(void) 46 | { 47 | #ifdef VERB_CACHE 48 | register_function("log_cache_stats", 0, 0, bf_log_cache_stats); 49 | register_function("verb_cache_stats", 0, 0, bf_verb_cache_stats); 50 | #endif /* VERB_CACHE */ 51 | } 52 | -------------------------------------------------------------------------------- /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 Tokens_H 19 | #define Tokens_H 1 20 | 21 | #include "ast.h" 22 | #include "structures.h" 23 | 24 | #include "y.tab.h" 25 | 26 | #endif /* !Tokens_H */ 27 | 28 | /* 29 | * $Log$ 30 | * Revision 2.0 1995/11/30 05:08:14 pavel 31 | * New baseline version, corresponding to release 1.8.0alpha1. 32 | * 33 | * Revision 1.1 1995/11/30 05:08:05 pavel 34 | * Initial revision 35 | */ 36 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | # generated automatically by aclocal 1.17 -*- Autoconf -*- 2 | 3 | # Copyright (C) 1996-2024 Free Software Foundation, Inc. 4 | 5 | # This file is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 | # PARTICULAR PURPOSE. 13 | 14 | m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) 15 | m4_include([ac_include/ax_gcc_func_attribute.m4]) 16 | m4_include([ac_include/ax_gcc_var_attribute.m4]) 17 | m4_include([ac_include/ax_lp.m4]) 18 | m4_include([ac_include/ax_xt.m4]) 19 | m4_include([ac_include/moo_arguments.m4]) 20 | m4_include([ac_include/moo_cflags.m4]) 21 | m4_include([ac_include/moo_decl.m4]) 22 | m4_include([ac_include/moo_git.m4]) 23 | m4_include([ac_include/moo_iconv.m4]) 24 | m4_include([ac_include/moo_net.m4]) 25 | m4_include([ac_include/moo_netopt.m4]) 26 | m4_include([ac_include/moo_options.m4]) 27 | m4_include([ac_include/moo_svf.m4]) 28 | m4_include([ac_include/moo_svf_mk.m4]) 29 | m4_include([ac_include/moo_sys_ancient.m4]) 30 | m4_include([ac_include/moo_xt.m4]) 31 | -------------------------------------------------------------------------------- /my-ctype.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1995, 1996 Xerox Corporation. All rights reserved. 3 | Use and copying of this software and preparation of derivative works based 4 | upon this software are permitted. Any distribution of this software or 5 | derivative works must comply with all applicable United States export 6 | control laws. This software is made available AS IS, and Xerox Corporation 7 | makes no warranty about the software, its performance or its conformity to 8 | any specification. Any person obtaining a copy of this software is requested 9 | to send their name and post office or electronic mail address to: 10 | Pavel Curtis 11 | Xerox PARC 12 | 3333 Coyote Hill Rd. 13 | Palo Alto, CA 94304 14 | Pavel@Xerox.Com 15 | *****************************************************************************/ 16 | 17 | #ifndef My_CType_H 18 | #define My_CType_H 1 19 | 20 | #include "config.h" 21 | 22 | #include 23 | 24 | #if NDECL_TOLOWER 25 | extern int tolower(int); 26 | extern int toupper(int); 27 | #endif 28 | 29 | #endif /* !My_CType_H */ 30 | 31 | /* 32 | * $Log$ 33 | * Revision 2.1 1996/02/08 06:05:23 pavel 34 | * Updated copyright notice for 1996. Release 1.8.0beta1. 35 | * 36 | * Revision 2.0 1995/11/30 05:08:25 pavel 37 | * New baseline version, corresponding to release 1.8.0alpha1. 38 | * 39 | * Revision 1.1 1995/11/30 05:08:19 pavel 40 | * Initial revision 41 | */ 42 | -------------------------------------------------------------------------------- /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 | #ifndef Verbs_H 19 | #define Verbs_H 1 20 | 21 | #include "db.h" 22 | #include "structures.h" 23 | 24 | extern enum error validate_verb_descriptor(Var desc); 25 | extern db_verb_handle find_described_verb(Objid oid, Var desc); 26 | 27 | #endif /* !Verbs_H */ 28 | 29 | /* 30 | * $Log$ 31 | * Revision 2.1 1996/02/08 06:07:21 pavel 32 | * Updated copyright notice for 1996. Release 1.8.0beta1. 33 | * 34 | * Revision 2.0 1995/12/28 00:16:05 pavel 35 | * Release 1.8.0alpha3. 36 | * 37 | * Revision 1.1 1995/12/28 00:14:25 pavel 38 | * Initial revision 39 | */ 40 | -------------------------------------------------------------------------------- /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 | #ifndef Code_Gen_H 19 | #define Code_Gen_H 1 20 | 21 | #include "ast.h" 22 | #include "program.h" 23 | #include "version.h" 24 | 25 | extern Program *generate_code(Stmt *, DB_Version); 26 | 27 | #endif /* !Code_Gen_H */ 28 | 29 | /* 30 | * $Log$ 31 | * Revision 2.2 1996/02/08 06:28:58 pavel 32 | * Made generate_code() version-dependent. Updated copyright notice for 1996. 33 | * Release 1.8.0beta1. 34 | * 35 | * Revision 2.1 1995/11/30 05:04:34 pavel 36 | * New baseline version, corresponding to release 1.8.0alpha1. 37 | * 38 | * Revision 2.0 1995/11/30 05:04:03 pavel 39 | * Initial RCS-controlled version. 40 | */ 41 | -------------------------------------------------------------------------------- /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 | #ifndef DeCompile_H 19 | #define DeCompile_H 1 20 | 21 | #include "ast.h" 22 | #include "program.h" 23 | 24 | extern Stmt *decompile_program(Program * program, int vector); 25 | extern unsigned find_line_number(Program * program, int vector, unsigned pc); 26 | 27 | #endif /* !DeCompile_H */ 28 | 29 | /* 30 | * $Log$ 31 | * Revision 2.1 1996/02/08 06:27:19 pavel 32 | * Updated copyright notice for 1996. Release 1.8.0beta1. 33 | * 34 | * Revision 2.0 1995/11/30 05:06:15 pavel 35 | * New baseline version, corresponding to release 1.8.0alpha1. 36 | * 37 | * Revision 1.1 1995/11/30 05:06:05 pavel 38 | * Initial revision 39 | */ 40 | -------------------------------------------------------------------------------- /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 | #ifndef Quota_H 19 | #define Quota_H 1 20 | 21 | #include "structures.h" 22 | 23 | extern int decr_quota(Objid player); 24 | extern void incr_quota(Objid player); 25 | 26 | #endif /* !Quota_H */ 27 | 28 | /* 29 | * $Log$ 30 | * Revision 2.1 1996/02/08 06:13:52 pavel 31 | * Updated copyright notice for 1996. Release 1.8.0beta1. 32 | * 33 | * Revision 2.0 1995/11/30 04:54:39 pavel 34 | * New baseline version, corresponding to release 1.8.0alpha1. 35 | * 36 | * Revision 1.2 1992/10/23 23:03:47 pavel 37 | * Added copyright notice. 38 | * 39 | * Revision 1.1 1992/07/20 23:23:12 pavel 40 | * Initial RCS-controlled version. 41 | */ 42 | -------------------------------------------------------------------------------- /ref_count.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 Ref_Count_H 19 | #define Ref_Count_H 1 20 | 21 | #include "config.h" 22 | 23 | #if 0 24 | extern void addref(const void *p); 25 | extern unsigned int delref(const void *p); 26 | #else 27 | #define addref(X) (++((int *)(X))[-1]) 28 | #define delref(X) (--((int *)(X))[-1]) 29 | #define refcount(X) (((int *)(X))[-1]) 30 | #endif 31 | 32 | #endif /* !Ref_Count_H */ 33 | 34 | /* 35 | * $Log$ 36 | * Revision 2.1 1996/02/08 06:13:28 pavel 37 | * Updated copyright notice for 1996. Release 1.8.0beta1. 38 | * 39 | * Revision 2.0 1995/11/30 05:07:57 pavel 40 | * New baseline version, corresponding to release 1.8.0alpha1. 41 | * 42 | */ 43 | -------------------------------------------------------------------------------- /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 | #ifndef Disassemble_H 19 | #define Disassemble_H 1 20 | 21 | #include "my-stdio.h" 22 | 23 | #include "program.h" 24 | 25 | extern void disassemble_to_file(FILE * fp, Program * program); 26 | extern void disassemble_to_stderr(Program * program); 27 | 28 | #endif /* !Disassemble_H */ 29 | 30 | /* 31 | * $Log$ 32 | * Revision 2.1 1996/02/08 06:27:06 pavel 33 | * Added disassemble_to_file(). Updated copyright notice for 1996. 34 | * Release 1.8.0beta1. 35 | * 36 | * Revision 2.0 1995/11/30 05:06:29 pavel 37 | * New baseline version, corresponding to release 1.8.0alpha1. 38 | * 39 | * Revision 1.1 1995/11/30 05:06:21 pavel 40 | * Initial revision 41 | */ 42 | -------------------------------------------------------------------------------- /net_mplex.c: -------------------------------------------------------------------------------- 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 "net_mplex.h" 19 | 20 | #include "options.h" 21 | 22 | # if MPLEX_STYLE == MP_SELECT 23 | # include "net_mp_selct.c" 24 | # endif 25 | 26 | # if MPLEX_STYLE == MP_POLL 27 | # include "net_mp_poll.c" 28 | # endif 29 | 30 | # if MPLEX_STYLE == MP_FAKE 31 | # include "net_mp_fake.c" 32 | # endif 33 | 34 | 35 | /* 36 | * $Log$ 37 | * Revision 2.1 1996/02/08 06:58:20 pavel 38 | * Updated copyright notice for 1996. Release 1.8.0beta1. 39 | * 40 | * Revision 2.0 1995/11/30 04:28:28 pavel 41 | * New baseline version, corresponding to release 1.8.0alpha1. 42 | * 43 | * Revision 1.1 1995/11/30 04:28:19 pavel 44 | * Initial revision 45 | */ 46 | -------------------------------------------------------------------------------- /my-wait.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 My_Wait_H 19 | #define My_Wait_H 1 20 | 21 | #include "config.h" 22 | 23 | #include 24 | 25 | #if NDECL_WAITPID 26 | #include "my-types.h" 27 | 28 | extern pid_t waitpid(pid_t, int *, int); 29 | #endif 30 | 31 | #endif /* !My_Wait_H */ 32 | 33 | /* 34 | * $Log$ 35 | * Revision 2.1 1996/02/08 05:58:27 pavel 36 | * Updated copyright notice for 1996. Release 1.8.0beta1. 37 | * 38 | * Revision 2.0 1995/11/30 05:00:04 pavel 39 | * New baseline version, corresponding to release 1.8.0alpha1. 40 | * 41 | * Revision 1.2 1992/10/23 23:03:47 pavel 42 | * Added copyright notice. 43 | * 44 | * Revision 1.1 1992/10/23 22:25:00 pavel 45 | * Initial RCS-controlled version. 46 | */ 47 | -------------------------------------------------------------------------------- /bf_register.h.in: -------------------------------------------------------------------------------- 1 | /*************************** 2 | * bf_register.h.in 3 | */ 4 | 5 | #ifndef BF_Register_H 6 | #define BF_Register_H 1 7 | 8 | #include "config.h" 9 | #include "options.h" 10 | 11 | /*--------------------------* 12 | | registration functions | 13 | *--------------------------*/ 14 | 15 | /* ... are functions that are called exactly once during server 16 | * initialization before the database is loaded. They are allowed and 17 | * expected to contain combinations of calls to 18 | * 19 | * register_function (functions.h) 20 | * register_db_load_hooks (db_file.h) 21 | * register_db_save_hooks (db_file.h) 22 | * register_task_queue (tasks.h) 23 | * 24 | * The build process scans all COMMON_CSRCS and ALL_XT_CSRCS files for 25 | * functions matching the following criteria, collecting them below: 26 | * 27 | * (1) have a name starting with 'register_' 28 | * (base name of the file being the typical suffix) 29 | * 30 | * (2) have void return type and (void) arguments, 31 | * 32 | * (3) appear directly (i.e., not via #includes) with no indentation 33 | * and return type on a separate line as per the usual style here 34 | * for function definitions, 35 | * 36 | * For header purposes, registration functions are treated as if they 37 | * were defined in bf_register.c, meaning .c files that define or 38 | * otherwise reference them should #include "bf_register.h" internally 39 | * instead of publicly declaring the individual functions in their own 40 | * header (.h) files. 41 | */ 42 | 43 | extern void do_all_registrations(void); 44 | /* run all registration functions */ 45 | 46 | @@EXTERNS@@ 47 | 48 | #endif /* !BF_Register_H */ 49 | -------------------------------------------------------------------------------- /ac_include/moo_cflags.m4: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------- 2 | # MOO_ADD_CFLAGS(-OPTION,[-OPTION2,...]) 3 | # 4 | # Add -OPTION to CFLAGS, but only if compilation does not break 5 | # If multiple -OPTIONs are given, adds the first one that works. 6 | # Sets cache variable(s) moo_cc_cv_grok_OPTION. 7 | # 8 | AC_DEFUN([MOO_ADD_CFLAGS], 9 | [m4_if([$2],[], 10 | [_MOO_ADD_CFLAG([$1],[nobreak])], 11 | [[while : ; do]m4_map_args([ 12 | _MOO_ADD_CFLAG],$@)[ 13 | break 14 | done]])])dnl 15 | # 16 | # _MOO_ADD_CFLAG(-OPTION,[nobreak]) 17 | # does the actual work; 18 | # adds a 'break' if successful unless 'nobreak' is specified 19 | # 20 | # (the mechanics are annoying because clang warns but otherwise 21 | # happily continues with -Wfoos that it doesn't recognize, 22 | # so we have to set -Werror to get it to fail. But this 23 | # causes -Wstrict-prototypes to make 'int main() {...}' fail, 24 | # so we cannot use AC_LANG_PROGRAM, and we also have to deal 25 | # with -Wunused (enabled by -Wall and -Wextra (nee -W)) 26 | # killing us unless argc and argv are given something to do). 27 | # 28 | m4_define([_MOO_ADD_CFLAG], 29 | [AS_VAR_PUSHDEF([_moo_Flag], [moo_cc_cv_grok$1])dnl 30 | AC_CACHE_CHECK([if $CC accepts $1],m4_dquote(_moo_Flag),[[ 31 | _moo_save_cflags="$CFLAGS" 32 | CFLAGS="$CFLAGS -Werror $1"] 33 | AC_LINK_IFELSE([AC_LANG_SOURCE([[ 34 | #include 35 | int 36 | main (int argc, char **argv) 37 | { 38 | printf("Hello %d, World %s!", argc, argv[0]); 39 | return 0; 40 | } 41 | ]])],[AS_VAR_SET(m4_dquote(_moo_Flag),[yes])],[AS_VAR_SET(m4_dquote(_moo_Flag),[no])])[ 42 | CFLAGS="$_moo_save_cflags" 43 | ]]) 44 | AS_VAR_IF(m4_dquote(_moo_Flag),[yes], 45 | [[CFLAGS="$CFLAGS $1"]m4_if([$2],[],[[ 46 | break]],[])]) 47 | AS_VAR_POPDEF([_moo_Flag])]) 48 | dnl 49 | -------------------------------------------------------------------------------- /my-stropts.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 My_StrOpts_H 19 | #define My_StrOpts_H 1 20 | 21 | #include "config.h" 22 | 23 | #if UNDEF_IO_IN_STROPTS_H 24 | /* prevent conflict with */ 25 | #undef _IO 26 | #endif 27 | 28 | #include 29 | 30 | #endif /* !My_StrOpts_H */ 31 | 32 | 33 | /* 34 | * $Log$ 35 | * Revision 2.1 1996/02/08 06:01:12 pavel 36 | * Updated copyright notice for 1996. Release 1.8.0beta1. 37 | * 38 | * Revision 2.0 1995/11/30 04:59:12 pavel 39 | * New baseline version, corresponding to release 1.8.0alpha1. 40 | * 41 | * Revision 1.3 1992/10/23 23:03:47 pavel 42 | * Added copyright notice. 43 | * 44 | * Revision 1.2 1992/10/21 03:02:35 pavel 45 | * Converted to use new automatic configuration system. 46 | * 47 | * Revision 1.1 1992/10/06 01:38:46 pavel 48 | * Initial RCS-controlled version. 49 | */ 50 | -------------------------------------------------------------------------------- /net_proto.c: -------------------------------------------------------------------------------- 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 "net_proto.h" 19 | 20 | # if NETWORK_PROTOCOL == NP_TCP 21 | # if NETWORK_STYLE == NS_BSD 22 | # include "net_bsd_tcp.c" 23 | # endif 24 | # if NETWORK_STYLE == NS_SYSV 25 | # include "net_sysv_tcp.c" 26 | # endif 27 | # endif 28 | 29 | # if NETWORK_PROTOCOL == NP_LOCAL 30 | # if NETWORK_STYLE == NS_BSD 31 | # include "net_bsd_lcl.c" 32 | # endif 33 | # if NETWORK_STYLE == NS_SYSV 34 | # include "net_sysv_lcl.c" 35 | # endif 36 | # endif 37 | 38 | 39 | /* 40 | * $Log$ 41 | * Revision 2.1 1996/02/08 06:58:12 pavel 42 | * Updated copyright notice for 1996. Release 1.8.0beta1. 43 | * 44 | * Revision 2.0 1995/11/30 04:28:43 pavel 45 | * New baseline version, corresponding to release 1.8.0alpha1. 46 | * 47 | * Revision 1.1 1995/11/30 04:28:36 pavel 48 | * Initial revision 49 | */ 50 | -------------------------------------------------------------------------------- /my-inet.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 My_INet_H 19 | #define My_INet_H 1 20 | 21 | #include "config.h" 22 | 23 | #if ARPA_INET_H_NEEDS_HELP 24 | /* Some systems don't #include everything they depend on in their headers. */ 25 | #include "my-in.h" 26 | #endif 27 | 28 | #include 29 | 30 | #endif /* !My_INet_H */ 31 | 32 | /* 33 | * $Log$ 34 | * Revision 2.1 1996/02/08 06:04:48 pavel 35 | * Updated copyright notice for 1996. Release 1.8.0beta1. 36 | * 37 | * Revision 2.0 1995/11/30 04:57:31 pavel 38 | * New baseline version, corresponding to release 1.8.0alpha1. 39 | * 40 | * Revision 1.3 1992/10/23 23:03:47 pavel 41 | * Added copyright notice. 42 | * 43 | * Revision 1.2 1992/10/21 03:02:35 pavel 44 | * Converted to use new automatic configuration system. 45 | * 46 | * Revision 1.1 1992/10/09 00:04:28 pavel 47 | * Initial RCS-controlled version. 48 | */ 49 | -------------------------------------------------------------------------------- /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 | #ifndef Pattern_H 19 | #define Pattern_H 1 20 | 21 | #include "config.h" 22 | 23 | typedef struct { 24 | int start, end; 25 | } Match_Indices; 26 | 27 | typedef struct { 28 | void *ptr; 29 | } Pattern; 30 | 31 | typedef enum { 32 | MATCH_SUCCEEDED, MATCH_FAILED, MATCH_ABORTED 33 | } Match_Result; 34 | 35 | extern Pattern new_pattern(const char *pattern, int case_matters); 36 | extern Match_Result match_pattern(Pattern p, const char *string, 37 | Match_Indices * indices, int is_reverse); 38 | extern void free_pattern(Pattern p); 39 | 40 | #endif /* !Pattern_H */ 41 | 42 | /* 43 | * $Log$ 44 | * Revision 2.1 1996/02/08 06:14:35 pavel 45 | * Updated copyright notice for 1996. Release 1.8.0beta1. 46 | * 47 | * Revision 2.0 1995/11/30 05:07:35 pavel 48 | * New baseline version, corresponding to release 1.8.0alpha1. 49 | * 50 | * Revision 1.1 1995/11/30 05:07:25 pavel 51 | * Initial revision 52 | */ 53 | -------------------------------------------------------------------------------- /ac_include/moo_svf_mk.m4: -------------------------------------------------------------------------------- 1 | dnl -*- autoconf -*- 2 | 3 | # -------------------------------------------------------------------- 4 | # MOO_SVF_ARG_MAKE 5 | # 6 | # --(enable|disable)-svf-make 7 | # whether server_version_full includes a 'make' group 8 | # default is yes iff GNU make is in use. 9 | # 10 | AC_DEFUN([MOO_SVF_ARG_MAKE], 11 | [AC_REQUIRE([MOO_CHECK_GNU_MAKE]) 12 | AC_ARG_ENABLE([svf-make], 13 | [AS_HELP_STRING([--(en|dis)able-svf-make],[include/exclude 'make' group],[30])], 14 | [AS_CASE([$enableval],[[yes]], 15 | AS_CASE([[$moo_cv_make_is_gnumake]],[[no]], 16 | [AC_MSG_ERROR([--enable-svf-make requires GNU make])]))], 17 | [AS_VAR_COPY([enable_svf_make],[moo_cv_make_is_gnumake])])]) 18 | 19 | 20 | # -------------------------------------------------------------------- 21 | # MOO_CHECK_GNU_MAKE 22 | # 23 | # determines whether $MAKE understands GNU features needed 24 | # for server_version_full to include a 'make' group 25 | # (needs to understand ${subst...} and MAKEOVERRIDES) 26 | # 27 | AC_DEFUN([MOO_CHECK_GNU_MAKE], 28 | [AC_REQUIRE([AC_PROG_MAKE_SET]) 29 | AC_CACHE_CHECK([make having GNU features],[moo_cv_make_is_gnumake],[[ 30 | if "][$][{MAKE-make}" a=b=c=d -f - <<'END' | grep axbxcxd >/dev/null 2>&1 31 | b=][$][{subst =,x,][$][{MAKEOVERRIDES}} 32 | t: 33 | @echo $(b) 34 | END 35 | then 36 | moo_cv_make_is_gnumake=yes 37 | else 38 | moo_cv_make_is_gnumake=no 39 | fi 40 | ]])]) 41 | 42 | # -------------------------------------------------------------------- 43 | # MOO_SVF_SUBST_VERSION_MAKE 44 | # 45 | # set the Makefile substitution for collecting 46 | # the version 'make' group, (or make it a no-op 47 | # if --disable-svf-make is specified) 48 | # 49 | 50 | AC_DEFUN([MOO_SVF_SUBST_VERSION_MAKE], 51 | [AC_SUBST_FILE([version_make_frag]) 52 | AS_CASE([$enable_svf_make], 53 | [[no]],[[ 54 | version_make_frag="$srcdir/ac_include/moo_svf_mk0.mk"]], 55 | [[yes]],[[ 56 | version_make_frag="$srcdir/ac_include/moo_svf_mk1.mk"]])]) 57 | -------------------------------------------------------------------------------- /my-poll.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 My_Poll_H 19 | #define My_Poll_H 1 20 | 21 | #include "config.h" 22 | 23 | #include 24 | 25 | #if NDECL_POLL 26 | extern int poll(struct pollfd *, unsigned long, int); 27 | #endif 28 | 29 | #endif /* !My_Poll_H */ 30 | 31 | 32 | /* 33 | * $Log$ 34 | * Revision 2.1 1996/02/08 06:03:22 pavel 35 | * Updated copyright notice for 1996. Release 1.8.0beta1. 36 | * 37 | * Revision 2.0 1995/11/30 04:57:46 pavel 38 | * New baseline version, corresponding to release 1.8.0alpha1. 39 | * 40 | * Revision 1.4 1992/10/23 23:03:47 pavel 41 | * Added copyright notice. 42 | * 43 | * Revision 1.3 1992/10/21 03:02:35 pavel 44 | * Converted to use new automatic configuration system. 45 | * 46 | * Revision 1.2 1992/10/06 18:27:51 pavel 47 | * Added `#ifdef sun' around the declaration of poll(), since only SunOS seems 48 | * to need it. 49 | * 50 | * Revision 1.1 1992/10/03 00:52:26 pavel 51 | * Initial RCS-controlled version. 52 | */ 53 | -------------------------------------------------------------------------------- /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 My_Math_H 19 | #define My_Math_H 1 20 | 21 | #include "config.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #if HAVE___FLOAT128 28 | # if HAVE_QUADMATH_H 29 | # include 30 | # endif 31 | #endif 32 | 33 | #define IS_REAL(x) (-FLOAT_DEF(HUGE_VAL) < (x) && (x) < FLOAT_DEF(HUGE_VAL)) 34 | 35 | #endif /* !My_Math_H */ 36 | 37 | /* 38 | * $Log$ 39 | * Revision 2.2 1996/03/10 01:06:01 pavel 40 | * Replaced HUGE_VAL with DBL_MAX, since some systems (e.g., BSDi 1.1) 41 | * mis-define the former as positive infinity. Release 1.8.0. 42 | * 43 | * Revision 2.1 1996/02/08 06:04:22 pavel 44 | * Updated copyright notice for 1996. Added inclusion of for all of 45 | * the standard math functions. Added IS_REAL() check for NaNs and 46 | * infinities. Release 1.8.0beta1. 47 | * 48 | * Revision 2.0 1995/11/30 05:15:40 pavel 49 | * New baseline version, corresponding to release 1.8.0alpha1. 50 | */ 51 | -------------------------------------------------------------------------------- /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 | #ifndef Match_H 19 | #define Match_H 1 20 | 21 | #include "config.h" 22 | 23 | #include "structures.h" 24 | 25 | extern Objid match_object(Objid player, const char *name); 26 | 27 | #endif /* !Match_H */ 28 | 29 | /* 30 | * $Log$ 31 | * Revision 2.1 1996/02/08 06:22:33 pavel 32 | * Updated copyright notice for 1996. Release 1.8.0beta1. 33 | * 34 | * Revision 2.0 1995/11/30 04:52:16 pavel 35 | * New baseline version, corresponding to release 1.8.0alpha1. 36 | * 37 | * Revision 1.5 1992/10/23 23:03:47 pavel 38 | * Added copyright notice. 39 | * 40 | * Revision 1.4 1992/10/21 03:02:35 pavel 41 | * Converted to use new automatic configuration system. 42 | * 43 | * Revision 1.3 1992/09/14 17:43:40 pjames 44 | * Moved db_modification code to db modules. 45 | * 46 | * Revision 1.2 1992/08/31 22:26:59 pjames 47 | * Changed some `char *'s to `const char *' 48 | * 49 | * Revision 1.1 1992/07/20 23:23:12 pavel 50 | * Initial RCS-controlled version. 51 | */ 52 | -------------------------------------------------------------------------------- /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.gz 32 | gzip $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 | 43 | ############################################################################### 44 | # $Log$ 45 | # Revision 2.1 1996/02/08 07:25:45 pavel 46 | # Updated copyright notice for 1996. Release 1.8.0beta1. 47 | # 48 | # Revision 2.0 1995/11/30 05:14:43 pavel 49 | # New baseline version, corresponding to release 1.8.0alpha1. 50 | # 51 | # Revision 1.2 1994/05/26 16:43:13 pavel 52 | # Fixed up copyright, RCS info; removed debugging switch. 53 | # 54 | # Revision 1.1 1994/05/26 16:41:32 pavel 55 | # Initial revision 56 | ############################################################################### 57 | -------------------------------------------------------------------------------- /my-ioctl.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 My_IOCtl_H 19 | #define My_IOCtl_H 1 20 | 21 | #include "config.h" 22 | 23 | #include 24 | 25 | #if NDECL_IOCTL 26 | extern int ioctl(int, int,...); 27 | #endif 28 | 29 | #endif /* !My_IOCtl_H */ 30 | 31 | /* 32 | * $Log$ 33 | * Revision 2.1 1996/02/08 06:04:38 pavel 34 | * Updated copyright notice for 1996. Release 1.8.0beta1. 35 | * 36 | * Revision 2.0 1995/11/30 04:57:38 pavel 37 | * New baseline version, corresponding to release 1.8.0alpha1. 38 | * 39 | * Revision 1.5 1992/10/23 23:03:47 pavel 40 | * Added copyright notice. 41 | * 42 | * Revision 1.4 1992/10/21 03:02:35 pavel 43 | * Converted to use new automatic configuration system. 44 | * 45 | * Revision 1.3 1992/10/17 20:35:51 pavel 46 | * Changed declaration of ioctl() to avoid specifying the type of the last 47 | * argument. 48 | * 49 | * Revision 1.2 1992/07/30 00:31:12 pavel 50 | * Add support for compiling on RISC/os 4.52 and NonStop-UX A22. 51 | * 52 | * Revision 1.1 1992/07/20 23:23:12 pavel 53 | * Initial RCS-controlled version. 54 | */ 55 | -------------------------------------------------------------------------------- /getpagesize.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 GetPageSize_H 19 | #define GetPageSize_H 1 20 | 21 | #ifdef BSD 22 | #ifndef BSD4_1 23 | #define HAVE_GETPAGESIZE 24 | #endif 25 | #endif 26 | 27 | #ifndef HAVE_GETPAGESIZE 28 | 29 | #include 30 | 31 | #ifdef EXEC_PAGESIZE 32 | #define getpagesize() EXEC_PAGESIZE 33 | #else 34 | #ifdef NBPG 35 | #define getpagesize() NBPG * CLSIZE 36 | #ifndef CLSIZE 37 | #define CLSIZE 1 38 | #endif /* no CLSIZE */ 39 | #else /* no NBPG */ 40 | #define getpagesize() NBPC 41 | #endif /* no NBPG */ 42 | #endif /* no EXEC_PAGESIZE */ 43 | 44 | #endif /* not HAVE_GETPAGESIZE */ 45 | 46 | #endif /* !GetPageSize_H */ 47 | 48 | 49 | /* 50 | * $Log$ 51 | * Revision 2.1 1996/02/08 06:24:58 pavel 52 | * Updated copyright notice for 1996. Release 1.8.0beta1. 53 | * 54 | * Revision 2.0 1995/11/30 04:51:46 pavel 55 | * New baseline version, corresponding to release 1.8.0alpha1. 56 | * 57 | * Revision 1.2 1992/10/23 23:03:47 pavel 58 | * Added copyright notice. 59 | * 60 | * Revision 1.1 1992/07/20 23:23:12 pavel 61 | * Initial RCS-controlled version. 62 | */ 63 | -------------------------------------------------------------------------------- /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 | #ifndef Keywords_H 19 | #define Keywords_H 1 20 | 21 | #include "config.h" 22 | 23 | #include "structures.h" 24 | #include "version.h" 25 | 26 | struct keyword { 27 | const char *name; /* the canonical spelling of the keyword */ 28 | DB_Version version; /* the DB version when it was introduced */ 29 | int token; /* the type of token the scanner should use */ 30 | enum error error; /* for token == ERROR, the value */ 31 | }; 32 | 33 | typedef const struct keyword Keyword; 34 | 35 | extern Keyword *find_keyword(const char *, size_t); 36 | 37 | #endif /* !Keywords_H */ 38 | 39 | /* 40 | * $Log$ 41 | * Revision 2.2 1996/02/08 06:24:47 pavel 42 | * Fixed type of version number. Updated copyright notice for 1996. 43 | * Release 1.8.0beta1. 44 | * 45 | * Revision 2.1 1995/12/11 08:15:02 pavel 46 | * Removed useless #include "tokens.h". Release 1.8.0alpha2. 47 | * 48 | * Revision 2.0 1995/11/30 05:06:50 pavel 49 | * New baseline version, corresponding to release 1.8.0alpha1. 50 | * 51 | * Revision 1.1 1995/11/30 05:06:40 pavel 52 | * Initial revision 53 | */ 54 | -------------------------------------------------------------------------------- /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 "my-time.h" 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(void); 34 | 35 | #endif /* !Timers_H */ 36 | 37 | /* 38 | * $Log$ 39 | * Revision 2.1 1996/02/08 06:09:00 pavel 40 | * Updated copyright notice for 1996. Release 1.8.0beta1. 41 | * 42 | * Revision 2.0 1995/11/30 04:56:13 pavel 43 | * New baseline version, corresponding to release 1.8.0alpha1. 44 | * 45 | * Revision 1.3 1992/10/23 23:03:47 pavel 46 | * Added copyright notice. 47 | * 48 | * Revision 1.2 1992/09/23 17:12:25 pavel 49 | * Added protection against this file being included more than once. 50 | * 51 | * Revision 1.1 1992/07/20 23:23:12 pavel 52 | * Initial RCS-controlled version. 53 | */ 54 | -------------------------------------------------------------------------------- /restart: -------------------------------------------------------------------------------- 1 | #!/bin/csh -f 2 | 3 | # Copyright (c) 1992, 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 ($#argv < 1 || $#argv > 2) then 19 | echo 'Usage: restart dbase-prefix [port]' 20 | exit 1 21 | endif 22 | 23 | if (! -r $1.db) then 24 | echo "Unknown database: $1.db" 25 | exit 1 26 | endif 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.gz 32 | gzip $1.db.old & 33 | endif 34 | 35 | if (-f $1.log) then 36 | cat $1.log >> $1.log.old 37 | rm $1.log 38 | endif 39 | 40 | echo `date`: RESTARTED >> $1.log 41 | #unlimit descriptors 42 | nohup ./moo $1.db $1.db.new $2 >>& $1.log & 43 | 44 | ############################################################################### 45 | # $Log$ 46 | # Revision 2.1 1996/02/08 07:25:52 pavel 47 | # Updated copyright notice for 1996. Release 1.8.0beta1. 48 | # 49 | # Revision 2.0 1995/11/30 05:14:17 pavel 50 | # New baseline version, corresponding to release 1.8.0alpha1. 51 | # 52 | # Revision 1.4 1992/10/23 23:15:21 pavel 53 | # Added copyright notice. 54 | # 55 | # Revision 1.3 1992/08/18 00:34:52 pavel 56 | # Added automatic compression of the .old database and the provision of a new 57 | # log file for each activation, saving the old log file on the end of a 58 | # .log.old file. 59 | # 60 | # Revision 1.2 1992/07/20 23:29:34 pavel 61 | # Trying out an RCS change log in this file to see if it'll work properly. 62 | # 63 | ############################################################################### 64 | -------------------------------------------------------------------------------- /my-stat.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 My_Stat_H 19 | #define My_Stat_H 1 20 | 21 | #include "config.h" 22 | 23 | #if SYS_STAT_H_NEEDS_HELP 24 | # include "my-types.h" 25 | #endif 26 | 27 | #include 28 | 29 | #if NDECL_FSTAT 30 | #include "my-types.h" 31 | 32 | extern int stat(const char *, struct stat *); 33 | extern int fstat(int, struct stat *); 34 | extern int mkfifo(const char *, mode_t); 35 | #endif 36 | 37 | #if !HAVE_MKFIFO 38 | extern int mknod(const char *file, int mode, int dev); 39 | #define mkfifo(path, mode) mknod(path, S_IFIFO | (mode), 0) 40 | #endif 41 | 42 | #endif /* !My_Stat_H */ 43 | 44 | /* 45 | * $Log$ 46 | * Revision 2.3 1996/02/08 06:02:22 pavel 47 | * Updated copyright notice for 1996. Release 1.8.0beta1. 48 | * 49 | * Revision 2.2 1995/12/31 03:25:59 pavel 50 | * Added test for needing help. Release 1.8.0alpha4. 51 | * 52 | * Revision 2.1 1995/12/28 00:36:26 pavel 53 | * Added declaration of stat(). Release 1.8.0alpha3. 54 | * 55 | * Revision 2.0 1995/11/30 04:58:21 pavel 56 | * New baseline version, corresponding to release 1.8.0alpha1. 57 | * 58 | * Revision 1.2 1992/10/23 23:03:47 pavel 59 | * Added copyright notice. 60 | * 61 | * Revision 1.1 1992/10/23 22:25:00 pavel 62 | * Initial RCS-controlled version. 63 | */ 64 | -------------------------------------------------------------------------------- /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 | 23 | #include "structures.h" 24 | #include "version.h" 25 | 26 | extern Var *new_rt_env(unsigned size); 27 | extern void free_rt_env(Var * rt_env, unsigned size); 28 | extern Var *copy_rt_env(Var * from, unsigned size); 29 | 30 | void set_rt_env_obj(Var * env, int slot, Objid o); 31 | void set_rt_env_str(Var * env, int slot, const char *s); 32 | void set_rt_env_var(Var * env, int slot, Var v); 33 | 34 | void fill_in_rt_consts(Var * env, DB_Version); 35 | 36 | #endif /* !Eval_Env_H */ 37 | 38 | /* 39 | * $Log$ 40 | * Revision 2.1 1996/02/08 06:26:34 pavel 41 | * Made fill_in_rt_consts() version-dependent. Updated copyright notice for 42 | * 1996. Release 1.8.0beta1. 43 | * 44 | * Revision 2.0 1995/11/30 04:50:38 pavel 45 | * New baseline version, corresponding to release 1.8.0alpha1. 46 | * 47 | * Revision 1.4 1992/10/23 23:03:47 pavel 48 | * Added copyright notice. 49 | * 50 | * Revision 1.3 1992/10/21 03:02:35 pavel 51 | * Converted to use new automatic configuration system. 52 | * 53 | * Revision 1.2 1992/08/31 22:22:36 pjames 54 | * Changed some `char *'s to `const char *' 55 | * 56 | * Revision 1.1 1992/08/10 16:20:00 pjames 57 | * Initial RCS-controlled version 58 | */ 59 | -------------------------------------------------------------------------------- /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 | -- add a case to each of free_var(), var_ref(), and var_dup(), in utils.c 19 | 20 | In addition, for visible types, you must: 21 | -- consider adding a new built-in MOO variable like OBJ, STR, and LIST: 22 | -- add a new SLOT_XXX constant *at the end* of the list in sym_table.h 23 | -- add a new DB version number *just before the end* of the 24 | `DB_Version' enumeration in version.h 25 | -- add a version-contingent clause to fill_in_rt_consts(), 26 | in eval_env.c 27 | -- add a version-contingent clause to each of new_builtin_names() and 28 | first_user_slot(), in sym_table.c 29 | -- consider adding a new kind of MOO literal or expression that produces values 30 | of the new type. 31 | -- add a case to each of stream_add_tostr() and unparse_value(), in list.c; the 32 | former is used by the MOO function tostr() and the latter by toliteral(). 33 | -- add a case to to each of become_integer() and become_float(), in numbers.c; 34 | the former is used by toint() and toobj() and the latter by tofloat(). 35 | -- consider adding a clause to is_true(), equality(), and value_bytes(), 36 | in utils.c; the first implements MOO's notion of truth values, the second is 37 | used in the `==' and `!=' expressions and the equals() function, and the 38 | third is used in the MOO function of the same name. 39 | -------------------------------------------------------------------------------- /my-fcntl.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 My_FCntl_H 19 | #define My_FCntl_H 1 20 | 21 | #include "config.h" 22 | 23 | #include 24 | 25 | #if NDECL_FCNTL 26 | extern int fcntl(int, int,...); 27 | extern int open(const char *, int,...); 28 | #endif 29 | 30 | #if POSIX_NONBLOCKING_WORKS 31 | /* Prefer POSIX-style nonblocking, if available. */ 32 | #define NONBLOCK_FLAG O_NONBLOCK 33 | #else 34 | #define NONBLOCK_FLAG O_NDELAY 35 | #endif 36 | 37 | #endif /* !My_FCntl_H */ 38 | 39 | /* 40 | * $Log$ 41 | * Revision 2.1 1996/02/08 06:05:07 pavel 42 | * Updated copyright notice for 1996. Release 1.8.0beta1. 43 | * 44 | * Revision 2.0 1995/11/30 04:57:10 pavel 45 | * New baseline version, corresponding to release 1.8.0alpha1. 46 | * 47 | * Revision 1.5 1992/10/23 23:03:47 pavel 48 | * Added copyright notice. 49 | * 50 | * Revision 1.4 1992/10/23 19:27:57 pavel 51 | * Changed to conditionalize on POSIX_NONBLOCKING_WORKS instead of 52 | * defined(O_NONBLOCK). 53 | * 54 | * Revision 1.3 1992/10/21 03:02:35 pavel 55 | * Converted to use new automatic configuration system. 56 | * 57 | * Revision 1.2 1992/10/17 20:34:42 pavel 58 | * Added some more system-dependent #if's. 59 | * Added definition of NONBLOCK_FLAG, to allow use of POSIX-style non-blocking 60 | * on systems where it is available. 61 | * 62 | * Revision 1.1 1992/10/06 01:38:46 pavel 63 | * Initial RCS-controlled version. 64 | */ 65 | -------------------------------------------------------------------------------- /name_lookup.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 | /* 19 | * This module provides IP host name lookup with timeouts. Because 20 | * many DNS servers are flaky and the normal UNIX name-lookup facilities just 21 | * hang in such situations, this interface comes in very handy. 22 | */ 23 | 24 | #ifndef Name_Lookup_H 25 | #define Name_Lookup_H 1 26 | 27 | #include "config.h" 28 | 29 | #include "my-in.h" 30 | 31 | extern int initialize_name_lookup(void); 32 | /* Initialize the module, returning true iff 33 | * this succeeds. 34 | */ 35 | 36 | extern uint32_t lookup_addr_from_name(const char *name, 37 | unsigned timeout); 38 | /* Translate a host name to a 32-bit 39 | * internet address in host byte order. If 40 | * anything goes wrong, return 0. Dotted 41 | * decimal address are translated properly. 42 | */ 43 | 44 | extern const char *lookup_name_from_addr(struct sockaddr_in *addr, 45 | unsigned timeout); 46 | /* Translate an internet address, contained 47 | * in the sockaddr_in, to a host name. If 48 | * the translation cannot be done, the 49 | * address is returned in dotted decimal 50 | * form. 51 | */ 52 | 53 | #endif /* !Name_Lookup_H */ 54 | 55 | /* 56 | * $Log$ 57 | * Revision 2.0 1995/11/30 05:07:03 pavel 58 | * New baseline version, corresponding to release 1.8.0alpha1. 59 | * 60 | * Revision 1.1 1995/11/30 05:06:56 pavel 61 | * Initial revision 62 | */ 63 | -------------------------------------------------------------------------------- /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 | #ifndef Eval_VM_H 19 | #define Eval_VM_H 1 20 | 21 | #include "config.h" 22 | 23 | #include "execute.h" 24 | #include "structures.h" 25 | 26 | extern vm read_vm(TaskID task_id); 27 | extern void write_vm(vm); 28 | 29 | extern vm new_vm(TaskID task_id, int stack_size); 30 | extern void free_vm(vm the_vm, int stack_too); 31 | 32 | extern activation top_activ(vm); 33 | extern Objid progr_of_cur_verb(vm); 34 | extern unsigned suspended_lineno_of_vm(vm); 35 | 36 | #endif /* !Eval_VM_H */ 37 | 38 | /* 39 | * $Log$ 40 | * Revision 2.1 1996/02/08 06:26:06 pavel 41 | * Updated copyright notice for 1996. Release 1.8.0beta1. 42 | * 43 | * Revision 2.0 1995/11/30 04:50:51 pavel 44 | * New baseline version, corresponding to release 1.8.0alpha1. 45 | * 46 | * Revision 1.6 1993/12/21 23:41:30 pavel 47 | * Add new `outcome' result from the interpreter. 48 | * 49 | * Revision 1.5 1992/10/23 23:03:47 pavel 50 | * Added copyright notice. 51 | * 52 | * Revision 1.4 1992/10/21 03:02:35 pavel 53 | * Converted to use new automatic configuration system. 54 | * 55 | * Revision 1.3 1992/10/17 20:26:16 pavel 56 | * Changed return-type of read_vm() from `char' to `int', for systems that use 57 | * unsigned chars. 58 | * 59 | * Revision 1.2 1992/08/31 22:22:56 pjames 60 | * Changed some `char *'s to `const char *' 61 | * 62 | * Revision 1.1 1992/08/10 16:20:00 pjames 63 | * Initial RCS-controlled version 64 | */ 65 | -------------------------------------------------------------------------------- /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 | #ifndef Log_H 19 | #define Log_H 1 20 | 21 | #include "config.h" 22 | 23 | #include "my-stdio.h" 24 | 25 | #include "structures.h" 26 | 27 | extern void set_log_file(FILE *); 28 | 29 | extern void oklog(const char *,...) FORMAT(printf,1,2); 30 | extern void errlog(const char *,...) FORMAT(printf,1,2); 31 | extern void log_perror(const char *); 32 | 33 | extern void reset_command_history(void); 34 | extern void log_command_history(void); 35 | extern void add_command_to_history(Objid player, const char *command); 36 | 37 | 38 | #define log_report_progress() ((--log_pcount <= 0) && log_report_progress_cktime()) 39 | 40 | extern int log_pcount; 41 | extern int log_report_progress_cktime(void); 42 | 43 | #endif /* !Log_H */ 44 | 45 | /* 46 | * $Log$ 47 | * Revision 2.2 1996/04/08 01:05:28 pavel 48 | * Added `set_log_file()' entry point. Release 1.8.0p3. 49 | * 50 | * Revision 2.1 1996/02/08 06:23:32 pavel 51 | * Renamed err/logf() to errlog/oklog(). Updated copyright notice for 1996. 52 | * Release 1.8.0beta1. 53 | * 54 | * Revision 2.0 1995/11/30 04:52:07 pavel 55 | * New baseline version, corresponding to release 1.8.0alpha1. 56 | * 57 | * Revision 1.3 1992/10/23 23:03:47 pavel 58 | * Added copyright notice. 59 | * 60 | * Revision 1.2 1992/10/21 03:02:35 pavel 61 | * Converted to use new automatic configuration system. 62 | * 63 | * Revision 1.1 1992/07/20 23:23:12 pavel 64 | * Initial RCS-controlled version. 65 | */ 66 | -------------------------------------------------------------------------------- /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 List_H 19 | #define List_H 1 20 | 21 | #include "structures.h" 22 | #include "streams.h" 23 | 24 | extern Var listappend(Var list, Var value); 25 | extern Var listinsert(Var list, Var value, int pos); 26 | extern Var listdelete(Var list, int pos); 27 | extern Var listset(Var list, Var value, int pos); 28 | extern Var listrangeset(Var list, Num from, Num after, Var value); 29 | extern Var listconcat(Var first, Var second); 30 | extern int ismember(Var value, Var list, int case_matters); 31 | extern Var setadd(Var list, Var value); 32 | extern Var setremove(Var list, Var value); 33 | extern Var sublist(Var list, Num first, Num after); 34 | extern Var strrangeset(Var list, Num from, Num after, Var value); 35 | extern Var substr(Var str, Num first, Num after); 36 | extern Var new_list(int size); 37 | extern const char *value2str(Var); 38 | extern void unparse_value(Stream *, Var); 39 | 40 | #endif /* !List_H */ 41 | 42 | /* 43 | * $Log$ 44 | * Revision 2.1 1996/02/08 06:23:44 pavel 45 | * Updated copyright notice for 1996. Release 1.8.0beta1. 46 | * 47 | * Revision 2.0 1995/11/30 04:51:57 pavel 48 | * New baseline version, corresponding to release 1.8.0alpha1. 49 | * 50 | * Revision 1.3 1992/10/23 23:03:47 pavel 51 | * Added copyright notice. 52 | * 53 | * Revision 1.2 1992/08/28 23:20:04 pjames 54 | * Added `listrangeset()' and `strrangeset()'. 55 | * 56 | * Revision 1.1 1992/07/20 23:23:12 pavel 57 | * Initial RCS-controlled version. 58 | */ 59 | -------------------------------------------------------------------------------- /my-tiuser.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 My_TIUser_H 19 | #define My_TIUser_H 1 20 | 21 | #include "config.h" 22 | 23 | #include 24 | 25 | #if NDECL_T_OPEN 26 | extern int t_accept(int, int, struct t_call *); 27 | extern void *t_alloc(int, int, int); 28 | extern int t_bind(int, struct t_bind *, struct t_bind *); 29 | extern int t_close(int); 30 | extern int t_connect(int, struct t_call *, struct t_call *); 31 | extern int t_listen(int, struct t_call *); 32 | extern int t_open(const char *, int, struct t_info *); 33 | 34 | extern int t_errno; 35 | #endif 36 | 37 | #if NDECL_T_ERRLIST 38 | extern char *t_errlist[]; 39 | #endif 40 | 41 | #endif /* !My_TIUser_H */ 42 | 43 | 44 | /* 45 | * $Log$ 46 | * Revision 2.1 1996/02/08 06:00:32 pavel 47 | * Updated copyright notice for 1996. Release 1.8.0beta1. 48 | * 49 | * Revision 2.0 1995/11/30 04:59:38 pavel 50 | * New baseline version, corresponding to release 1.8.0alpha1. 51 | * 52 | * Revision 1.5 1993/10/11 19:09:23 pavel 53 | * Separated out the check for an undeclared t_errlist, since Solaris, for one, 54 | * declares everying *but* that... 55 | * 56 | * Revision 1.4 1992/10/23 23:03:47 pavel 57 | * Added copyright notice. 58 | * 59 | * Revision 1.3 1992/10/21 03:02:35 pavel 60 | * Converted to use new automatic configuration system. 61 | * 62 | * Revision 1.2 1992/10/17 20:41:40 pavel 63 | * Added some more system-dependent #if's. 64 | * 65 | * Revision 1.1 1992/10/06 01:40:02 pavel 66 | * Initial RCS-controlled version. 67 | */ 68 | -------------------------------------------------------------------------------- /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 | 23 | #include "program.h" 24 | #include "version.h" 25 | 26 | typedef struct { 27 | void (*error) (void *, const char *); 28 | void (*warning) (void *, const char *); 29 | int32_t (*getch) (void *); 30 | } Parser_Client; 31 | 32 | extern Program *parse_program(DB_Version, Parser_Client, void *); 33 | extern Program *parse_list_as_program(Var code, Var * errors); 34 | 35 | #endif /* !Parser_H */ 36 | 37 | /* 38 | * $Log$ 39 | * Revision 2.2 1996/02/08 06:15:30 pavel 40 | * Removed ungetch() method on Parser_Client, added version number to 41 | * parse_program. Updated copyright notice for 1996. Release 1.8.0beta1. 42 | * 43 | * Revision 2.1 1995/12/28 00:47:29 pavel 44 | * Added support for MOO-compilation warnings. Release 1.8.0alpha3. 45 | * 46 | * Revision 2.0 1995/11/30 04:54:19 pavel 47 | * New baseline version, corresponding to release 1.8.0alpha1. 48 | * 49 | * Revision 1.5 1992/10/23 23:03:47 pavel 50 | * Added copyright notice. 51 | * 52 | * Revision 1.4 1992/10/21 03:02:35 pavel 53 | * Converted to use new automatic configuration system. 54 | * 55 | * Revision 1.3 1992/10/06 18:26:41 pavel 56 | * Changed name of global Parser_Client to avoid a name clash. 57 | * 58 | * Revision 1.2 1992/09/14 17:42:46 pjames 59 | * Moved db_modification code to db modules. 60 | * 61 | * Revision 1.1 1992/07/20 23:23:12 pavel 62 | * Initial RCS-controlled version. 63 | */ 64 | -------------------------------------------------------------------------------- /utf-ctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utf-ctype.h 3 | * 4 | * query Unicode Character Database for character attributes 5 | */ 6 | 7 | #ifndef UTF_CType_H 8 | #define UTF_CType_H 1 9 | 10 | #include "config.h" 11 | #include "options.h" 12 | 13 | #include "my-ctype.h" 14 | 15 | #if !UNICODE_NUMBERS 16 | inline int my_isdigit(uint32_t c) { return isdigit(c); } 17 | inline int my_digitval(uint32_t c) { return c - '0'; } 18 | #else 19 | extern int my_isdigit(uint32_t); 20 | extern int my_digitval(uint32_t); 21 | #endif 22 | 23 | #if !UNICODE_IDENTIFIERS 24 | inline int my_is_xid_start(uint32_t c) { return isalpha(c); } 25 | inline int my_is_xid_cont(uint32_t c) { return isalnum(c); } 26 | #else 27 | extern int my_is_xid_start(uint32_t); 28 | extern int my_is_xid_cont(uint32_t); 29 | #endif 30 | 31 | #if !UNICODE_STRINGS 32 | inline uint32_t my_tolower(uint32_t c) { return tolower(c); } 33 | inline uint32_t my_toupper(uint32_t c) { return toupper(c); } 34 | inline int my_isspace(uint32_t c) { return isspace(c); } 35 | #else 36 | extern uint32_t my_tolower(uint32_t); 37 | extern uint32_t my_toupper(uint32_t); 38 | extern int my_isspace(uint32_t); 39 | #endif 40 | 41 | #if UNICODE_STRINGS 42 | extern int my_is_printable(uint32_t); 43 | #else 44 | inline int 45 | my_is_printable(uint32_t x) 46 | { 47 | /* ::= isgraph(x) || x == ' ' || x == '\t', 48 | * except since we are defining our own thing we may 49 | * as well NOT rely on the ctype.h definitions. 50 | */ 51 | return ((x <= 0x7e) /* excludes DELETE */ 52 | && 53 | ((x & 0x60) || (x == '\t'))); 54 | } 55 | #endif 56 | /* Unlike with the other my_* functions here, which are intended to 57 | * follow the respective Unicode classifications, "printable" here 58 | * does NOT. It actually refers to the set of code points (character 59 | * values) that are part of the MOO language character set, i.e., 60 | * characters usable in MOO language string constants and on 61 | * connections that are not in binary mode. 62 | * 63 | * (XXX -- have thoughts about renaming, but if this comment is 64 | * still here, then that has not happened yet.) 65 | */ 66 | 67 | #define my_isascii(x) ((unsigned int)(x) < 127) 68 | 69 | extern const char *my_char_name(uint32_t); 70 | extern uint32_t my_char_lookup(const char *); 71 | 72 | extern uint32_t my_unicode_version(void); 73 | extern uint32_t my_unilib_version(void); 74 | extern const char *my_unilib_name; 75 | 76 | #endif /* !UTF_CType_H */ 77 | 78 | /* 79 | * $Log$ 80 | * 81 | */ 82 | -------------------------------------------------------------------------------- /net_multi.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 | #ifndef Net_Multi_H 19 | #define Net_Multi_H 1 20 | 21 | /* Extra networking facilities available only for the multi-user networking 22 | * configurations. 23 | */ 24 | 25 | typedef void (*network_fd_callback) (int fd, void *data); 26 | 27 | extern void network_register_fd(int fd, network_fd_callback readable, 28 | network_fd_callback writable, void *data); 29 | /* The file descriptor FD will be selected for 30 | * at intervals (whenever the networking module 31 | * is doing its own I/O processing). If FD 32 | * selects true for reading and READABLE is 33 | * non-zero, then READABLE will be called, 34 | * passing FD and DATA. Similarly for 35 | * WRITABLE. 36 | */ 37 | 38 | extern void network_unregister_fd(int fd); 39 | /* Any existing registration for FD is 40 | * forgotten. 41 | */ 42 | 43 | extern int network_set_nonblocking(int fd); 44 | /* Enable nonblocking I/O on the file 45 | * descriptor FD. Return true iff successful. 46 | */ 47 | 48 | extern void network_set_client_echo(network_handle nh, int is_on); 49 | /* Emit telnet escape sequence to inform 50 | * client what the echo state should be 51 | */ 52 | 53 | #endif /* !Net_Multi_H */ 54 | 55 | /* 56 | * $Log$ 57 | * Revision 2.1 1996/02/08 06:18:14 pavel 58 | * Updated copyright notice for 1996. Release 1.8.0beta1. 59 | * 60 | * Revision 2.0 1995/11/30 05:07:18 pavel 61 | * New baseline version, corresponding to release 1.8.0alpha1. 62 | * 63 | * Revision 1.1 1995/11/30 05:07:10 pavel 64 | * Initial revision 65 | */ 66 | -------------------------------------------------------------------------------- /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 | #ifndef Random_H 19 | #define Random_H 1 20 | 21 | #include "config.h" 22 | 23 | #if HAVE_LRAND48 24 | extern long lrand48(void); 25 | extern void srand48(long); 26 | # define RANDOM lrand48 27 | # define SRANDOM srand48 28 | #else 29 | # include "my-stdlib.h" 30 | # if HAVE_RANDOM 31 | # define RANDOM random 32 | # define SRANDOM srandom 33 | # else 34 | # define RANDOM rand 35 | # define SRANDOM srand 36 | # endif 37 | #endif 38 | 39 | #endif /* !Random_H */ 40 | 41 | /* 42 | * $Log$ 43 | * Revision 2.1 1996/02/08 06:13:41 pavel 44 | * Updated copyright notice for 1996. Release 1.8.0beta1. 45 | * 46 | * Revision 2.0 1995/11/30 04:54:47 pavel 47 | * New baseline version, corresponding to release 1.8.0alpha1. 48 | * 49 | * Revision 1.7 1993/08/04 00:04:28 pavel 50 | * Moved declaration of random() and srandom() to my-stdlib.h. 51 | * 52 | * Revision 1.6 1992/10/23 23:03:47 pavel 53 | * Added copyright notice. 54 | * 55 | * Revision 1.5 1992/10/21 03:02:35 pavel 56 | * Converted to use new automatic configuration system. 57 | * 58 | * Revision 1.4 1992/10/17 20:50:13 pavel 59 | * Generalized support for rand() replacements on systems that have better 60 | * generators. 61 | * 62 | * Revision 1.3 1992/09/11 21:16:41 pavel 63 | * Fixed to include config.h, to test USE_RANDOM. 64 | * 65 | * Revision 1.2 1992/08/14 00:38:20 pavel 66 | * Changed declaration of srandom() to be compatible with IRIX 4.0; I sure hope 67 | * this doesn't break any other ports... 68 | * 69 | * Revision 1.1 1992/07/20 23:23:12 pavel 70 | * Initial RCS-controlled version. 71 | */ 72 | -------------------------------------------------------------------------------- /network.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1992 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 "network.h" 19 | 20 | #include "options.h" 21 | 22 | #if NETWORK_PROTOCOL == NP_SINGLE 23 | # include "net_single.c" 24 | #else 25 | # include "net_multi.c" 26 | #endif 27 | 28 | #if NETWORK_PROTOCOL == NP_TCP 29 | # define TCP_ONLY 30 | #else 31 | # define TCP_ONLY UNUSED_ 32 | #endif 33 | 34 | Var 35 | network_connection_options(network_handle nh TCP_ONLY, Var list) 36 | { 37 | CONNECTION_OPTION_LIST(NETWORK_CO_TABLE, nh, list); 38 | } 39 | 40 | int 41 | network_connection_option(network_handle nh TCP_ONLY, const char *option TCP_ONLY, Var * value TCP_ONLY) 42 | { 43 | CONNECTION_OPTION_GET(NETWORK_CO_TABLE, nh, option, value); 44 | } 45 | 46 | int 47 | network_set_connection_option(network_handle nh TCP_ONLY, const char *option TCP_ONLY, Var value TCP_ONLY) 48 | { 49 | CONNECTION_OPTION_SET(NETWORK_CO_TABLE, nh, option, value); 50 | } 51 | 52 | 53 | /* 54 | * $Log$ 55 | * Revision 2.0 1995/11/30 05:11:37 pavel 56 | * New baseline version, corresponding to release 1.8.0alpha1. 57 | * 58 | * Revision 1.5 1992/10/23 23:03:47 pavel 59 | * Added copyright notice. 60 | * 61 | * Revision 1.4 1992/10/21 03:02:35 pavel 62 | * Converted to use new automatic configuration system. 63 | * 64 | * Revision 1.3 1992/09/26 02:29:24 pavel 65 | * Dyked out useless support plans for XNS protocols. 66 | * 67 | * Revision 1.2 1992/09/23 17:18:44 pavel 68 | * Now supports the new networking architecture, switching among protocol and 69 | * multiplexing-wait implementations based on settings in config.h. 70 | * 71 | * Revision 1.1 1992/09/03 21:09:51 pavel 72 | * Initial RCS-controlled version. 73 | */ 74 | -------------------------------------------------------------------------------- /my-sys-time.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 My_Sys_Time_H 19 | #define My_Sys_Time_H 1 20 | 21 | #include "config.h" 22 | #include "options.h" 23 | 24 | #include 25 | 26 | #if NEED_SELECT_H 27 | # include "my-types.h" 28 | # include 29 | #endif 30 | 31 | #if NDECL_GETITIMER 32 | extern int getitimer(int, struct itimerval *); 33 | #endif 34 | 35 | #if NDECL_SETITIMER 36 | extern int setitimer(int, struct itimerval *, struct itimerval *); 37 | #endif 38 | 39 | #if NDECL_SELECT && MPLEX_STYLE == MP_SELECT 40 | #include "my-types.h" 41 | 42 | extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 43 | #endif 44 | 45 | #endif /* !My_Sys_Time_H */ 46 | 47 | /* 48 | * $Log$ 49 | * Revision 2.1 1996/02/08 06:01:00 pavel 50 | * Updated copyright notice for 1996. Release 1.8.0beta1. 51 | * 52 | * Revision 2.0 1995/11/30 04:59:21 pavel 53 | * New baseline version, corresponding to release 1.8.0alpha1. 54 | * 55 | * Revision 1.5 1993/08/12 01:23:11 pavel 56 | * -- Split out optional declaration of setitimer() to be independent of the 57 | * one for getitimer(). 58 | * -- Only use declaration of select() if MP_SELECT is enabled. 59 | * -- Include if it exists. 60 | * 61 | * Revision 1.4 1992/10/23 23:03:47 pavel 62 | * Added copyright notice. 63 | * 64 | * Revision 1.3 1992/10/21 03:02:35 pavel 65 | * Converted to use new automatic configuration system. 66 | * 67 | * Revision 1.2 1992/10/17 21:01:10 pavel 68 | * Dyked out useless declaration of gettimeofday(). 69 | * Added some more system-dependent #if's. 70 | * 71 | * Revision 1.1 1992/07/20 23:23:12 pavel 72 | * Initial RCS-controlled version. 73 | */ 74 | -------------------------------------------------------------------------------- /my-time.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 My_Time_H 19 | #define My_Time_H 1 20 | 21 | #include "config.h" 22 | 23 | #if TIME_H_NEEDS_HELP 24 | /* Some systems' time.h does not include time_t or clock_t */ 25 | #include "my-types.h" 26 | #endif 27 | 28 | #include 29 | 30 | #if NDECL_TIME 31 | #include "my-types.h" 32 | 33 | extern time_t time(time_t *); 34 | #endif 35 | 36 | #include 37 | 38 | #if defined(MACH) && defined(CMU) 39 | /* These clowns blew the declaration of strftime() in their */ 40 | #undef HAVE_STRFTIME 41 | #endif 42 | 43 | #if HAVE_STRFTIME && NDECL_STRFTIME 44 | #include "my-types.h" 45 | 46 | extern size_t strftime(char *s, size_t smax, const char *fmt, 47 | const struct tm *tp); 48 | #endif 49 | 50 | #if HAVE_TZNAME && NDECL_TZNAME 51 | extern char *tzname; 52 | #endif 53 | 54 | #endif /* !My_Time_H */ 55 | 56 | /* 57 | * $Log$ 58 | * Revision 2.1 1996/02/08 06:00:41 pavel 59 | * *** empty log message *** 60 | * 61 | * Revision 2.0 1995/11/30 04:59:30 pavel 62 | * New baseline version, corresponding to release 1.8.0alpha1. 63 | * 64 | * Revision 1.5 1992/10/23 23:03:47 pavel 65 | * Added copyright notice. 66 | * 67 | * Revision 1.4 1992/10/23 19:35:14 pavel 68 | * Added check for avoiding strftime() on CMU MACH systems, since they declare 69 | * it wrong (though they implement it right). 70 | * Added missing #include "my-types.h" for strftime() declaration. 71 | * 72 | * Revision 1.3 1992/10/21 03:02:35 pavel 73 | * Converted to use new automatic configuration system. 74 | * 75 | * Revision 1.2 1992/07/30 00:38:08 pavel 76 | * Add support for compiling on RISC/os 4.52 and NonStop-UX A22. 77 | * 78 | * Revision 1.1 1992/07/20 23:23:12 pavel 79 | * Initial RCS-controlled version. 80 | */ 81 | -------------------------------------------------------------------------------- /md5.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 1996 Xerox Corporation. All rights reserved. 3 | Use and copying of this software and preparation of derivative works based 4 | upon this software are permitted. Any distribution of this software or 5 | derivative works must comply with all applicable United States export 6 | control laws. This software is made available AS IS, and Xerox Corporation 7 | makes no warranty about the software, its performance or its conformity to 8 | any specification. Any person obtaining a copy of this software is requested 9 | to send their name and post office or electronic mail address to: 10 | Pavel Curtis 11 | Xerox PARC 12 | 3333 Coyote Hill Rd. 13 | Palo Alto, CA 94304 14 | Pavel@Xerox.Com 15 | *****************************************************************************/ 16 | 17 | /* md5.h 18 | MD5 Message Digest Algorithm implementation. 19 | Ron Frederick 20 | 21 | Derived from RSA Data Security, Inc. MD5 Message-Digest Algorithm 22 | See below for original license notice. 23 | */ 24 | 25 | /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 26 | rights reserved. 27 | 28 | License to copy and use this software is granted provided that it 29 | is identified as the "RSA Data Security, Inc. MD5 Message-Digest 30 | Algorithm" in all material mentioning or referencing this software 31 | or this function. 32 | 33 | License is also granted to make and use derivative works provided 34 | that such works are identified as "derived from the RSA Data 35 | Security, Inc. MD5 Message-Digest Algorithm" in all material 36 | mentioning or referencing the derived work. 37 | 38 | RSA Data Security, Inc. makes no representations concerning either 39 | the merchantability of this software or the suitability of this 40 | software for any particular purpose. It is provided "as is" 41 | without express or implied warranty of any kind. 42 | 43 | These notices must be retained in any copies of any part of this 44 | documentation and/or software. 45 | */ 46 | 47 | #ifndef MD5_h 48 | #define MD5_h 1 49 | 50 | #include "config.h" 51 | 52 | /* MD5 context. */ 53 | typedef struct { 54 | uint32_t state[4]; /* state (ABCD) */ 55 | uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ 56 | uint8_t buffer[64]; /* input buffer */ 57 | } md5ctx_t; 58 | 59 | void md5_Init(md5ctx_t * context); 60 | void md5_Update(md5ctx_t * context, uint8_t * buf, unsigned len); 61 | void md5_Final(md5ctx_t * context, uint8_t digest[16]); 62 | 63 | #endif /* !MD5_h */ 64 | 65 | /* 66 | * $Log$ 67 | * Revision 1.1 1996/02/18 23:18:53 pavel 68 | * Initial revision 69 | * 70 | */ 71 | -------------------------------------------------------------------------------- /my-stdarg.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 My_StdArg_H 19 | #define My_StdArg_H 1 20 | 21 | #include "config.h" 22 | 23 | /* The server no longer uses variable-length argument lists of large (size > 8 24 | * bytes) structures, so this code is no longer needed and BUGGY_STDARG is 25 | * never defined in config.h. I've left the code here for possible future use. 26 | */ 27 | 28 | #if BUGGY_STDARG 29 | 30 | /* 31 | * This implementation of the stdarg.h stuff is very simplistic; it ignores all 32 | * promotion and alignment issues. This is good enough for LambdaMOO's uses on 33 | * most machines. Regardless, this implementation should not be used unless 34 | * the one on your machine won't work. 35 | */ 36 | 37 | #ifndef _VA_LIST_ 38 | #define _VA_LIST_ 1 39 | typedef void *va_list; 40 | #endif 41 | 42 | #define va_start(ptr, arg) \ 43 | (ptr = (void *) ((unsigned) &arg + sizeof(arg))) 44 | 45 | #define va_arg(ptr, type) \ 46 | ((type *) (ptr = (void *) ((unsigned) ptr + sizeof(type))))[-1] 47 | 48 | #define va_end(ptr) 49 | 50 | #else 51 | 52 | #include 53 | 54 | #endif /* BUGGY_STDARG */ 55 | 56 | #endif /* !My_StdArg_H */ 57 | 58 | /* 59 | * $Log$ 60 | * Revision 2.1 1996/02/08 06:02:14 pavel 61 | * Updated copyright notice for 1996. Release 1.8.0beta1. 62 | * 63 | * Revision 2.0 1995/11/30 04:58:36 pavel 64 | * New baseline version, corresponding to release 1.8.0alpha1. 65 | * 66 | * Revision 1.4 1992/10/23 23:03:47 pavel 67 | * Added copyright notice. 68 | * 69 | * Revision 1.3 1992/10/21 03:02:35 pavel 70 | * Converted to use new automatic configuration system. 71 | * 72 | * Revision 1.2 1992/09/22 22:47:15 pavel 73 | * Added missing #include of "config.h". 74 | * 75 | * Revision 1.1 1992/07/20 23:23:12 pavel 76 | * Initial RCS-controlled version. 77 | */ 78 | -------------------------------------------------------------------------------- /my-in.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 My_In_H 19 | #define My_In_H 1 20 | 21 | #include "config.h" 22 | 23 | #include "my-types.h" 24 | #include 25 | 26 | #if HAVE_MACHINE_ENDIAN_H 27 | 28 | # include 29 | 30 | #else 31 | 32 | # if !defined(htonl) && NDECL_HTONL 33 | extern unsigned short htons(); 34 | extern unsigned32 htonl(); 35 | extern unsigned short ntohs(); 36 | extern unsigned32 ntohl(); 37 | # endif 38 | 39 | #endif 40 | 41 | # if NDECL_IN_ADDR_T 42 | typedef unsigned32 in_addr_t; 43 | # endif 44 | 45 | # ifndef INADDR_NONE 46 | # define INADDR_NONE ((in_addr_t)-1) 47 | # endif 48 | 49 | #endif /* !My_In_H */ 50 | 51 | /* 52 | * $Log$ 53 | * Revision 2.1 1996/02/08 06:04:58 pavel 54 | * Updated copyright notice for 1996. Release 1.8.0beta1. 55 | * 56 | * Revision 2.0 1995/11/30 04:57:23 pavel 57 | * New baseline version, corresponding to release 1.8.0alpha1. 58 | * 59 | * Revision 1.7 1993/08/10 20:56:44 pavel 60 | * Fixed syntax error in default declaration of htonl() and friends. 61 | * 62 | * Revision 1.6 1993/08/04 00:11:59 pavel 63 | * Removed default big-endian definition for htonl() and friends, replacing it 64 | * with an external function declaration. 65 | * 66 | * Revision 1.5 1992/10/23 23:03:47 pavel 67 | * Added copyright notice. 68 | * 69 | * Revision 1.4 1992/10/23 19:28:46 pavel 70 | * Added protection against multiple inclusions, for systems that aren't 71 | * clever enough to do that for themselves. 72 | * 73 | * Revision 1.3 1992/10/21 03:02:35 pavel 74 | * Converted to use new automatic configuration system. 75 | * 76 | * Revision 1.2 1992/10/04 04:56:05 pavel 77 | * Removed misplaced declaration for inet_addr(). 78 | * 79 | * Revision 1.1 1992/07/20 23:23:12 pavel 80 | * Initial RCS-controlled version. 81 | */ 82 | -------------------------------------------------------------------------------- /my-signal.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 My_Signal_H 19 | #define My_Signal_H 1 20 | 21 | #include "config.h" 22 | 23 | #if SIGNAL_H_NEEDS_HELP 24 | /* Some systems' headers don't include all of the headers they need. */ 25 | #include 26 | #endif 27 | 28 | #include 29 | 30 | #if NDECL_KILL 31 | #include "my-types.h" 32 | 33 | extern int kill(pid_t, int); 34 | #endif 35 | 36 | #if NDECL_SIGEMPTYSET && HAVE_SIGEMPTYSET 37 | extern int sigemptyset(sigset_t *); 38 | extern int sigaddset(sigset_t *, int); 39 | #endif 40 | 41 | #if NDECL_SIGPROCMASK && HAVE_SIGPROCMASK 42 | extern int sigprocmask(int, sigset_t *, sigset_t *); 43 | #endif 44 | 45 | #if NDECL_SIGRELSE && HAVE_SIGRELSE 46 | extern int sigrelse(int); 47 | #endif 48 | 49 | #ifndef SIGCHLD 50 | #define SIGCHLD SIGCLD 51 | #endif 52 | 53 | #endif /* !My_Signal_H */ 54 | 55 | /* 56 | * $Log$ 57 | * Revision 2.1 1996/02/08 06:03:00 pavel 58 | * Updated copyright notice for 1996. Release 1.8.0beta1. 59 | * 60 | * Revision 2.0 1995/11/30 04:57:56 pavel 61 | * New baseline version, corresponding to release 1.8.0alpha1. 62 | * 63 | * Revision 1.7 1993/08/10 20:50:08 pavel 64 | * Split out the optional declaration of sigprocmask as a separate case. 65 | * 66 | * Revision 1.6 1992/10/23 23:03:47 pavel 67 | * Added copyright notice. 68 | * 69 | * Revision 1.5 1992/10/23 19:29:19 pavel 70 | * Added declarations for POSIX-style mask-manipulation functions. 71 | * 72 | * Revision 1.4 1992/10/21 03:02:35 pavel 73 | * Converted to use new automatic configuration system. 74 | * 75 | * Revision 1.3 1992/10/17 20:36:19 pavel 76 | * Added some more system-dependent #if's. 77 | * 78 | * Revision 1.2 1992/07/30 00:32:20 pavel 79 | * Add support for compiling on RISC/os 4.52 and NonStop-UX A22. 80 | * 81 | * Revision 1.1 1992/07/20 23:23:12 pavel 82 | * Initial RCS-controlled version. 83 | */ 84 | -------------------------------------------------------------------------------- /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 "config.h" 22 | 23 | #include "my-stdio.h" 24 | 25 | #include "program.h" 26 | #include "structures.h" 27 | 28 | typedef void (*Unparser_Receiver) (void *, const char *); 29 | 30 | extern void unparse_program(Program *, Unparser_Receiver, void *, 31 | int fully_parenthesize, 32 | int indent_lines, int f_index); 33 | 34 | extern void unparse_to_file(FILE * fp, Program *, 35 | int fully_parenthesize, 36 | int indent_lines, int f_index); 37 | extern void unparse_to_stderr(Program *, int fully_parenthesize, 38 | int indent_lines, int f_index); 39 | 40 | extern const char *error_name(enum error); /* E_NONE -> "E_NONE" */ 41 | extern const char *unparse_error(enum error); /* E_NONE -> "No error" */ 42 | 43 | #endif /* !Unparse_H */ 44 | 45 | /* 46 | * $Log$ 47 | * Revision 2.1 1996/02/08 06:08:46 pavel 48 | * Added unparse_to_file() and unparse_to_stderr(). Updated copyright notice 49 | * for 1996. Release 1.8.0beta1. 50 | * 51 | * Revision 2.0 1995/11/30 04:56:22 pavel 52 | * New baseline version, corresponding to release 1.8.0alpha1. 53 | * 54 | * Revision 1.7 1992/10/23 23:03:47 pavel 55 | * Added copyright notice. 56 | * 57 | * Revision 1.6 1992/10/21 03:02:35 pavel 58 | * Converted to use new automatic configuration system. 59 | * 60 | * Revision 1.5 1992/08/31 22:23:46 pjames 61 | * Changed some `char *'s to `const char *' 62 | * 63 | * Revision 1.4 1992/08/21 00:40:15 pavel 64 | * Renamed include file "parse_command.h" to "parse_cmd.h". 65 | * 66 | * Revision 1.3 1992/08/13 23:59:27 pavel 67 | * Converted to a typedef of `var_type' = `enum var_type'. 68 | * 69 | * Revision 1.2 1992/08/10 16:41:25 pjames 70 | * Changed ip to pc. 71 | * 72 | * Revision 1.1 1992/07/20 23:23:12 pavel 73 | * Initial RCS-controlled version. 74 | */ 75 | -------------------------------------------------------------------------------- /quota.c: -------------------------------------------------------------------------------- 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 "quota.h" 19 | 20 | #include "config.h" 21 | 22 | #include "db.h" 23 | #include "structures.h" 24 | 25 | static const char *quota_name = "ownership_quota"; 26 | 27 | int 28 | decr_quota(Objid player) 29 | { 30 | db_prop_handle h; 31 | Var v; 32 | 33 | if (!valid(player)) 34 | return 1; 35 | 36 | h = db_find_property(player, quota_name, &v); 37 | if (!h.ptr) 38 | return 1; 39 | 40 | if (v.type != TYPE_INT) 41 | return 1; 42 | 43 | if (v.v.num <= 0) 44 | return 0; 45 | 46 | v.v.num--; 47 | db_set_property_value(h, v); 48 | return 1; 49 | } 50 | 51 | void 52 | incr_quota(Objid player) 53 | { 54 | db_prop_handle h; 55 | Var v; 56 | 57 | if (!valid(player)) 58 | return; 59 | 60 | h = db_find_property(player, quota_name, &v); 61 | if (!h.ptr) 62 | return; 63 | 64 | if (v.type != TYPE_INT) 65 | return; 66 | 67 | v.v.num++; 68 | db_set_property_value(h, v); 69 | } 70 | 71 | 72 | /* 73 | * $Log$ 74 | * Revision 2.1 1996/02/08 06:54:04 pavel 75 | * Renamed TYPE_NUM to TYPE_INT. Updated copyright notice for 1996. 76 | * Release 1.8.0beta1. 77 | * 78 | * Revision 2.0 1995/11/30 04:30:55 pavel 79 | * New baseline version, corresponding to release 1.8.0alpha1. 80 | * 81 | * Revision 1.6 1992/10/23 23:03:47 pavel 82 | * Added copyright notice. 83 | * 84 | * Revision 1.5 1992/10/21 03:02:35 pavel 85 | * Converted to use new automatic configuration system. 86 | * 87 | * Revision 1.4 1992/09/14 17:43:25 pjames 88 | * Moved db_modification code to db modules. 89 | * 90 | * Revision 1.3 1992/08/10 16:54:57 pjames 91 | * Updated #includes. 92 | * 93 | * Revision 1.2 1992/07/21 00:06:18 pavel 94 | * Added rcsid_ declaration to hold the RCS ident. string. 95 | * 96 | * Revision 1.1 1992/07/20 23:23:12 pavel 97 | * Initial RCS-controlled version. 98 | */ 99 | -------------------------------------------------------------------------------- /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 | 23 | #include "db.h" 24 | #include "structures.h" 25 | 26 | typedef struct { 27 | const char *verb; /* verb (as typed by player) */ 28 | const char *argstr; /* arguments to verb */ 29 | Var args; /* arguments to the verb */ 30 | 31 | const char *dobjstr; /* direct object string */ 32 | Objid dobj; /* direct object */ 33 | 34 | const char *prepstr; /* preposition string */ 35 | db_prep_spec prep; /* preposition identifier */ 36 | 37 | const char *iobjstr; /* indirect object string */ 38 | Objid iobj; /* indirect object */ 39 | } Parsed_Command; 40 | 41 | extern char **parse_into_words(char *input, int *nwords); 42 | extern Var parse_into_wordlist(const char *command); 43 | extern Parsed_Command *parse_command(const char *command, Objid user); 44 | extern void free_parsed_command(Parsed_Command *); 45 | 46 | #endif /* !Parse_Cmd_H */ 47 | 48 | /* 49 | * $Log$ 50 | * Revision 2.1 1996/02/08 06:15:41 pavel 51 | * Updated copyright notice for 1996. Release 1.8.0beta1. 52 | * 53 | * Revision 2.0 1995/11/30 04:54:11 pavel 54 | * New baseline version, corresponding to release 1.8.0alpha1. 55 | * 56 | * Revision 1.6 1992/10/23 23:03:47 pavel 57 | * Added copyright notice. 58 | * 59 | * Revision 1.5 1992/10/21 03:02:35 pavel 60 | * Converted to use new automatic configuration system. 61 | * 62 | * Revision 1.4 1992/09/14 17:43:03 pjames 63 | * Moved db_modification code to db modules. 64 | * 65 | * Revision 1.3 1992/08/31 22:26:06 pjames 66 | * Changed some `char *'s to `const char *' 67 | * 68 | * Revision 1.2 1992/08/10 17:34:34 pjames 69 | * Added find_verb() which doesn't fill in a Parse_Info, just returns 70 | * information about the verb. 71 | * 72 | * Revision 1.1 1992/07/20 23:23:12 pavel 73 | * Initial RCS-controlled version. 74 | */ 75 | -------------------------------------------------------------------------------- /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 | 23 | #include "version.h" 24 | 25 | typedef struct { 26 | unsigned max_size; 27 | unsigned size; 28 | const char **names; 29 | } Names; 30 | 31 | extern Names *new_builtin_names(DB_Version); 32 | extern int first_user_slot(DB_Version); 33 | extern unsigned find_or_add_name(Names **, const char *); 34 | extern int find_name(Names *, const char *); 35 | extern void free_names(Names *); 36 | 37 | /* Environment slots for built-in variables */ 38 | #define SLOT_NUM 0 39 | #define SLOT_OBJ 1 40 | #define SLOT_STR 2 41 | #define SLOT_LIST 3 42 | #define SLOT_ERR 4 43 | #define SLOT_PLAYER 5 44 | #define SLOT_THIS 6 45 | #define SLOT_CALLER 7 46 | #define SLOT_VERB 8 47 | #define SLOT_ARGS 9 48 | #define SLOT_ARGSTR 10 49 | #define SLOT_DOBJ 11 50 | #define SLOT_DOBJSTR 12 51 | #define SLOT_PREPSTR 13 52 | #define SLOT_IOBJ 14 53 | #define SLOT_IOBJSTR 15 54 | 55 | /* Added in DBV_Float: */ 56 | #define SLOT_INT 16 57 | #define SLOT_FLOAT 17 58 | 59 | #endif /* !Sym_Table_H */ 60 | 61 | /* 62 | * $Log$ 63 | * Revision 2.2 1996/03/10 01:15:53 pavel 64 | * Removed a number of obsolete declarations. Release 1.8.0. 65 | * 66 | * Revision 2.1 1996/02/08 06:11:23 pavel 67 | * Made new_builtin_names() and first_user_slot() version-dependent to support 68 | * version numbers on suspended-task frames. Added SLOT_INT and SLOT_FLOAT. 69 | * Updated copyright notice for 1996. Release 1.8.0beta1. 70 | * 71 | * Revision 2.0 1995/11/30 04:55:57 pavel 72 | * New baseline version, corresponding to release 1.8.0alpha1. 73 | * 74 | * Revision 1.4 1992/10/23 23:03:47 pavel 75 | * Added copyright notice. 76 | * 77 | * Revision 1.3 1992/10/21 03:02:35 pavel 78 | * Converted to use new automatic configuration system. 79 | * 80 | * Revision 1.2 1992/08/31 22:24:26 pjames 81 | * Changed some `char *'s to `const char *' 82 | * 83 | * Revision 1.1 1992/07/20 23:23:12 pavel 84 | * Initial RCS-controlled version. 85 | */ 86 | -------------------------------------------------------------------------------- /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 1 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 | #define BQM_DESCRIBE_Bytecodes(B,F,V,X) ((4 * F) + V) 34 | 35 | typedef struct { 36 | DB_Version version; 37 | unsigned first_lineno; 38 | unsigned ref_count; 39 | 40 | Bytecodes main_vector; 41 | 42 | unsigned num_literals; 43 | Var *literals; 44 | 45 | unsigned fork_vectors_size; 46 | Bytecodes *fork_vectors; 47 | 48 | unsigned num_var_names; 49 | const char **var_names; 50 | 51 | unsigned cached_lineno; 52 | unsigned cached_lineno_pc; 53 | int cached_lineno_vec; 54 | } Program; 55 | #define BQM_DESCRIBE_Program(B,F,V,X) ((8 * F) + (9 * V)) 56 | 57 | #define MAIN_VECTOR -1 /* As opposed to an index into fork_vectors */ 58 | 59 | extern Program *new_program(void); 60 | extern Program *null_program(void); 61 | extern Program *program_ref(Program *); 62 | extern int program_bytes(Program *); 63 | extern void free_program(Program *); 64 | 65 | #endif /* !Program_H */ 66 | 67 | /* 68 | * $Log$ 69 | * Revision 2.3 1996/02/08 06:14:19 pavel 70 | * Added version number on programs. Updated copyright notice for 1996. 71 | * Release 1.8.0beta1. 72 | * 73 | * Revision 2.2 1995/12/31 03:13:02 pavel 74 | * Added numbytes_stack field to Bytecodes values. Release 1.8.0alpha4. 75 | * 76 | * Revision 2.1 1995/12/11 08:03:22 pavel 77 | * Removed a useless macro definition. Added `null_program()' and 78 | * `program_bytes()'. Release 1.8.0alpha2. 79 | * 80 | * Revision 2.0 1995/11/30 04:54:29 pavel 81 | * New baseline version, corresponding to release 1.8.0alpha1. 82 | * 83 | * Revision 1.2 1992/10/23 23:03:47 pavel 84 | * Added copyright notice. 85 | * 86 | * Revision 1.1 1992/07/20 23:23:12 pavel 87 | * Initial RCS-controlled version. 88 | */ 89 | -------------------------------------------------------------------------------- /net_mp_selct.c: -------------------------------------------------------------------------------- 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 "net_mplex.h" 21 | 22 | #include /* errno */ 23 | #include "my-string.h" /* bzero() or memset(), used in FD_ZERO */ 24 | #include "my-sys-time.h" /* select(), struct timeval */ 25 | #include "my-types.h" /* fd_set, FD_ZERO(), FD_SET(), FD_ISSET() */ 26 | 27 | #include "log.h" 28 | 29 | static fd_set input, output; 30 | static int max_descriptor; 31 | 32 | void 33 | mplex_clear(void) 34 | { 35 | FD_ZERO(&input); 36 | FD_ZERO(&output); 37 | max_descriptor = -1; 38 | } 39 | 40 | void 41 | mplex_add_reader(int fd) 42 | { 43 | FD_SET(fd, &input); 44 | if (fd > max_descriptor) 45 | max_descriptor = fd; 46 | } 47 | 48 | void 49 | mplex_add_writer(int fd) 50 | { 51 | FD_SET(fd, &output); 52 | if (fd > max_descriptor) 53 | max_descriptor = fd; 54 | } 55 | 56 | int 57 | mplex_wait(unsigned timeout) 58 | { 59 | struct timeval tv; 60 | int n; 61 | 62 | tv.tv_sec = timeout; 63 | tv.tv_usec = 0; 64 | 65 | n = select(max_descriptor + 1, (void *) &input, (void *) &output, 0, &tv); 66 | 67 | if (n < 0) { 68 | if (errno != EINTR) 69 | log_perror("Waiting for network I/O"); 70 | return 1; 71 | } else 72 | return (n == 0); 73 | } 74 | 75 | int 76 | mplex_is_readable(int fd) 77 | { 78 | return FD_ISSET(fd, &input); 79 | } 80 | 81 | int 82 | mplex_is_writable(int fd) 83 | { 84 | return FD_ISSET(fd, &output); 85 | } 86 | 87 | 88 | /* 89 | * $Log$ 90 | * Revision 2.1 1996/02/08 06:36:22 pavel 91 | * Updated copyright notice for 1996. Release 1.8.0beta1. 92 | * 93 | * Revision 2.0 1995/11/30 04:45:48 pavel 94 | * New baseline version, corresponding to release 1.8.0alpha1. 95 | * 96 | * Revision 1.3 1992/10/23 23:03:47 pavel 97 | * Added copyright notice. 98 | * 99 | * Revision 1.2 1992/10/23 19:38:51 pavel 100 | * Added missing #include of my-string.h. 101 | * 102 | * Revision 1.1 1992/09/23 17:14:17 pavel 103 | * Initial RCS-controlled version. 104 | */ 105 | -------------------------------------------------------------------------------- /my-socket.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 My_Socket_H 19 | #define My_Socket_H 1 20 | 21 | #include "config.h" 22 | 23 | #if SYS_SOCKET_H_NEEDS_HELP 24 | /* Some systems aren't sufficiently careful about headers including the other 25 | * headers that they depend upon... 26 | */ 27 | #include "my-types.h" 28 | #endif 29 | 30 | #include 31 | 32 | #if NDECL_ACCEPT 33 | extern int accept(int, struct sockaddr *, int *); 34 | extern int listen(int, int); 35 | extern int setsockopt(int, int, int, const char *, int); 36 | extern int socket(int, int, int); 37 | #endif 38 | 39 | #if NDECL_BIND 40 | extern int bind(int, struct sockaddr *, int); 41 | extern int getsockname(int, struct sockaddr *, int *); 42 | extern int connect(int, struct sockaddr *, int); 43 | #endif 44 | 45 | #if NDECL_SHUTDOWN 46 | extern int shutdown(int, int); 47 | #endif 48 | 49 | #endif /* !My_Socket_H */ 50 | 51 | /* 52 | * $Log$ 53 | * Revision 2.2 1996/02/08 06:02:39 pavel 54 | * Updated copyright notice for 1996. Release 1.8.0beta1. 55 | * 56 | * Revision 2.1 1995/12/31 03:24:41 pavel 57 | * Added getsockname(). Release 1.8.0alpha4. 58 | * 59 | * Revision 2.0 1995/11/30 04:58:09 pavel 60 | * New baseline version, corresponding to release 1.8.0alpha1. 61 | * 62 | * Revision 1.8 1993/08/03 21:41:53 pavel 63 | * Broke out bind() and connect() for a separate NDECL test. 64 | * 65 | * Revision 1.7 1992/10/23 23:03:47 pavel 66 | * Added copyright notice. 67 | * 68 | * Revision 1.6 1992/10/21 03:02:35 pavel 69 | * Converted to use new automatic configuration system. 70 | * 71 | * Revision 1.5 1992/10/17 20:36:37 pavel 72 | * Added some more system-dependent #if's. 73 | * 74 | * Revision 1.4 1992/10/06 01:34:00 pavel 75 | * Added SGI and AIX to the list of losers who don't #include the right things 76 | * from inside their own header files. 77 | * 78 | * Revision 1.3 1992/09/23 22:35:52 pavel 79 | * Added conditional #include of "my-types.h", for systems that need it. 80 | * 81 | * Revision 1.2 1992/08/31 22:26:43 pjames 82 | * Changed some `char *'s to `const char *' 83 | * 84 | * Revision 1.1 1992/07/20 23:23:12 pavel 85 | * Initial RCS-controlled version. 86 | */ 87 | -------------------------------------------------------------------------------- /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 "keywords.h" 21 | 22 | #include "tokens.h" 23 | 24 | %} 25 | struct keyword {}; /* bogus decl not copied into the output */ 26 | %% 27 | if, DBV_Prehistory, tIF, -1 28 | else, DBV_Prehistory, tELSE, -1 29 | elseif, DBV_Prehistory, tELSEIF, -1 30 | endif, DBV_Prehistory, tENDIF, -1 31 | for, DBV_Prehistory, tFOR, -1 32 | in, DBV_Prehistory, tIN, -1 33 | endfor, DBV_Prehistory, tENDFOR, -1 34 | fork, DBV_Prehistory, tFORK, -1 35 | endfork, DBV_Prehistory, tENDFORK, -1 36 | return, DBV_Prehistory, tRETURN, -1 37 | while, DBV_Prehistory, tWHILE, -1 38 | endwhile, DBV_Prehistory, tENDWHILE, -1 39 | try, DBV_Exceptions, tTRY, -1 40 | except, DBV_Exceptions, tEXCEPT, -1 41 | finally, DBV_Exceptions, tFINALLY, -1 42 | endtry, DBV_Exceptions, tENDTRY, -1 43 | ANY, DBV_Exceptions, tANY, -1 44 | break, DBV_BreakCont, tBREAK, -1 45 | continue, DBV_BreakCont, tCONTINUE, -1 46 | E_NONE, DBV_Prehistory, tERROR, E_NONE 47 | E_TYPE, DBV_Prehistory, tERROR, E_TYPE 48 | E_DIV, DBV_Prehistory, tERROR, E_DIV 49 | E_PERM, DBV_Prehistory, tERROR, E_PERM 50 | E_PROPNF, DBV_Prehistory, tERROR, E_PROPNF 51 | E_VERBNF, DBV_Prehistory, tERROR, E_VERBNF 52 | E_VARNF, DBV_Prehistory, tERROR, E_VARNF 53 | E_INVIND, DBV_Prehistory, tERROR, E_INVIND 54 | E_RECMOVE, DBV_Prehistory, tERROR, E_RECMOVE 55 | E_MAXREC, DBV_Prehistory, tERROR, E_MAXREC 56 | E_RANGE, DBV_Prehistory, tERROR, E_RANGE 57 | E_ARGS, DBV_Prehistory, tERROR, E_ARGS 58 | E_NACC, DBV_Prehistory, tERROR, E_NACC 59 | E_INVARG, DBV_Prehistory, tERROR, E_INVARG 60 | E_QUOTA, DBV_Prehistory, tERROR, E_QUOTA 61 | E_FLOAT, DBV_Float, tERROR, E_FLOAT 62 | %% 63 | 64 | 65 | /* 66 | * $Log$ 67 | * Revision 2.2 1996/02/08 06:33:21 pavel 68 | * Added `break', `continue', and E_FLOAT. Updated copyright notice for 1996. 69 | * Release 1.8.0beta1. 70 | * 71 | * Revision 2.1 1995/12/11 08:15:42 pavel 72 | * Added #include "tokens.h" removed from keywords.h. Release 1.8.0alpha2. 73 | * 74 | * Revision 2.0 1995/11/30 05:02:56 pavel 75 | * New baseline version, corresponding to release 1.8.0alpha1. 76 | * 77 | * Revision 1.1 1995/11/30 05:01:47 pavel 78 | * Initial revision 79 | */ 80 | -------------------------------------------------------------------------------- /README.Minimal: -------------------------------------------------------------------------------- 1 | Instructions on using Minimal.db 2 | ------------ -- ----- ---------- 3 | 4 | The Minimal database is really quite minimal; there are no commands defined 5 | other than the built-in ones (`PREFIX', `SUFFIX', and `.program') and only 6 | enough verbs defined and/or programmed to make it possible to bootstrap. It's 7 | almost a certainty that you'd better off starting from the most recent release 8 | of the LambdaCore database and possibly trimming things from that. Some people 9 | can't resist a challenge, though, so this document exists to orient them to the 10 | meager contents of the Minimal database. 11 | 12 | There are four objects in the Minimal database, arranged in the parent/child 13 | hierarchy as follows: 14 | 15 | Root Class (#1) 16 | System Object (#0) 17 | The First Room (#2) 18 | Wizard (#3) 19 | 20 | The System Object has one defined verb, #0:do_login_command, which simply 21 | returns #3. This has the effect that all connections to the Minimal database 22 | are automatically logged-in to Wizard, the only player. 23 | 24 | The First Room has a verb named `eval' defined but not yet programmed. It has 25 | arguments `any any any' and permissions `rxd'. 26 | 27 | The Wizard is initially located in the First Room and the other three objects 28 | are initially located in #-1 (i.e., nowhere). 29 | 30 | There are no other properties or verbs defined in the database. There are no 31 | forked or suspended tasks either. 32 | 33 | The only way to get started in the Minimal database is either to change the 34 | program for #0:do_login_command to perform some useful task (probably a more 35 | tedious way to go, since you'd have to reconnect to get that verb to run), or 36 | to provide a useful definition for `#2:eval' (probably the right course, since 37 | you can invoke that more easily). 38 | 39 | Of course, there are no restrictions on what you make this `eval' verb do, but 40 | I recommend that you implement a simple, general MOO-code expression evaluator, 41 | perhaps using code like this: 42 | 43 | .program here:eval 44 | notify(player, toliteral(eval("return " + argstr + ";")[2])); 45 | . 46 | 47 | Or, perhaps something a tad fancier, to help you diagnose syntax errors more 48 | easily: 49 | 50 | .program here:eval 51 | answer = eval("return " + argstr + ";"); 52 | if (answer[1]) 53 | notify(player, tostr("=> ", toliteral(answer[2]))); 54 | else 55 | for line in (answer[2]) 56 | notify(player, line); 57 | endfor 58 | endif 59 | . 60 | 61 | Of course, much fancier `eval' verbs are possible, but you'll discover them for 62 | yourself, I'm sure. 63 | 64 | From such a basis, you can do anything by using the various built-in functions 65 | directly, like add_verb(), add_property(), etc. With sufficient amounts of 66 | work, you can build up a set of easier-to-use command-line interfaces to these 67 | facilities to make programming and building much easier. 68 | 69 | If you should decide, after reading this, to build up an interesting database 70 | starting from the Minimal one, and you succeed in doing so, please drop me a 71 | line; I'd love to hear about it. 72 | 73 | Pavel Curtis 74 | aka Haakon, ArchWizard of LambdaMOO 75 | Pavel@PARC.Xerox.Com 76 | -------------------------------------------------------------------------------- /my-types.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 My_Types_H 19 | #define My_Types_H 1 20 | 21 | #include "config.h" 22 | 23 | /* The Linux manpage for select indicates that sys/time.h is necessary 24 | for the FD_ZERO et al declarations. If this causes problems on 25 | other systems, we'll have to put this into autoconf. --Jay */ 26 | 27 | #include 28 | 29 | #include 30 | 31 | #if NEED_BSDTYPES_H 32 | #include 33 | #endif 34 | 35 | #ifndef FD_ZERO 36 | #define NFDBITS (sizeof(fd_set)*8) 37 | #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 38 | #define FD_SET(n, p) ((p)->fds_bits[0] |= (1L<<((n)%NFDBITS))) 39 | #define FD_ISSET(n, p) ((p)->fds_bits[0] & (1L<<((n)%NFDBITS))) 40 | #endif /* FD_ZERO */ 41 | 42 | #endif /* !My_Types_H */ 43 | 44 | /* 45 | * $Log$ 46 | * Revision 2.1 1996/02/08 06:00:13 pavel 47 | * Updated copyright notice for 1996. Release 1.8.0beta1. 48 | * 49 | * Revision 2.0 1995/11/30 04:59:47 pavel 50 | * New baseline version, corresponding to release 1.8.0alpha1. 51 | * 52 | * Revision 1.11 1992/10/23 23:03:47 pavel 53 | * Added copyright notice. 54 | * 55 | * Revision 1.10 1992/10/23 19:35:43 pavel 56 | * Moved bzero declaration to my-string.h. 57 | * 58 | * Revision 1.9 1992/10/21 03:02:35 pavel 59 | * Converted to use new automatic configuration system. 60 | * 61 | * Revision 1.8 1992/10/17 20:41:53 pavel 62 | * Added some more system-dependent #if's. 63 | * 64 | * Revision 1.7 1992/09/27 19:27:19 pavel 65 | * Added declaration of mode_t for non-POSIX systems. 66 | * 67 | * Revision 1.6 1992/09/23 17:15:03 pavel 68 | * Moved declaration of bzero (for SunOS) to here from net_multi.c. 69 | * 70 | * Revision 1.5 1992/09/21 17:43:16 pavel 71 | * Added missing #include of "config.h". 72 | * 73 | * Revision 1.4 1992/08/31 23:42:15 pavel 74 | * Changed to conditionalize on FD_ZERO rather than AUX for the fd_set macros. 75 | * 76 | * Revision 1.3 1992/08/21 00:45:50 pavel 77 | * Changed to conditionalize on the option AVOID_POSIX rather than USE_POSIX. 78 | * 79 | * Revision 1.2 1992/07/30 00:39:05 pavel 80 | * Add support for compiling on RISC/os 4.52 and NonStop-UX A22. 81 | * 82 | * Revision 1.1 1992/07/20 23:23:12 pavel 83 | * Initial RCS-controlled version. 84 | */ 85 | -------------------------------------------------------------------------------- /my-unistd.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 My_UniStd_H 19 | #define My_UniStd_H 1 20 | 21 | #include "config.h" 22 | 23 | #if HAVE_UNISTD_H && !NDECL_FORK 24 | 25 | #include 26 | 27 | #else 28 | 29 | #include "my-types.h" 30 | 31 | extern unsigned alarm(unsigned); 32 | extern int chmod(const char *, mode_t); 33 | extern int close(int); 34 | extern int dup(int); 35 | extern void _exit(int); 36 | extern pid_t fork(void); 37 | extern pid_t getpid(void); 38 | extern int link(const char *, const char *); 39 | extern int pause(void); 40 | extern int pipe(int *fds); 41 | extern int read(int, void *, unsigned); 42 | extern unsigned sleep(unsigned); 43 | extern int unlink(const char *); 44 | extern int write(int, const void *, unsigned); 45 | extern int fsync(int); 46 | 47 | #endif 48 | 49 | #endif /* !My_UniStd_H */ 50 | 51 | /* 52 | * $Log$ 53 | * Revision 2.1 1996/02/08 06:00:01 pavel 54 | * Updated copyright notice for 1996. Release 1.8.0beta1. 55 | * 56 | * Revision 2.0 1995/11/30 04:59:57 pavel 57 | * New baseline version, corresponding to release 1.8.0alpha1. 58 | * 59 | * Revision 1.11 1992/10/23 23:03:47 pavel 60 | * Added copyright notice. 61 | * 62 | * Revision 1.10 1992/10/23 19:37:01 pavel 63 | * Added support for systems that have , but still don't declare 64 | * most of the functions in it... 65 | * 66 | * Revision 1.9 1992/10/21 03:02:35 pavel 67 | * Converted to use new automatic configuration system. 68 | * 69 | * Revision 1.8 1992/10/17 20:42:25 pavel 70 | * Added declarations of link() and unlink(). 71 | * 72 | * Revision 1.7 1992/09/27 19:30:09 pavel 73 | * Added declarations of chmod() and pipe() for non-POSIX systems. 74 | * 75 | * Revision 1.6 1992/09/21 17:08:59 pavel 76 | * Added missing #include of config.h. 77 | * 78 | * Revision 1.5 1992/09/03 23:53:33 pavel 79 | * Added declaration for sleep(). 80 | * 81 | * Revision 1.4 1992/08/31 22:26:21 pjames 82 | * Changed some `char *'s to `const char *' 83 | * 84 | * Revision 1.3 1992/08/21 00:46:08 pavel 85 | * Changed to conditionalize on the option AVOID_POSIX rather than USE_POSIX. 86 | * 87 | * Revision 1.2 1992/08/13 23:19:46 pavel 88 | * Added declaration for dup()... 89 | * 90 | * Revision 1.1 1992/07/20 23:23:12 pavel 91 | * Initial RCS-controlled version. 92 | */ 93 | -------------------------------------------------------------------------------- /net_mp_poll.c: -------------------------------------------------------------------------------- 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 "net_mplex.h" 21 | 22 | #include 23 | #include "my-poll.h" 24 | 25 | #include "log.h" 26 | #include "storage.h" 27 | 28 | typedef struct pollfd Port; 29 | 30 | static Port *ports = 0; 31 | static int num_ports = 0; 32 | static int max_fd; 33 | 34 | void 35 | mplex_clear(void) 36 | { 37 | int i; 38 | 39 | max_fd = 0; 40 | for (i = 0; i < num_ports; i++) { 41 | ports[i].fd = -1; 42 | ports[i].events = 0; 43 | } 44 | } 45 | 46 | static void 47 | add_common(int fd, unsigned dir) 48 | { 49 | if (fd >= num_ports) { /* Grow ports array */ 50 | int new_num = (fd + 9) / 10 * 10 + 1; 51 | Port *new_ports = mymalloc(new_num * sizeof(Port), M_NETWORK); 52 | int i; 53 | 54 | for (i = 0; i < num_ports; i++) 55 | new_ports[i] = ports[i]; 56 | 57 | if (ports != 0) 58 | myfree(ports, M_NETWORK); 59 | 60 | ports = new_ports; 61 | num_ports = new_num; 62 | } 63 | ports[fd].fd = fd; 64 | ports[fd].events |= dir; 65 | if (fd > max_fd) 66 | max_fd = fd; 67 | } 68 | 69 | void 70 | mplex_add_reader(int fd) 71 | { 72 | add_common(fd, POLLIN); 73 | } 74 | 75 | void 76 | mplex_add_writer(int fd) 77 | { 78 | add_common(fd, POLLOUT); 79 | } 80 | 81 | int 82 | mplex_wait(unsigned timeout) 83 | { 84 | int result = poll(ports, max_fd + 1, timeout * 1000); 85 | 86 | if (result < 0) { 87 | if (errno != EINTR) 88 | log_perror("Waiting for network I/O"); 89 | return 1; 90 | } else 91 | return (result == 0); 92 | } 93 | 94 | int 95 | mplex_is_readable(int fd) 96 | { 97 | return fd <= max_fd && (ports[fd].revents & (POLLIN | POLLHUP)) != 0; 98 | } 99 | 100 | int 101 | mplex_is_writable(int fd) 102 | { 103 | return fd <= max_fd && (ports[fd].revents & POLLOUT) != 0; 104 | } 105 | 106 | 107 | /* 108 | * $Log$ 109 | * Revision 2.1 1996/02/08 06:36:15 pavel 110 | * Updated copyright notice for 1996. Release 1.8.0beta1. 111 | * 112 | * Revision 2.0 1995/11/30 04:46:12 pavel 113 | * New baseline version, corresponding to release 1.8.0alpha1. 114 | * 115 | * Revision 1.2 1992/10/23 23:03:47 pavel 116 | * Added copyright notice. 117 | * 118 | * Revision 1.1 1992/10/03 00:52:26 pavel 119 | * Initial RCS-controlled version. 120 | */ 121 | -------------------------------------------------------------------------------- /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 | 73 | /* 74 | * $Log$ 75 | * Revision 2.1 1996/02/08 06:18:23 pavel 76 | * Updated copyright notice for 1996. Release 1.8.0beta1. 77 | * 78 | * Revision 2.0 1995/11/30 04:53:08 pavel 79 | * New baseline version, corresponding to release 1.8.0alpha1. 80 | * 81 | * Revision 1.2 1992/10/23 23:03:47 pavel 82 | * Added copyright notice. 83 | * 84 | * Revision 1.1 1992/09/23 17:14:17 pavel 85 | * Initial RCS-controlled version. 86 | */ 87 | -------------------------------------------------------------------------------- /my-stdio.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 My_StdIO_H 19 | #define My_StdIO_H 1 20 | 21 | #include "config.h" 22 | 23 | #include 24 | #include 25 | 26 | #if NDECL_FCLOSE 27 | #include "my-types.h" 28 | 29 | extern int fclose(FILE *); 30 | extern int fflush(FILE *); 31 | extern int fileno(FILE *); 32 | extern size_t fwrite(const void *, size_t, size_t, FILE *); 33 | extern int fgetc(FILE *); 34 | extern int fprintf(FILE *, const char *,...); 35 | extern int fscanf(FILE *, const char *,...); 36 | extern int sscanf(const char *, const char *,...); 37 | extern int printf(const char *,...); 38 | extern int ungetc(int, FILE *); 39 | #endif 40 | 41 | #if NDECL_PERROR 42 | extern void perror(const char *); 43 | #endif 44 | 45 | #if NDECL_REMOVE 46 | extern int remove(const char *); 47 | extern int rename(const char *, const char *); 48 | #endif 49 | 50 | #if NDECL_VFPRINTF 51 | #include "my-stdarg.h" 52 | 53 | extern int vfprintf(FILE *, const char *, va_list); 54 | extern int vfscanf(FILE *, const char *, va_list); 55 | #endif 56 | 57 | #if !HAVE_REMOVE 58 | # include "my-unistd.h" 59 | # define remove(x) unlink(x) 60 | #endif 61 | 62 | #if !HAVE_RENAME 63 | # include "my-unistd.h" 64 | # define rename(old, new) (link(old, new) && unlink(old)) 65 | #endif 66 | 67 | #endif /* !My_StdIO_H */ 68 | 69 | /* 70 | * $Log$ 71 | * Revision 2.2 1996/02/08 06:02:04 pavel 72 | * Updated copyright notice for 1996. Release 1.8.0beta1. 73 | * 74 | * Revision 2.1 1996/01/11 07:44:48 pavel 75 | * Added declaration for fwrite(). Release 1.8.0alpha5. 76 | * 77 | * Revision 2.0 1995/11/30 04:58:44 pavel 78 | * New baseline version, corresponding to release 1.8.0alpha1. 79 | * 80 | * Revision 1.7 1992/10/28 01:58:05 pavel 81 | * Changed NDECL_VPRINTF to NDECL_VFPRINTF, which is the one we care about... 82 | * 83 | * Revision 1.6 1992/10/23 23:03:47 pavel 84 | * Added copyright notice. 85 | * 86 | * Revision 1.5 1992/10/23 19:30:14 pavel 87 | * Split up the declarations into four equivalence classes instead of just one. 88 | * 89 | * Revision 1.4 1992/10/21 03:02:35 pavel 90 | * Converted to use new automatic configuration system. 91 | * 92 | * Revision 1.3 1992/10/17 20:37:59 pavel 93 | * Added support for systems that lack rename() and/or remove(). 94 | * 95 | * Revision 1.2 1992/09/03 23:53:10 pavel 96 | * Added declaration for printf(). 97 | * 98 | * Revision 1.1 1992/07/20 23:23:12 pavel 99 | * Initial RCS-controlled version. 100 | */ 101 | -------------------------------------------------------------------------------- /exceptions.c: -------------------------------------------------------------------------------- 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 | /* Copyright 1989 Digital Equipment Corporation. */ 19 | /* Distributed only by permission. */ 20 | /*****************************************************************************/ 21 | /* File: exceptions.c */ 22 | /* Taken originally from: */ 23 | /* Implementing Exceptions in C */ 24 | /* Eric S. Roberts */ 25 | /* Research Report #40 */ 26 | /* DEC Systems Research Center */ 27 | /* March 21, 1989 */ 28 | /* Modified slightly by Pavel Curtis for use in the LambdaMOO server code. */ 29 | /* ------------------------------------------------------------------------- */ 30 | /* Implementation of the C exception handler. Most of the real work is */ 31 | /* done in the macros defined in the exceptions.h header file. */ 32 | /*****************************************************************************/ 33 | 34 | #include 35 | 36 | #include "exceptions.h" 37 | 38 | ES_CtxBlock *ES_exceptionStack = 0; 39 | 40 | Exception ANY; 41 | 42 | void 43 | ES_RaiseException(Exception * exception, int value) 44 | { 45 | ES_CtxBlock *cb, *xb; 46 | int i; 47 | 48 | for (xb = ES_exceptionStack; xb; xb = xb->link) { 49 | for (i = 0; i < xb->nx; i++) { 50 | if (xb->array[i] == exception || xb->array[i] == &ANY) 51 | goto doneSearching; 52 | } 53 | } 54 | 55 | doneSearching: 56 | if (!xb) 57 | panic("Unhandled exception!"); 58 | 59 | for (cb = ES_exceptionStack; cb != xb && !cb->finally; cb = cb->link); 60 | ES_exceptionStack = cb; 61 | cb->id = exception; 62 | cb->value = value; 63 | longjmp((void *) cb->jmp, 1); 64 | } 65 | 66 | 67 | /* 68 | * $Log$ 69 | * Revision 2.1 1996/02/08 07:11:32 pavel 70 | * Updated copyright notice for 1996. Release 1.8.0beta1. 71 | * 72 | * Revision 2.0 1995/11/30 04:23:03 pavel 73 | * New baseline version, corresponding to release 1.8.0alpha1. 74 | * 75 | * Revision 1.3 1992/10/23 23:03:47 pavel 76 | * Added copyright notice. 77 | * 78 | * Revision 1.2 1992/07/21 00:01:23 pavel 79 | * Added rcsid_ declaration to hold the RCS ident. string. 80 | * 81 | * Revision 1.1 1992/07/20 23:23:12 pavel 82 | * Initial RCS-controlled version. 83 | */ 84 | -------------------------------------------------------------------------------- /ac_include/moo_git.m4: -------------------------------------------------------------------------------- 1 | dnl -*- autoconf -*- 2 | dnl 3 | # ----------------------------------------- 4 | # MOO_PROG_GIT 5 | # Checks for git being installed (moo_prog_cv_git = 'yes|no') 6 | # Checks if $srcdir is a git repo (moo_git_cv_repo = 'yes|no') 7 | AC_DEFUN([MOO_PROG_GIT], 8 | [AC_CACHE_CHECK([git],[moo_prog_cv_git],[[ 9 | moo_git_zerohash=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 10 | moo_git_cv_repo=no 11 | if test `git hash-object --stdin /dev/null 2>&1) ; then 14 | moo_git_cv_repo=yes 15 | fi 16 | else 17 | moo_prog_cv_git=no 18 | fi 19 | ]]) 20 | AC_CACHE_CHECK([for git repository],[moo_git_cv_repo],[])]) 21 | 22 | # ----------------------------------------------------------- 23 | # MOO_PROG_SHA1GIT_HASH 24 | # Find a file hashing function, preferring 'git hash-object' 25 | # Sets moo_prog_cv_sha1git_hash = 26 | # git => use 'git hash-object' 27 | # sha1?sum => use that 28 | # no => nothing available 29 | # In the first two cases, sets moo_git_hash_body to 30 | # something that produces the same result as 'git hash-object' 31 | # 32 | AC_DEFUN([MOO_PROG_SHA1GIT_HASH], 33 | [AC_REQUIRE([MOO_PROG_GIT])dnl 34 | AC_CACHE_CHECK([how to do git hash],[moo_prog_cv_sha1git_hash],[[ 35 | if test "$moo_prog_cv_git" = yes ; then 36 | moo_prog_cv_sha1git_hash=git 37 | elif test `printf "blob 0\000" | shasum | tr -d ' -' 2<&1` = "$moo_git_zerohash"; then 38 | moo_prog_cv_sha1git_hash=shasum 39 | elif test `printf "blob 0\000" | sha1sum | tr -d ' -' 2<&1` = "$moo_git_zerohash"; then 40 | moo_prog_cv_sha1git_hash=sha1sum 41 | else 42 | moo_prog_cv_sha1git_hash=no 43 | fi]]) 44 | AS_CASE([$moo_prog_cv_sha1git_hash],[[ 45 | git]],[[ 46 | moo_git_hash_body='git hash-object "$][1"' 47 | ]],[[ 48 | shasum | sha1sum]],[[ 49 | moo_git_hash_body='_moo_a=`cat $][1`] 50 | AS_VAR_ARITH([_moo_b],[[ 1 + ${@%:@_moo_a} ]])[ 51 | printf "blob %d\000%s\n" $_moo_b "${_moo_a}" | '$moo_prog_cv_sha1git_hash' | tr -d '"' -'" 52 | ]],[[ 53 | moo_git_hash_body=']AC_MSG_ERROR([no sha1 hash avaiable])[' 54 | ]])]) 55 | 56 | # ----------------------------------------- 57 | # MOO_GIT_TREE_HASH(FILE_HASH) 58 | # given that 'FILE_HASH file' hashes a single file, 59 | # use git to compute a hash of all differences in the working tree 60 | # (or '?unmerged?' if a merge is unresolved, 61 | # or nothing if there are no changes from the most recent commit) 62 | AC_DEFUN([MOO_GIT_TREE_HASH], 63 | [[ moo_dfile=$tmp/moo_vdiff.tmp 64 | rm -f "$moo_dfile" 65 | (cd $ac_top_srcdir ; git diff-index --no-abbrev --no-renames HEAD ) | { 66 | moo_changed=false 67 | while : ; do 68 | while read _ _ _ moo_hash moo_UMAD moo_file ; do 69 | moo_changed=:] 70 | AS_CASE([$moo_UMAD],[[ 71 | U]],[[ 72 | # unfinished merge; this make is destined to fail 73 | printf "?unmerged?" 74 | break 2 75 | ]],[[ 76 | D]],[[ 77 | # deleted file; no contents to hash 78 | printf "%s\n" "|$moo_file| deleted" >>"$moo_dfile" 79 | ]],[[ 80 | if test "$moo_hash" = 0000000000000000000000000000000000000000 ; then 81 | # not yet hashed; need to do it ourselves 82 | ]$1[ "$srcdir/$moo_file" >>"$moo_dfile" 83 | else 84 | printf "%s\n" "$moo_hash" >>"$moo_dfile" 85 | fi 86 | ]])[ 87 | done 88 | if $moo_changed ; then 89 | ]$1[ "$moo_dfile" 90 | fi 91 | break 92 | done 93 | } 94 | rm -f "$moo_dfile"]]) 95 | -------------------------------------------------------------------------------- /ac_include/moo_sys_ancient.m4: -------------------------------------------------------------------------------- 1 | dnl -*- autoconf -*- 2 | # 3 | # various tweaks for various ancient platforms. 4 | # 5 | # *************************************************************************** 6 | # MOO_AUX 7 | # Defines _POSIX_SOURCE if this machine is running A/UX; this appears to be 8 | # necessary in order to get declarations of POSIX functions. 9 | AC_DEFUN([MOO_AUX], 10 | [AC_CACHE_CHECK([for A/UX],[moo_sys_cv_a_ux], 11 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 12 | #if !defined(AUX) 13 | #emote not seeing aux 14 | #endif 15 | ]])],[moo_sys_cv_a_ux=yes],[moo_sys_cv_a_ux=no])])[ 16 | test "$moo_sys_cv_a_ux" = yes &&] 17 | AC_DEFINE([_POSIX_SOURCE],[1]) 18 | ])dnl 19 | dnl 20 | # *************************************************************************** 21 | # MOO_HPUX 22 | # Defines _HPUX_SOURCE if this machine is running HP/UX; this appears to be 23 | # necessary in order to get declarations of POSIX functions. 24 | AC_DEFUN([MOO_HPUX], 25 | [AC_CACHE_CHECK([for HP/UX],[moo_sys_cv_hp_ux], 26 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 27 | #if !defined(__hpux) 28 | #emote not seeing hpux 29 | #endif 30 | ]])],[moo_sys_cv_hp_ux=yes],[moo_sys_cv_hp_ux=no])])[ 31 | test "$moo_sys_cv_hp_ux" = yes &&] 32 | AC_DEFINE([_HPUX_SOURCE],[1]) 33 | ])dnl 34 | dnl 35 | dnl 36 | # *************************************************************************** 37 | # MOO_ALPHA 38 | # If this machine is a DEC Alpha running OSF/1, and we're not using GCC, then 39 | # add `-Olimit 1000' to the `cc' switches, to allow the compiler to run the 40 | # optimizer over large functions, like the main MOO interpreter loop. 41 | AC_DEFUN([MOO_ALPHA], 42 | [AC_CACHE_CHECK([for the DEC Alpha running OSF/1],[moo_sys_cv_dec_alpha], 43 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 44 | #if !(defined(__osf__) && defined(__alpha) && !defined(__GNUC__)) 45 | #emote not an alpha 46 | #endif 47 | ]])],[moo_sys_cv_dec_alpha=yes],[moo_sys_cv_dec_alpha=no])])[ 48 | test "$moo_sys_cv_dec_alpha" = yes && CFLAGS="$CFLAGS -Olimit 2500" 49 | ]])dnl 50 | dnl 51 | # *************************************************************************** 52 | # MOO_SGI 53 | # If this machine is an SGI running IRIX, and we're not using GCC, then 54 | # add `-Olimit 2500' to the `cc' switches, to allow the compiler to run the 55 | # optimizer over large functions, like the main MOO interpreter loop. Also, 56 | # even if we are using GCC, undefine __EXTENSIONS__ to keep from seeing a 57 | # bunch of interfering declarations. 58 | AC_DEFUN([MOO_SGI], 59 | [AC_CACHE_CHECK([for the SGI compiler],[moo_sys_cv_sgi], 60 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 61 | #if !(defined(sgi) && !defined(__GNUC__)) 62 | #emote not an sgi or running gnucc 63 | #endif 64 | ]])], [[moo_sys_cv_sgi=yes]], 65 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 66 | #if !defined(sgi) 67 | #emote not an sgi 68 | #endif 69 | ]])], [[moo_sys_cv_sgi=gcc]], [[moo_sys_cv_sgi=no]])])])[ 70 | test "$moo_sys_cv_sgi" = yes && CFLAGS="$CFLAGS -Olimit 2500" 71 | test "$moo_sys_cv_sgi" = no || CFLAGS="$CFLAGS -U__EXTENSIONS__" 72 | ]])dnl 73 | dnl 74 | # *************************************************************************** 75 | # MOO_NEXT 76 | # On NeXT, we need to make sure that _NEXT_SOURCE and _POSIX_SOURCE are 77 | # defined. 78 | AC_DEFUN([MOO_NEXT], 79 | [AC_CACHE_CHECK([for NeXT],[moo_sys_cv_next], 80 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 81 | #ifndef NeXT 82 | #emote not a next 83 | #endif 84 | ]])],[[moo_sys_cv_next=yes]],[[moo_sys_cv_next=no]])])[ 85 | if test "x$moo_sys_cv_next" = xyes ; then] 86 | AC_DEFINE([_NEXT_SOURCE]) 87 | AC_DEFINE([_POSIX_SOURCE])[ 88 | fi]])dnl 89 | dnl 90 | -------------------------------------------------------------------------------- /client_bsd.c: -------------------------------------------------------------------------------- 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 | /* BSD/LOCAL MUD client */ 19 | 20 | #include "config.h" 21 | #include "options.h" 22 | 23 | #include 24 | #include "my-socket.h" 25 | #include "my-stdio.h" 26 | #include "my-stdlib.h" 27 | #include "my-string.h" 28 | #include "my-sys-time.h" 29 | #include 30 | #include "my-types.h" 31 | #include "my-unistd.h" 32 | 33 | int 34 | main(int argc, char **argv) 35 | { 36 | const char *connect_file = DEFAULT_CONNECT_FILE; 37 | int s; 38 | struct sockaddr_un address; 39 | 40 | if (argc == 2) 41 | connect_file = argv[1]; 42 | else if (argc != 1) { 43 | fprintf(stderr, "Usage: %s [server-connect-file]\n", argv[0]); 44 | exit(1); 45 | } 46 | if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { 47 | perror("socket"); 48 | exit(1); 49 | } 50 | address.sun_family = AF_UNIX; 51 | strcpy(address.sun_path, connect_file); 52 | 53 | if (connect(s, (struct sockaddr *) &address, 54 | sizeof(address.sun_family) + strlen(connect_file)) < 0) { 55 | perror("connect"); 56 | exit(1); 57 | } 58 | while (1) { 59 | fd_set input; 60 | char buffer[1024]; 61 | 62 | FD_ZERO(&input); 63 | FD_SET(0, &input); 64 | FD_SET(s, &input); 65 | 66 | if (select(s + 1, (void *) &input, 0, 0, 0) < 0) { 67 | if (errno != EINTR) { 68 | perror("select"); 69 | exit(1); 70 | } 71 | } else { 72 | if (FD_ISSET(0, &input)) 73 | write(s, buffer, read(0, buffer, sizeof(buffer))); 74 | if (FD_ISSET(s, &input)) { 75 | int count = read(s, buffer, sizeof(buffer)); 76 | 77 | if (count == 0) 78 | break; 79 | write(1, buffer, count); 80 | } 81 | } 82 | } 83 | 84 | exit(0); 85 | } 86 | 87 | 88 | /* 89 | * $Log$ 90 | * Revision 2.2 1996/03/10 01:11:49 pavel 91 | * Moved definition of DEFAULT_CONNECT_FILE to options.h. Release 1.8.0. 92 | * 93 | * Revision 2.1 1996/02/08 06:33:46 pavel 94 | * Updated copyright notice for 1996. Release 1.8.0beta1. 95 | * 96 | * Revision 2.0 1995/11/30 04:47:38 pavel 97 | * New baseline version, corresponding to release 1.8.0alpha1. 98 | * 99 | * Revision 1.5 1992/10/23 23:03:47 pavel 100 | * Added copyright notice. 101 | * 102 | * Revision 1.4 1992/10/21 03:02:35 pavel 103 | * Converted to use new automatic configuration system. 104 | * 105 | * Revision 1.3 1992/10/17 20:17:13 pavel 106 | * Fix up connect_file defaulting, to eliminate warnings from naive compilers. 107 | * 108 | * Revision 1.2 1992/10/06 18:15:34 pavel 109 | * Added missing #include of my-stdlib.h, for exit(). 110 | * 111 | * Revision 1.1 1992/09/23 22:35:05 pavel 112 | * Initial RCS-controlled version. 113 | */ 114 | -------------------------------------------------------------------------------- /my-stdlib.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 My_StdLib_H 19 | #define My_StdLib_H 1 20 | 21 | #include "config.h" 22 | 23 | #if HAVE_STDLIB_H 24 | 25 | #include 26 | 27 | #if NEED_MALLOC_H 28 | #include 29 | #endif 30 | 31 | #else /* !HAVE_STDLIB_H */ 32 | 33 | #include "my-types.h" 34 | 35 | extern void abort(void); 36 | extern int abs(int); 37 | extern void exit(int); 38 | extern void free(void *); 39 | extern void *malloc(size_t); 40 | extern int rand(void); 41 | extern void *realloc(void *, size_t); 42 | extern void srand(unsigned); 43 | 44 | #endif /* !HAVE_STDLIB_H */ 45 | 46 | #if NDECL_STRTOD 47 | extern double strtod(const char *, char **); 48 | #endif 49 | 50 | #if NDECL_STRTOL 51 | extern long strtol(const char *, char **, int); 52 | #endif 53 | 54 | #if HAVE_STRTOUL 55 | # if NDECL_STRTOUL 56 | extern unsigned long strtoul(const char *, char **, int); 57 | # endif 58 | #else 59 | # define strtoul strtol 60 | #endif 61 | 62 | #if NDECL_RANDOM 63 | extern int random(void); 64 | #endif 65 | 66 | #if NDECL_SRANDOM 67 | extern int srandom(unsigned); 68 | #endif 69 | 70 | #endif /* !My_StdLib_H */ 71 | 72 | /* 73 | * $Log$ 74 | * Revision 2.1 1996/02/08 06:01:42 pavel 75 | * Updated copyright notice for 1996. Added strtod(). Release 1.8.0beta1. 76 | * 77 | * Revision 2.0 1995/11/30 04:58:54 pavel 78 | * New baseline version, corresponding to release 1.8.0alpha1. 79 | * 80 | * Revision 1.10 1993/08/04 01:16:15 pavel 81 | * Added default definition for strtoul(), as a synonym for strtol(). 82 | * 83 | * Revision 1.9 1993/08/04 00:27:53 pavel 84 | * Added declaration for strtoul(). 85 | * 86 | * Revision 1.8 1993/08/04 00:13:30 pavel 87 | * Added declarations of random() and srandom(), moved from random.h. 88 | * 89 | * Revision 1.7 1992/10/23 23:03:47 pavel 90 | * Added copyright notice. 91 | * 92 | * Revision 1.6 1992/10/23 19:31:29 pavel 93 | * Added protection against multiple inclusions, for systems that aren't 94 | * clever enough to do that for themselves. 95 | * Added declaration of realloc(). 96 | * Added support for NEED_MALLOC_H. 97 | * 98 | * Revision 1.5 1992/10/21 03:02:35 pavel 99 | * Converted to use new automatic configuration system. 100 | * 101 | * Revision 1.4 1992/10/17 20:39:19 pavel 102 | * Removed apparently-useless declaration of exit()... (*sigh*) 103 | * 104 | * Revision 1.3 1992/09/27 19:25:12 pavel 105 | * Added declaration of exit() for SunOS. 106 | * 107 | * Revision 1.2 1992/07/30 00:33:28 pavel 108 | * Add support for compiling on RISC/os 4.52 and NonStop-UX A22. 109 | * 110 | * Revision 1.1 1992/07/20 23:23:12 pavel 111 | * Initial RCS-controlled version. 112 | */ 113 | -------------------------------------------------------------------------------- /storage.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 Storage_H 19 | #define Storage_H 1 20 | 21 | #include "my-string.h" 22 | 23 | #include "structures.h" 24 | #include "ref_count.h" 25 | 26 | typedef enum Memory_Type { 27 | M_AST_POOL, M_AST, M_PROGRAM, M_PVAL, M_NETWORK, M_STRING, M_VERBDEF, 28 | M_LIST, M_PREP, M_PROPDEF, M_OBJECT_TABLE, M_OBJECT, M_FLOAT, 29 | M_STREAM, M_NAMES, M_ENV, M_TASK, M_PATTERN, 30 | 31 | M_BYTECODES, M_FORK_VECTORS, M_LIT_LIST, 32 | M_PROTOTYPE, M_CODE_GEN, M_DISASSEMBLE, M_DECOMPILE, 33 | 34 | M_RT_STACK, M_RT_ENV, M_BI_FUNC_DATA, M_VM, 35 | 36 | M_REF_ENTRY, M_REF_TABLE, M_VC_ENTRY, M_VC_TABLE, M_STRING_PTRS, 37 | M_INTERN_POINTER, M_INTERN_ENTRY, M_INTERN_HUNK, 38 | 39 | M_XML_DATA, 40 | M_WAIF, M_WAIF_XTRA, 41 | 42 | Sizeof_Memory_Type 43 | 44 | } Memory_Type; 45 | 46 | extern char *str_dup(const char *); 47 | extern const char *str_ref(const char *); 48 | extern Var memory_usage(void); 49 | 50 | extern void myfree(const void *where, Memory_Type type); 51 | extern void *mymalloc(unsigned size, Memory_Type type); 52 | extern void *myrealloc(void *where, unsigned size, Memory_Type type); 53 | 54 | static inline void /* XXX was extern, fix for non-gcc compilers */ 55 | free_str(const char *s) 56 | { 57 | if (delref(s) == 0) 58 | myfree((void *) s, M_STRING); 59 | } 60 | 61 | #ifdef MEMO_STRLEN 62 | /* 63 | * Using the same mechanism as ref_count.h uses to hide Value ref counts, 64 | * keep a memozied strlen in the storage with the string. 65 | */ 66 | #define memo_strlen(X) ((void)0, (((int *)(X))[-2])) 67 | #else 68 | #define memo_strlen(X) strlen(X) 69 | 70 | #endif /* MEMO_STRLEN */ 71 | 72 | #endif /* !Storage_h */ 73 | 74 | /* 75 | * $Log$ 76 | * Revision 2.1 1996/02/08 06:13:09 pavel 77 | * Added M_FLOAT, removed unused M_PI. Updated copyright notice for 1996. 78 | * Release 1.8.0beta1. 79 | * 80 | * Revision 2.0 1995/11/30 04:55:11 pavel 81 | * New baseline version, corresponding to release 1.8.0alpha1. 82 | * 83 | * Revision 1.7 1992/10/23 23:03:47 pavel 84 | * Added copyright notice. 85 | * 86 | * Revision 1.6 1992/10/21 03:02:35 pavel 87 | * Converted to use new automatic configuration system. 88 | * 89 | * Revision 1.5 1992/10/17 20:53:28 pavel 90 | * Global rename of strdup->str_dup, strref->str_ref, vardup->var_dup, and 91 | * varref->var_ref, to avoid conflict on systems that provide their own 92 | * definition of strdup(). 93 | * 94 | * Revision 1.4 1992/09/14 17:39:30 pjames 95 | * Moved db_modification code to db modules. 96 | * 97 | * Revision 1.3 1992/08/31 22:23:29 pjames 98 | * Changed some `char *'s to `const char *' 99 | * 100 | * Revision 1.2 1992/08/28 16:25:17 pjames 101 | * Added memory types for refcount module. Added `strref()' and `free_str()'. 102 | * 103 | * Revision 1.1 1992/08/10 16:20:00 pjames 104 | * Initial RCS-controlled version 105 | */ 106 | -------------------------------------------------------------------------------- /ac_include/moo_arguments.m4: -------------------------------------------------------------------------------- 1 | dnl -*- autoconf -*- 2 | dnl 3 | 4 | # -------------------------------------------------------------------- 5 | # MOO_ALL_ARGUMENTS() 6 | # 7 | # creates all of the MOO-specific --enable-* and --with-* arguments 8 | # for ./configure 9 | 10 | AC_DEFUN([MOO_ALL_ARGUMENTS], 11 | 12 | [AC_PRESERVE_HELP_ORDER()dnl 13 | #---------------------------------------------------- 14 | # process LambdaMOO-specific command-line arguments 15 | #---------------------------------------------------- 16 | 17 | # --(enable|disable)-net 18 | MOO_NET_ARG_ENABLE([net]) 19 | 20 | # --enable-sz 21 | MOO_DATATYPESIZE_ARG_ENABLE([sz]) 22 | 23 | # --(enable|disable)-{extensions} 24 | MOO_XT_EXTENSION_ARGS() 25 | 26 | # --(enable|disable)-prop-protect 27 | # a less insane way of dealing with IGNORE_PROP_PROTECTED 28 | dnl 29 | dnl This is here as an example of how to do optional features 30 | dnl that are less complicated than --enable-net|sz|... 31 | dnl 32 | AC_ARG_ENABLE([prop-protect],[ 33 | AS_HELP_STRING([--disable-prop-protect],[disable]) 34 | AS_HELP_STRING([--enable-prop-protect],[/enable protection of builtin properties])], 35 | [AS_CASE([$enableval], 36 | [no],[[moo_d_IGNORE_PROP_PROTECTED=yes]], 37 | [[moo_d_IGNORE_PROP_PROTECTED=no]])]) 38 | 39 | # --(enable|disable)-svf-* for server-version-full settings 40 | MOO_SVF_ARG_ENABLES() 41 | 42 | # --(enable|disable)-def-* for options.h settings 43 | MOO_OPTION_ARG_ENABLES()dnl 44 | # -- end of moo-specific (enable|disable) 45 | 46 | MOO_PUT_HELP([ENABLE],[ 47 | Other Features:])]) 48 | dnl 49 | dnl --- end of MOO_ALL_ARGUMENTS 50 | 51 | # ------------------------------------------------------------------ 52 | # MOO_DATATYPESIZE_ARG_ENABLE([]) 53 | # creates the --enable-=kwds... ./configure argument 54 | # 55 | AC_DEFUN([MOO_DATATYPESIZE_ARG_ENABLE], 56 | [AC_ARG_ENABLE([$1],[[ 57 | Datatype options:] 58 | AS_HELP_STRING([[--enable-$1=KWD[,KWD]]], 59 | [set all datatype size options]) 60 | [ i64, i32, i16: INT_TYPE_BITSIZE=*] 61 | [ flt, fdbl, flong, fquad: FLOATING_TYPE=FT_*] 62 | [ box, unbox: BOXED_FLOATS=yes,no] 63 | [ bqhw, bq32, bq64[b]: BYTE_QUOTA_MODEL=BQM_*]], 64 | [[ac_save_IFS=$IFS 65 | IFS=, 66 | for moo_kwd in ,x $enableval ; do 67 | IFS=$ac_save_IFS] 68 | AS_CASE([$moo_kwd],[[ 69 | ,x]], [[continue]], [[ 70 | bqhw]], [[moo_d=BYTE_QUOTA_MODEL; moo_v=BQM_HW]], [[ 71 | bq32]], [[moo_d=BYTE_QUOTA_MODEL; moo_v=BQM_32]], [[ 72 | bq64]], [[moo_d=BYTE_QUOTA_MODEL; moo_v=BQM_64]], [[ 73 | bq64b]], [[moo_d=BYTE_QUOTA_MODEL; moo_v=BQM_64B]], [[ 74 | i64]], [[moo_d=INT_TYPE_BITSIZE; moo_v=64]], [[ 75 | i32]], [[moo_d=INT_TYPE_BITSIZE; moo_v=32]], [[ 76 | i16]], [[moo_d=INT_TYPE_BITSIZE; moo_v=16]], [[ 77 | flt]], [[moo_d=FLOATING_TYPE; moo_v=FT_FLOAT]], [[ 78 | fdbl]], [[moo_d=FLOATING_TYPE; moo_v=FT_DOUBLE]], [[ 79 | flong]], [[moo_d=FLOATING_TYPE; moo_v=FT_LONG]], [[ 80 | fquad]], [[moo_d=FLOATING_TYPE; moo_v=FT_QUAD]], [[ 81 | box]], [[moo_d=BOXED_FLOATS; moo_v=yes]], [[ 82 | unbox]], [[moo_d=BOXED_FLOATS; moo_v=no]], 83 | [AC_MSG_ERROR([unknown --enable-$1 keyword: $moo_kwd])]) 84 | AS_VAR_SET_IF([moo_d_$moo_d], 85 | [AS_VAR_COPY([moo_v],[moo_d_$moo_d]) 86 | AC_MSG_ERROR([[--enable-$1=...,$moo_kwd: $moo_d already set to $moo_v]])]) 87 | AS_VAR_SET([moo_d_$moo_d],[[$moo_v]]) 88 | AC_MSG_NOTICE([(--enable-$1:) $moo_d = $moo_v])[ 89 | done]])]) 90 | 91 | # ------------------------------------------------------------------ 92 | # MOO_PUT_HELP(OPTIONGRP,TEXT) 93 | # 94 | # With OPTIONGRP being either 'ENABLE' or 'WITH', 95 | # inserts additional TEXT into that section of ./configure help 96 | # (to break up the list and make it more readable). 97 | # 98 | AC_DEFUN([MOO_PUT_HELP], 99 | [m4_divert_text([HELP_$1],[$2])]) 100 | -------------------------------------------------------------------------------- /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 | 23 | #include "structures.h" 24 | 25 | /***************************************************************** 26 | * Server Executable Version 27 | */ 28 | 29 | extern const char *server_version; 30 | extern Var server_version_full(Var); 31 | 32 | 33 | /***************************************************************** 34 | * Language / Database-Format Version 35 | */ 36 | 37 | /* The following list must never be reordered, only appended to. There is one 38 | * element per version of the database format (including incompatible changes 39 | * to the language, such as the addition of new keywords). The integer value 40 | * of each element is used in the DB header on disk to identify the format 41 | * version in use in that file. 42 | */ 43 | typedef enum { 44 | DBV_Prehistory, /* Before format versions */ 45 | DBV_Exceptions, /* Addition of the `try', `except', `finally', 46 | * and `endtry' keywords. 47 | */ 48 | DBV_BreakCont, /* Addition of the `break' and `continue' 49 | * keywords. 50 | */ 51 | DBV_Float, /* Addition of `FLOAT' and `INT' variables and 52 | * the `E_FLOAT' keyword, along with version 53 | * numbers on each frame of a suspended task. 54 | */ 55 | DBV_BFBugFixed, /* Bug in built-in function overrides fixed by 56 | * making it use tail-calling. This DB_Version 57 | * change exists solely to turn off special 58 | * bug handling in read_bi_func_data(). 59 | */ 60 | Num_DB_Versions /* Special: the current version is this - 1. */ 61 | } DB_Version; 62 | 63 | #define current_db_version ((DB_Version) (Num_DB_Versions - 1)) 64 | 65 | extern int check_db_version(DB_Version); 66 | /* Returns true iff given version is within the 67 | * known range. 68 | */ 69 | 70 | #endif /* !Version_H */ 71 | 72 | /* 73 | * $Log$ 74 | * Revision 2.3 1996/04/19 01:25:21 pavel 75 | * Added somewhat bogus DBV_BFBugFixed version. Release 1.8.0p4. 76 | * 77 | * Revision 2.2 1996/02/08 06:07:10 pavel 78 | * Added DBV_BreakCont and DBV_Float versions, check_version(). 79 | * ...(check_version is now check_db_version -- wrog 2010) 80 | * Moved db_in_version to db_io.h and renamed db_out_version to 81 | * current_version ...(is now current_db_version -- wrog 2010) 82 | * Updated copyright notice for 1996. Release 1.8.0beta1. 83 | * 84 | * Revision 2.1 1995/12/28 00:48:42 pavel 85 | * Fixed list of new keywords in comment to remove transient `raise' keyword. 86 | * Release 1.8.0alpha3. 87 | * 88 | * Revision 2.0 1995/11/30 04:56:42 pavel 89 | * New baseline version, corresponding to release 1.8.0alpha1. 90 | * 91 | * Revision 1.3 1992/10/23 23:03:47 pavel 92 | * Added copyright notice. 93 | * 94 | * Revision 1.2 1992/10/21 03:02:35 pavel 95 | * Converted to use new automatic configuration system. 96 | * 97 | * Revision 1.1 1992/07/20 23:23:12 pavel 98 | * Initial RCS-controlled version. 99 | */ 100 | -------------------------------------------------------------------------------- /ac_include/moo_decl.m4: -------------------------------------------------------------------------------- 1 | dnl -*- autoconf -*- 2 | 3 | dnl ****************************************************************** 4 | dnl MOO_NDECL_FUNCS(header, func1 func2 ...[, extra-hdr]) 5 | dnl Defines NDECL_func1, NDECL_func2, ... if not declared in header. 6 | dnl Sets ac_cv_have_decl_{func1,func2,...} if declared 7 | dnl *** TODO: use AC_CHECK_DECLS but that entails changing 8 | dnl *** #ifdef NDECL_func to #if !HAVE_DECL_func everywhere 9 | dnl *** ALSO if you use this twice for the same function (cf. bzero) 10 | dnl *** you need to reset ac_cv_have_decl_FUNC 11 | dnl *** otherwise the 2nd check does not happen. --wrog 12 | m4_define([_MOO_CHECK_NDECL], 13 | [AC_CHECK_DECL([$1], [], 14 | [AC_DEFINE_UNQUOTED(AS_TR_CPP([NDECL_][$1]))], [$2]) 15 | ])dnl -- this NL apparently matters in 2.71 16 | dnl 17 | AC_DEFUN([MOO_NDECL_FUNCS], 18 | [m4_map_args_w([$2], [_MOO_CHECK_NDECL(], [, 19 | [[@%:@include <$1>] 20 | $3])],[ 21 | ])])dnl 22 | dnl 23 | dnl *************************************************************************** 24 | dnl MOO_NDECL_VARS(header, var1 var2 ...[, extra-hdr]) 25 | dnl Defines NDECL_var1, NDECL_var2, ... if they are not declared in header. 26 | dnl Sets ac_cv_have_decl_{var1,var2,...} if declared 27 | dnl (since AC_CHECK_DECL only checks that the name can be used as an 28 | dnl rvalue without causing link errors and so works equally well for 29 | dnl vars and funcs, so this is now identical to MOO_NDECL_FUNCS) 30 | AC_DEFUN([MOO_NDECL_VARS],m4_defn([MOO_NDECL_FUNCS]))dnl 31 | 32 | 33 | dnl *************************************************************************** 34 | dnl MOO_WHERE_THE_HELL_IS_BZERO 35 | dnl It seems bzero() can be just about anywhere. If we already know 36 | dnl it will be in the cache (ac_cv_have_decl_bzero), otherwise search 37 | dnl 'yes' is for the usual place (string.h) and otherwise we 38 | dnl cdefine NDECL_BZERO and whichever BZERO_IN_ applies 39 | dnl 40 | AC_DEFUN([MOO_WHERE_THE_HELL_IS_BZERO], 41 | [AS_IF([[test x"$ac_cv_have_decl_bzero" = x]], 42 | [_MOO_WHERE_THE_HELL_IS_BZERO( 43 | [[yes]], [[@%:@if NEED_MEMORY_H 44 | @%:@include 45 | @%:@endif 46 | @%:@include ]], 47 | [[strings]],[[@%:@include ]], 48 | [[stdlib]], [[@%:@include ]])]) 49 | AS_IF([[test "$ac_cv_have_decl_bzero" != yes]], 50 | [AC_DEFINE([NDECL_BZERO]) 51 | AS_CASE([[$ac_cv_have_decl_bzero]],[[ 52 | strings]],[AC_DEFINE([BZERO_IN_STRINGS_H])],[[ 53 | stdlib]], [AC_DEFINE([BZERO_IN_STDLIB_H])])])]) 54 | 55 | m4_define([_MOO_WHERE_THE_HELL_IS_BZERO], 56 | [m4_ifval([$2],[AS_UNSET([ac_cv_have_decl_bzero]) 57 | AC_CHECK_DECL([bzero], 58 | [[ac_cv_have_decl_bzero=]$1], 59 | [$0(m4_shift2($@))], [$2])], 60 | [[ac_cv_have_decl_bzero=no]])]) 61 | 62 | 63 | dnl *************************************************************************** 64 | dnl MOO_HEADER_STANDS_ALONE(header [, extra-code]) 65 | dnl Sets moo_cc_cv_hso_HEADER to yes or no accordingly. 66 | dnl Defines header_NEEDS_HELP if can't be compiled all by itself. 67 | dnl 68 | AC_DEFUN([MOO_HEADER_STANDS_ALONE], 69 | [AS_VAR_PUSHDEF([_moo_Flag], [moo_cc_cv_hso_$1])dnl 70 | AC_CACHE_CHECK([for self-sufficiency of $1], m4_dquote(_moo_Flag), 71 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 72 | #include <$1> 73 | $2 74 | ]],[[]])],[AS_VAR_SET(m4_dquote(_moo_Flag),[yes])],[AS_VAR_SET(m4_dquote(_moo_Flag),[no])])]) 75 | AS_VAR_IF(m4_dquote(_moo_Flag),[no],[AC_DEFINE_UNQUOTED(AS_TR_CPP([$1][_NEEDS_HELP]))]) 76 | AS_VAR_POPDEF([_moo_Flag])])dnl 77 | 78 | dnl *************************************************************************** 79 | dnl MOO_HAVE_FUNC_LIBS(func1 func2 ..., lib1 "lib2a lib2b" lib3 ...) 80 | dnl For each `func' in turn, if `func' is defined using the current LIBS value, 81 | dnl leave LIBS alone. Otherwise, try adding each of the given libs to LIBS in 82 | dnl turn, stopping when one of them succeeds in providing `func'. Define 83 | dnl HAVE_func if `func' is eventually found. 84 | dnl 85 | m4_define([_MOO_HAVE_FUNC_LIBS], 86 | [AC_SEARCH_LIBS([$1], [$2], 87 | [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]),[1])], [], [$3])])dnl 88 | 89 | AC_DEFUN([MOO_HAVE_FUNC_LIBS], 90 | [m4_map_args_w([$1], [_$0(], [, [$2], [$3])])])dnl 91 | -------------------------------------------------------------------------------- /extensions2_tutorial.ac: -------------------------------------------------------------------------------- 1 | MOO_XT_DECLARE_EXTENSIONS([ 2 | #| Everything above this line is boilerplate; do not edit. 3 | 4 | #| Run "autoconf -f" after any changes to extensions2.ac 5 | 6 | #| To start the tutorial (see Extensions.md), copy this file to 7 | #| extensions2.ac, make that writable and do all editing there. 8 | 9 | #| And yes, this file is nothing but comments and, 10 | #| in its initial state, does nothing. 11 | 12 | #| Lines beginning with #| are supposed to stay commented forever. 13 | 14 | #| Lines beginning with #(tab) get uncommented at various times; 15 | #| just delete the # but leave the tab there, then put the line 16 | #| back the way it was when it comes time to recomment it. 17 | 18 | #| The "TOP" section for tutorial purposes is 19 | #| everything from here down to "[ end of extension declarations ]" 20 | 21 | #| This all being the first argument to MOO_XT_DECLARE_EXTENSIONS(), 22 | #| (other arguments except the 9th are M4-expanded and ignored), 23 | #| will be a sequence of cmds in the "MOO_XT Language". 24 | 25 | #| Indentation matters in this language. 26 | 27 | # %%extension hello 28 | # %disabled 29 | # %? Hello Facilities: 30 | 31 | #| Only one of these 3 lines should be uncommented: 32 | # --enable- hello 33 | # --enable- hi 34 | # --enable- hi = KWD,... 35 | 36 | # %?- no hello() function, sorry 37 | # %? provide a hello() function 38 | # XT_CSRCS = hello.c 39 | # %cdefine HELLO_CORE 40 | # %option esmtp HELLO_ESMTP 41 | # %alt ehlo 42 | # %? do the esmtp thing 43 | 44 | #| Next line is boilerplate; do not edit. 45 | ],,,,,,,,[ end of extension declarations ],,,,,,,, 46 | 47 | #| Everything from here to the last closing paren is straight 48 | #| autoconf/M4 code that is expanded/evaluated for side-effects only. 49 | 50 | #| The main m4 parsing weirdness to know about is that, in argument 51 | #| lists, whitespace after the initial open paren and after any top-level 52 | #| commas gets discarded, but a comment will end whatever run of 53 | #| whitespace it's in, meaning any whitespace *after* the comment 54 | #| (starting on the next line) will be kept and become part of the 55 | #| argument, which may mess things up, so try not to do that. 56 | 57 | #| At this point we begin the "MIDDLE" section, for declaring 58 | #| options associated with your extension: 59 | 60 | MOO_DECLARE_OPTIONS( 61 | 62 | dnl [[HELLO_ESMTP], [bool], no, [make hello() do The ESMTP Thing]], 63 | dnl| 64 | dnl| As a general rule, do not use '#' comments in m4 argument lists 65 | dnl| unless you are sure the macro you are invoking can discard them. 66 | dnl| 67 | dnl| MOO_XT_DECLARE_EXTENSIONS, which encloses this whole file, 68 | dnl| is good at discarding '#' comments; 69 | dnl| MOO_DECLARE_OPTIONS and most other m4 macros are *not*. 70 | dnl| 71 | dnl| So here we use 'dnl' (Delete to NewLine, and that means the 72 | dnl| newline goes away, too) comments which don't have this problem, 73 | dnl| since they expand to *nothing* rather than expanding to themselves 74 | dnl| the way '#' comments do. 75 | dnl| 76 | dnl| You do, however, still want to make sure you do not *INDENT* 77 | dnl| the next line after this comment ends, because that *will* 78 | dnl| introduce whitespace that will not go away. 79 | ) 80 | 81 | #| ____________________________________________________ 82 | #| And, finally, the "BOTTOM" section. Everything from here to the next 83 | #| line of underscores is for your own macro definitions (m4_define() or 84 | #| AC_DEFUN()) if you need to have any. 85 | 86 | 87 | 88 | #| ____________________________________________________ 89 | #| The next closing paren is boilerplate; do not edit. 90 | )dnl| --- end of extensions2.ac --- 91 | dnl| 92 | dnl| We're using 'dnl's here because, now that we're done with 93 | dnl| MOO_XT_DECLARE_EXTENSIONS, we're essentially back out in configure.ac, 94 | dnl| where everything being expanded shows up in ./configure, 95 | dnl| including the '#' comments, which, in this case, is 96 | dnl| not what anyone wants. 97 | dnl| 98 | dnl| Uncomment the next line and rerun autoconf 99 | dnl| if you want to see what the MOO_XT_* things actually do: 100 | dnl MOO_XT_DUMP_EVERYTHING() 101 | -------------------------------------------------------------------------------- /my-string.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 My_String_H 19 | #define My_String_H 1 20 | 21 | #include "config.h" 22 | 23 | #if USE_OWN_STRING_H 24 | 25 | #include "my-types.h" 26 | 27 | extern void bzero(char *, int); 28 | extern void *memset(void *, int, size_t); 29 | extern char *strcpy(char *, const char *); 30 | extern char *strncpy(char *, const char *, size_t); 31 | extern char *strcat(char *, const char *); 32 | extern int strcmp(const char *, const char *); 33 | extern int strncmp(const char *, const char *, size_t); 34 | extern char *strchr(const char *, int); 35 | extern char *strpbrk(const char *, const char *); 36 | extern char *strerror(int); 37 | 38 | /* We don't need to declare these because we're only using our own string.h 39 | * due to GCC complaining about conflicting built-in declarations for them. 40 | */ 41 | 42 | #if 0 43 | extern void *memcpy(void *, const void *, size_t); 44 | extern int memcmp(const void *, const void *, size_t); 45 | extern size_t strlen(const char *); 46 | #endif 47 | 48 | #else 49 | 50 | # include 51 | 52 | # if NEED_MEMORY_H 53 | # include 54 | # else 55 | # if NDECL_MEMCPY 56 | # include "my-types.h" 57 | extern void *memcpy(void *, const void *, size_t); 58 | extern void *memmove(void *, const void *, size_t); 59 | extern int memcmp(const void *, const void *, size_t); 60 | # endif 61 | # endif 62 | 63 | #endif 64 | 65 | #if HAVE_STRERROR 66 | # if NDECL_STRERROR 67 | extern char *strerror(int); 68 | # endif 69 | #else 70 | extern const char *sys_errlist[]; 71 | # define strerror(error_code) sys_errlist[error_code] 72 | #endif 73 | 74 | #if NDECL_BZERO && !defined(bzero) 75 | # if BZERO_IN_STRINGS_H 76 | # include "strings.h" 77 | # elif BZERO_IN_STDLIB_H 78 | # include "my-stdlib.h" 79 | # else 80 | extern void bzero(char *, int); 81 | # endif 82 | #endif 83 | 84 | #if NDECL_MEMSET 85 | #include "my-types.h" 86 | 87 | extern void *memset(void *, int, size_t); 88 | #endif 89 | 90 | #endif /* !My_String_H */ 91 | 92 | /* 93 | * $Log$ 94 | * Revision 2.1 1996/02/08 06:01:23 pavel 95 | * Updated copyright notice for 1996. Release 1.8.0beta1. 96 | * 97 | * Revision 2.0 1995/11/30 04:59:02 pavel 98 | * New baseline version, corresponding to release 1.8.0alpha1. 99 | * 100 | * Revision 1.8 1993/08/03 21:32:18 pavel 101 | * Added support for bzero() being declared in on some systems. 102 | * 103 | * Revision 1.7 1992/10/23 23:03:47 pavel 104 | * Added copyright notice. 105 | * 106 | * Revision 1.6 1992/10/23 19:33:23 pavel 107 | * Added declarations of bcopy() and memset(). 108 | * Commented out unnecessary USE_OWN_STRING_H declarations of memcmp(), 109 | * memcpy(), and strlen(). 110 | * 111 | * Revision 1.5 1992/10/21 03:02:35 pavel 112 | * Converted to use new automatic configuration system. 113 | * 114 | * Revision 1.4 1992/10/17 20:40:26 pavel 115 | * Added some more system-dependent #if's. 116 | * Added declaration of memcmp() for SunOS. 117 | * 118 | * Revision 1.3 1992/08/31 22:26:51 pjames 119 | * Changed some `char *'s to `const char *' 120 | * 121 | * Revision 1.2 1992/07/30 00:34:15 pavel 122 | * Add support for compiling on RISC/os 4.52 and NonStop-UX A22. 123 | * 124 | * Revision 1.1 1992/07/20 23:23:12 pavel 125 | * Initial RCS-controlled version. 126 | */ 127 | -------------------------------------------------------------------------------- /eval_env.c: -------------------------------------------------------------------------------- 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 "eval_env.h" 19 | 20 | #include "storage.h" 21 | #include "structures.h" 22 | #include "sym_table.h" 23 | #include "utils.h" 24 | 25 | /* 26 | * Keep a pool of rt_envs big enough to hold NUM_READY_VARS variables to 27 | * avoid lots of malloc/free. 28 | */ 29 | static Var *ready_size_rt_envs; 30 | 31 | Var * 32 | new_rt_env(unsigned size) 33 | { 34 | Var *ret; 35 | unsigned i; 36 | 37 | if (size <= NUM_READY_VARS && ready_size_rt_envs) { 38 | ret = ready_size_rt_envs; 39 | ready_size_rt_envs = ret[0].v.list; 40 | } else 41 | ret = mymalloc(MAX(size, NUM_READY_VARS) * sizeof(Var), M_RT_ENV); 42 | 43 | for (i = 0; i < size; i++) 44 | ret[i].type = TYPE_NONE; 45 | 46 | return ret; 47 | } 48 | 49 | void 50 | free_rt_env(Var * rt_env, unsigned size) 51 | { 52 | register unsigned i; 53 | 54 | for (i = 0; i < size; i++) 55 | free_var(rt_env[i]); 56 | 57 | if (size <= NUM_READY_VARS) { 58 | rt_env[0].v.list = ready_size_rt_envs; 59 | ready_size_rt_envs = rt_env; 60 | } else 61 | myfree((void *) rt_env, M_RT_ENV); 62 | } 63 | 64 | Var * 65 | copy_rt_env(Var * from, unsigned size) 66 | { 67 | unsigned i; 68 | 69 | Var *ret = new_rt_env(size); 70 | for (i = 0; i < size; i++) 71 | ret[i] = var_ref(from[i]); 72 | return ret; 73 | } 74 | 75 | void 76 | fill_in_rt_consts(Var * env, DB_Version version) 77 | { 78 | Var v; 79 | 80 | v.type = TYPE_INT; 81 | v.v.num = (int) TYPE_ERR; 82 | env[SLOT_ERR] = var_ref(v); 83 | v.v.num = (int) TYPE_INT; 84 | env[SLOT_NUM] = var_ref(v); 85 | v.v.num = (int) _TYPE_STR; 86 | env[SLOT_STR] = var_ref(v); 87 | v.v.num = (int) TYPE_OBJ; 88 | env[SLOT_OBJ] = var_ref(v); 89 | v.v.num = (int) _TYPE_LIST; 90 | env[SLOT_LIST] = var_ref(v); 91 | 92 | if (version >= DBV_Float) { 93 | v.v.num = (int) TYPE_INT; 94 | env[SLOT_INT] = var_ref(v); 95 | v.v.num = (int) _TYPE_FLOAT; 96 | env[SLOT_FLOAT] = var_ref(v); 97 | } 98 | } 99 | 100 | void 101 | set_rt_env_obj(Var * env, int slot, Objid o) 102 | { 103 | Var v; 104 | v.type = TYPE_OBJ; 105 | v.v.obj = o; 106 | env[slot] = var_ref(v); 107 | } 108 | 109 | void 110 | set_rt_env_str(Var * env, int slot, const char *s) 111 | { 112 | Var v; 113 | v.type = TYPE_STR; 114 | v.v.str = s; 115 | env[slot] = v; 116 | } 117 | 118 | void 119 | set_rt_env_var(Var * env, int slot, Var v) 120 | { 121 | env[slot] = v; 122 | } 123 | 124 | 125 | /* 126 | * $Log$ 127 | * Revision 2.1 1996/02/08 07:13:03 pavel 128 | * Renamed TYPE_NUM to TYPE_INT. Made fill_in_rt_consts() version-dependent. 129 | * Updated copyright notice for 1996. Release 1.8.0beta1. 130 | * 131 | * Revision 2.0 1995/11/30 04:21:51 pavel 132 | * New baseline version, corresponding to release 1.8.0alpha1. 133 | * 134 | * Revision 1.6 1992/10/23 23:03:47 pavel 135 | * Added copyright notice. 136 | * 137 | * Revision 1.5 1992/10/21 03:02:35 pavel 138 | * Converted to use new automatic configuration system. 139 | * 140 | * Revision 1.4 1992/10/17 20:24:21 pavel 141 | * Global rename of strdup->str_dup, strref->str_ref, vardup->var_dup, and 142 | * varref->var_ref. 143 | * 144 | * Revision 1.3 1992/08/31 22:23:15 pjames 145 | * Changed some `char *'s to `const char *' 146 | * 147 | * Revision 1.2 1992/08/28 15:59:54 pjames 148 | * Changed vardup to varref. 149 | * 150 | * Revision 1.1 1992/08/10 16:20:00 pjames 151 | * Initial RCS-controlled version 152 | */ 153 | -------------------------------------------------------------------------------- /program.c: -------------------------------------------------------------------------------- 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 "exceptions.h" 20 | #include "list.h" 21 | #include "parser.h" 22 | #include "program.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 = 0; 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("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 i, count; 69 | 70 | count = BQM_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 += BQM_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 += BQM_SIZEOF_PTR_TO_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 | 116 | 117 | /* 118 | * $Log$ 119 | * Revision 2.4 1997/03/04 04:36:18 eostrom 120 | * Fixed memory leak in free_program(). 121 | * 122 | * Revision 2.3 1996/04/08 00:41:16 pavel 123 | * Corrected an error in the computation of `program_bytes()'. 124 | * Release 1.8.0p3. 125 | * 126 | * Revision 2.2 1996/02/08 06:54:31 pavel 127 | * Updated copyright notice for 1996. Release 1.8.0beta1. 128 | * 129 | * Revision 2.1 1995/12/11 08:04:20 pavel 130 | * Added `null_program()' and `program_bytes()'. Release 1.8.0alpha2. 131 | * 132 | * Revision 2.0 1995/11/30 04:29:58 pavel 133 | * New baseline version, corresponding to release 1.8.0alpha1. 134 | * 135 | * Revision 1.6 1992/10/23 23:03:47 pavel 136 | * Added copyright notice. 137 | * 138 | * Revision 1.5 1992/08/28 16:17:41 pjames 139 | * Changed `ak_dealloc_string()' to `free_str()'. 140 | * 141 | * Revision 1.4 1992/08/10 16:54:22 pjames 142 | * Updated #includes. 143 | * 144 | * Revision 1.3 1992/07/27 18:16:27 pjames 145 | * Changed name of ct_env to var_names, const_env to literals, and 146 | * f_vectors to fork_vectors. 147 | * 148 | * Revision 1.2 1992/07/21 00:05:45 pavel 149 | * Added rcsid_ declaration to hold the RCS ident. string. 150 | * 151 | * Revision 1.1 1992/07/20 23:23:12 pavel 152 | * Initial RCS-controlled version. 153 | */ 154 | -------------------------------------------------------------------------------- /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 | #ifndef Numbers_H 19 | #define Numbers_H 1 20 | 21 | #include "structures.h" 22 | 23 | extern enum error become_integer(Var, Num *, int); 24 | 25 | extern int do_equals(Var, Var); 26 | extern Var numeric_lt_or_eq(int, 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 | /* 36 | * parse_number(flags, c_first, getch, ungetch|NULL ) 37 | * 38 | * parses and returns the next integer or float value, 39 | * possibly allowing whitespace, decimal points, exponents 40 | * or a leading #, in accordance with the specified 41 | * flags - keep reading 42 | * from an input stream defined by the last three arguments 43 | * c_first - the first character 44 | * getch() - advance input, return next character or EOF 45 | * ungetch(c) - NULL or routine that pushes c back to input 46 | * 47 | * flags are as follows: 48 | */ 49 | #define PN_FLOAT_OK 0x01 /* allow decimal. and exponent */ 50 | #define PN_REQ_FLOAT 0x02 /* force returning a float */ 51 | #define PN_REQ_INT 0x04 /* force returning an integer */ 52 | #define PN_NONNEG 0x08 /* non-negative numbers only, */ 53 | /* i.e., do not accept leading minus signs; this 54 | * also changes the range of acceptable integers 55 | * and *may* make it possible for them to overflow 56 | * to NUM_MIN -- what the yacc parser needs. 57 | * See Very Long Comment in numbers.c for details. */ 58 | 59 | /* The following should only be used when ungetch == NULL */ 60 | #define PN_OCTOTHORPE 0x10 /* a leading # is allowed */ 61 | #define PN_LDSPACE 0x20 /* allow leading whitespace */ 62 | #define PN_TRSPACE 0x40 /* allow trailing whitespace */ 63 | #define PN_OCTOSPACE 0x80 /* allow whitespace after # */ 64 | #define PN_MUST_EOF 0x100 /* must use all of the input */ 65 | #define PN_SPACE (PN_LDSPACE|PN_TRSPACE|PN_OCTOSPACE) 66 | /* 67 | * The return value will be a Var with .type = 68 | * TYPE_INT or TYPE_FLOAT if the parse was successful *and* 69 | * the resulting value was within the representable range 70 | * (integers must be in [NUM_MIN..NUM_MAX], or, 71 | * if PN_NONNEG is set, in [0..NUM_MAX+1]; 72 | * floats must have magnitude < HUGE_VAL) 73 | * TYPE_ERROR otherwise 74 | * .v.err = E_NONE if ungetch != NULL and no digits were seen 75 | * .v.err = E_INVARG for all other syntax errors 76 | * .v.err = E_RANGE or E_FLOAT for unrepresentable values 77 | * 78 | * as per the following chart: 79 | * 80 | * PN_REQ_flags Value encountered 81 | * specified No decimal./exponent Decimal./exponent seen 82 | * _____________||_____________________|________________________ 83 | * || TYPE_INT | TYPE_INT or E_FLOAT 84 | * PN_REQ_INT || or | (float is truncated) 85 | * _____________|| _ E_RANGE _ _ |________________________ 86 | * neither || | 87 | * -------------||---------------------+ TYPE_FLOAT 88 | * PN_REQ_FLOAT || (int is floated) . or E_FLOAT 89 | * 90 | * If ungetch() is non-NULL: 91 | * (1) E_NONE returned means the parser has fully backtracked, 92 | * i.e., the next getch() would return c_first. 93 | * (2) The parser will backtrack out of '..' 94 | * and certain bitwise operator situations, meaning, 95 | * that '..' will always be treated as a distinct token 96 | * and not included in any number so that, e.g., 97 | * "1.." parses as: [integer 1] ['..'] 98 | * "1...2" parses as: [integer 1] ['..'] [float 0.2] 99 | * "1....2" parses as: [integer 1] ['..'] ['..'] 100 | */ 101 | extern Var 102 | parse_number(unsigned flags, 103 | int32_t c_first, 104 | int32_t (*getch)(void), 105 | void (*ungetch)(int32_t)); 106 | 107 | 108 | #endif /* !Numbers_H */ 109 | 110 | /* 111 | * $Log$ 112 | * Revision 1.1 1996/02/08 07:28:25 pavel 113 | * Initial revision 114 | * 115 | */ 116 | -------------------------------------------------------------------------------- /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 "config.h" 22 | 23 | #include "my-stdio.h" 24 | 25 | #include "execute.h" 26 | #include "streams.h" 27 | 28 | #undef MAX 29 | #undef MIN 30 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) 31 | #define MIN(A, B) ((A) < (B) ? (A) : (B)) 32 | 33 | #define Arraysize(x) (sizeof(x) / sizeof(*x)) 34 | 35 | extern int mystrcasecmp(const char *, const char *); 36 | extern int mystrncasecmp(const char *, const char *, int); 37 | 38 | extern int verbcasecmp(const char *verb, const char *word); 39 | 40 | extern unsigned str_hash(const char *); 41 | 42 | extern void complex_free_var(Var); 43 | extern Var complex_var_ref(Var); 44 | extern Var complex_var_dup(Var); 45 | extern int var_refcount(Var); 46 | 47 | static inline void 48 | free_var(Var v) 49 | { 50 | if (v.type & TYPE_COMPLEX_FLAG) 51 | complex_free_var(v); 52 | } 53 | 54 | static inline Var 55 | var_ref(Var v) 56 | { 57 | if (v.type & TYPE_COMPLEX_FLAG) 58 | return complex_var_ref(v); 59 | else 60 | return v; 61 | } 62 | 63 | static inline Var 64 | var_dup(Var v) 65 | { 66 | if (v.type & TYPE_COMPLEX_FLAG) 67 | return complex_var_dup(v); 68 | else 69 | return v; 70 | } 71 | 72 | extern int equality(Var lhs, Var rhs, int case_matters); 73 | extern int is_true(Var v); 74 | 75 | extern void stream_add_strsub(Stream *, const char *, const char *, const char *, int); 76 | extern int strindex(const char *, const char *, int); 77 | extern int strrindex(const char *, const char *, int); 78 | 79 | extern Var get_system_property(const char *); 80 | extern Objid get_system_object(const char *); 81 | 82 | extern int value_bytes(Var); 83 | 84 | extern void stream_add_moobinary_from_raw_bytes( 85 | Stream *, const char *buffer, size_t buflen); 86 | extern const char *moobinary_to_raw_bytes(const char *binary, size_t *rawlen); 87 | 88 | /* Given a stream and a buffer of characters encoded as bytes using 89 | * fromcode, write the characters to the stream using tocode, 90 | * fromcode and tocode being encodings the iconv library 91 | * knows about. Return nonzero if successful. 92 | */ 93 | extern int stream_add_recoded_chars(Stream *s, 94 | const char *inbuf, size_t inbytesleft, 95 | const char *fromcode, 96 | const char *tocode); 97 | 98 | #endif /* !Utils_H */ 99 | 100 | 101 | /* 102 | * $Log$ 103 | * Revision 2.4 1996/02/08 06:08:07 pavel 104 | * Moved become_number and compare_ints to number.h. Updated copyright notice 105 | * for 1996. Release 1.8.0beta1. 106 | * 107 | * Revision 2.3 1996/01/11 07:46:18 pavel 108 | * Added raw_bytes_to_binary() and binary_to_raw_bytes(), in support of binary 109 | * I/O facilities. Release 1.8.0alpha5. 110 | * 111 | * Revision 2.2 1995/12/28 00:39:38 pavel 112 | * Removed declaration for private variable `cmap'. Release 1.8.0alpha3. 113 | * 114 | * Revision 2.1 1995/12/11 08:09:56 pavel 115 | * Add `value_bytes()'. Release 1.8.0alpha2. 116 | * 117 | * Revision 2.0 1995/11/30 04:56:31 pavel 118 | * New baseline version, corresponding to release 1.8.0alpha1. 119 | * 120 | * Revision 1.10 1992/10/23 23:03:47 pavel 121 | * Added copyright notice. 122 | * 123 | * Revision 1.9 1992/10/21 03:02:35 pavel 124 | * Converted to use new automatic configuration system. 125 | * 126 | * Revision 1.8 1992/10/17 20:57:30 pavel 127 | * Global rename of strdup->str_dup, strref->str_ref, vardup->var_dup, and 128 | * varref->var_ref. 129 | * Removed useless #ifdef of STRCASE. 130 | * 131 | * Revision 1.7 1992/09/08 21:55:12 pjames 132 | * Added `become_number()' (from bf_num.c). 133 | * 134 | * Revision 1.6 1992/09/03 16:23:16 pjames 135 | * Make cmap[] visible. 136 | * 137 | * Revision 1.5 1992/08/31 22:22:05 pjames 138 | * Changed some `char *'s to `const char *' 139 | * 140 | * Revision 1.4 1992/08/28 16:24:15 pjames 141 | * Added `varref()'. Removed `copy_pi()'. 142 | * 143 | * Revision 1.3 1992/08/10 16:38:28 pjames 144 | * Added is_true (from execute.h) and *_activ_as_pi routines. 145 | * 146 | * Revision 1.2 1992/07/27 18:03:48 pjames 147 | * Changed name of ct_env to var_names 148 | * 149 | * Revision 1.1 1992/07/20 23:23:12 pavel 150 | * Initial RCS-controlled version. 151 | */ 152 | -------------------------------------------------------------------------------- /eval_vm.c: -------------------------------------------------------------------------------- 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 "eval_vm.h" 19 | 20 | #include "config.h" 21 | #include "options.h" 22 | 23 | #include "db_io.h" 24 | #include "decompile.h" 25 | #include "execute.h" 26 | #include "log.h" 27 | #include "storage.h" 28 | #include "structures.h" 29 | #include "tasks.h" 30 | 31 | /**** external functions ****/ 32 | 33 | vm 34 | new_vm(TaskID task_id, int stack_size) 35 | { 36 | vm the_vm = mymalloc(sizeof(vmstruct), M_VM); 37 | 38 | the_vm->task_id = task_id; 39 | the_vm->activ_stack = mymalloc(sizeof(activation) * stack_size, M_VM); 40 | 41 | return the_vm; 42 | } 43 | 44 | void 45 | free_vm(vm the_vm, int stack_too) 46 | { 47 | int i; 48 | 49 | if (stack_too) 50 | for (i = the_vm->top_activ_stack; i >= 0; i--) 51 | free_activation(&the_vm->activ_stack[i], 1); 52 | myfree(the_vm->activ_stack, M_VM); 53 | myfree(the_vm, M_VM); 54 | } 55 | 56 | activation 57 | top_activ(vm the_vm) 58 | { 59 | return the_vm->activ_stack[the_vm->top_activ_stack]; 60 | } 61 | 62 | Objid 63 | progr_of_cur_verb(vm the_vm) 64 | { 65 | return top_activ(the_vm).progr; 66 | } 67 | 68 | unsigned 69 | suspended_lineno_of_vm(vm the_vm) 70 | { 71 | activation top; 72 | 73 | top = top_activ(the_vm); 74 | return find_line_number(top.prog, (the_vm->top_activ_stack == 0 75 | ? the_vm->root_activ_vector 76 | : MAIN_VECTOR), 77 | top.error_pc); 78 | } 79 | 80 | /**** read/write data base ****/ 81 | 82 | void 83 | write_vm(vm the_vm) 84 | { 85 | unsigned i; 86 | 87 | dbio_printf("%u %d %u %u\n", 88 | the_vm->top_activ_stack, the_vm->root_activ_vector, 89 | the_vm->func_id, the_vm->max_stack_size); 90 | 91 | for (i = 0; i <= the_vm->top_activ_stack; i++) 92 | write_activ(the_vm->activ_stack[i]); 93 | } 94 | 95 | vm 96 | read_vm(TaskID task_id) 97 | { 98 | unsigned i, top, func_id, max; 99 | int vector; 100 | vm the_vm; 101 | 102 | int scn = dbio_scxnf("%u %d %u\v %u", &top, &vector, &func_id, &max); 103 | if (!scn) { 104 | errlog("READ_VM: Bad vm header\n"); 105 | return 0; 106 | } 107 | else if (scn < 2) 108 | max = DEFAULT_MAX_STACK_DEPTH; 109 | 110 | the_vm = new_vm(task_id, top + 1); 111 | the_vm->max_stack_size = max; 112 | the_vm->top_activ_stack = top; 113 | the_vm->root_activ_vector = vector; 114 | the_vm->func_id = func_id; 115 | 116 | for (i = 0; i <= top; i++) 117 | if (!read_activ(&the_vm->activ_stack[i], 118 | i == 0 ? vector : MAIN_VECTOR)) { 119 | errlog("READ_VM: Bad activ number %d\n", i); 120 | return 0; 121 | } 122 | return the_vm; 123 | } 124 | 125 | 126 | /* 127 | * $Log$ 128 | * Revision 2.2 1996/02/08 07:12:16 pavel 129 | * Renamed err/logf() to errlog/oklog(). Updated copyright notice for 1996. 130 | * Release 1.8.0beta1. 131 | * 132 | * Revision 2.1 1995/12/31 03:19:43 pavel 133 | * Added missing #include "options.h". Release 1.8.0alpha4. 134 | * 135 | * Revision 2.0 1995/11/30 04:22:07 pavel 136 | * New baseline version, corresponding to release 1.8.0alpha1. 137 | * 138 | * Revision 1.10 1993/12/21 23:40:11 pavel 139 | * Add new `outcome' result from the interpreter. 140 | * 141 | * Revision 1.9 1993/08/11 06:03:12 pavel 142 | * Fixed mistaken %d->%u change. 143 | * 144 | * Revision 1.8 1993/08/11 02:58:03 pavel 145 | * Changed some bogus %d's to %u's in calls to *scanf() and *printf(), guided 146 | * by warnings from GCC... 147 | * 148 | * Revision 1.7 1992/10/23 23:03:47 pavel 149 | * Added copyright notice. 150 | * 151 | * Revision 1.6 1992/10/21 03:02:35 pavel 152 | * Converted to use new automatic configuration system. 153 | * 154 | * Revision 1.5 1992/10/17 20:25:59 pavel 155 | * Changed return-type of read_vm() from `char' to `int', for systems that use 156 | * unsigned chars. 157 | * 158 | * Revision 1.4 1992/09/25 21:12:12 pjames 159 | * Passed correct pc (error_pc) to get_lineno. 160 | * 161 | * Revision 1.3 1992/09/02 18:43:11 pavel 162 | * Added mechanism for resuming a read()ing task with an error. 163 | * 164 | * Revision 1.2 1992/08/31 22:22:24 pjames 165 | * Changed some `char *'s to `const char *' 166 | * 167 | * Revision 1.1 1992/08/10 16:20:00 pjames 168 | * Initial RCS-controlled version 169 | */ 170 | -------------------------------------------------------------------------------- /net_tcp.c: -------------------------------------------------------------------------------- 1 | /************ 2 | * net_tcp.c 3 | * 4 | * common code for 5 | * multi-user networking protocol implementations for TCP/IP 6 | * (net_bsd_tcp.c and net_sysv_tcp.c) 7 | * 8 | */ 9 | 10 | static in_addr_t bind_local_ip = INADDR_ANY; 11 | 12 | const char * 13 | proto_usage_string(void) 14 | { 15 | return "[+O|-O] [-a ip_address] [[-p] port]"; 16 | } 17 | 18 | 19 | static int 20 | tcp_arguments(struct proto *proto, int argc, char **argv, int *pport) 21 | { 22 | char *p = 0; 23 | 24 | for ( ; argc > 0; argc--, argv++) { 25 | if (argc > 0 26 | && (argv[0][0] == '-' || argv[0][0] == '+') 27 | && argv[0][1] == 'O' 28 | && argv[0][2] == 0 29 | ) { 30 | #ifdef OUTBOUND_NETWORK 31 | proto->can_connect_outbound = (argv[0][0] == '+'); 32 | #else 33 | if (argv[0][0] == '+') { 34 | fprintf(stderr, "Outbound network not supported.\n"); 35 | oklog("CMDLINE: *** Ignoring %s (outbound network not supported)\n", argv[0]); 36 | } 37 | #endif 38 | } 39 | else if (0 == strcmp(argv[0],"-a")) { 40 | if (argc <= 1) 41 | return 0; 42 | argc--; 43 | argv++; 44 | bind_local_ip = inet_addr(argv[0]); 45 | if (bind_local_ip == INADDR_NONE) 46 | return 0; 47 | oklog("CMDLINE: Source address restricted to %s\n", argv[0]); 48 | } 49 | else { 50 | if (p != 0) /* strtoul always sets p */ 51 | return 0; 52 | if (0 == strcmp(argv[0],"-p")) { 53 | if (argc <= 1) 54 | return 0; 55 | argc--; 56 | argv++; 57 | } 58 | *pport = strtoul(argv[0], &p, 10); 59 | if (*p != '\0') 60 | return 0; 61 | oklog("CMDLINE: Initial port = %d\n", *pport); 62 | } 63 | } 64 | #ifdef OUTBOUND_NETWORK 65 | oklog("CMDLINE: Outbound network connections %s.\n", 66 | proto->can_connect_outbound ? "enabled" : "disabled"); 67 | #endif 68 | return 1; 69 | } 70 | 71 | 72 | int 73 | proto_initialize(struct proto *proto, Var * desc, int argc, char **argv) 74 | { 75 | proto->can_connect_outbound = 76 | #ifdef OUTBOUND_NETWORK 77 | OUTBOUND_NETWORK; 78 | #else 79 | 0; 80 | #endif 81 | 82 | int port = DEFAULT_PORT; 83 | 84 | proto->pocket_size = 1; 85 | proto->believe_eof = 1; 86 | proto->eol_out_string = "\r\n"; 87 | 88 | if (!tcp_arguments(proto, argc, argv, &port)) 89 | return 0; 90 | 91 | initialize_name_lookup(); 92 | 93 | desc->type = TYPE_INT; 94 | desc->v.num = port; 95 | 96 | return 1; 97 | } 98 | 99 | 100 | /* So, historically, only 'name_lookup_timeout' existed and applied to 101 | * both inbound and outbound connections. But these are really 102 | * different situations and need to have separate settings. Which 103 | * means one of them has to be a new option, but defaulting to the old 104 | * one for backwards compatibility. 105 | * 106 | * We *could* have made the new one be the one governing outbound 107 | * connections, but since the setting for inbound connections is the 108 | * one people are way more likely to want to change (i.e., to set to 0 109 | * because, now that the year is 2024 and reverse-DNS is almost 110 | * completely useless), having the default for outbound be the inbound 111 | * setting would force everyone wanting to turn off inbound lookups to 112 | * make a *second* setting to restore the outbound default, which 113 | * would be a huge pain. So that is why it's the other way around 114 | * (inbound defaults to outbound). 115 | * 116 | * And, yes, the naming is confusing: "name lookup" can EITHER mean 117 | * you *have* a name that you are looking up to get information about 118 | * it, or you have the other information and want to look up the 119 | * corresponding name. English is stupid; film at 11. 120 | * 121 | * Here we are going with the former interpretation, which also 122 | * happens to put the new name with the new option, hence, 123 | * the option is named after the thing you provide: 124 | * 125 | * "name_lookup" is for when you have a name and need an address 126 | * (i.e., "ordinary" DNS A query for outbound connections) 127 | * "address_lookup" is for when you have an address and want a name 128 | * (i.e., "reverse" DNS PTR query for inbound connections) 129 | * 130 | * Sorry if this seems backwards to you, but we're in a no-win 131 | * situation here. --wrog (8/27/2024) 132 | */ 133 | static int 134 | address_lookup_timeout(server_listener sl) 135 | { 136 | int timeout = server_listener_int_option(sl, "address_lookup_timeout", -2); 137 | 138 | if (timeout == -2) 139 | timeout = server_listener_int_option(sl, "name_lookup_timeout", 5); 140 | return timeout < 0 ? 0 : timeout; 141 | } 142 | 143 | 144 | static int 145 | open_connection_arguments(Var arglist, 146 | const char **host_name, int *port) 147 | { 148 | if (arglist.v.list[0].v.num != 2) 149 | return E_ARGS; 150 | if (arglist.v.list[1].type != TYPE_STR || 151 | arglist.v.list[2].type != TYPE_INT) 152 | return E_TYPE; 153 | 154 | *host_name = arglist.v.list[1].v.str; 155 | *port = arglist.v.list[2].v.num; 156 | return E_NONE; 157 | } 158 | --------------------------------------------------------------------------------