first commit

This commit is contained in:
Babylon 2020-09-06 05:43:07 -07:00
commit 433e764989
5548 changed files with 433531 additions and 0 deletions

45
License.txt Normal file
View File

@ -0,0 +1,45 @@
Whatever the law says, so it applies here.
Note that the changes to the original Dead Souls release
of 1998 are copyrighted by me, Bill Sanchez, and
are NOT GPL. Understanding what that means and
due compliance with applicable laws is left as an
exercise to the reader.
MudOS/FluffOS is being packaged with the lib pursuant to
standard LPmud practice. Please note that MudOS and FluffOS
are copyrighted, and should we be asked to stop
distributing them by their respective copyright holders,
we will be obligated to do so.
For explicit details on Dead Souls and MudOS
bundled distribution, please see:
http://dead-souls.net/articles/copyright.html
A few details, for the license fetishists:
* It's ok to run a mud with this. Modify it as you
wish, and do what people normally associate with
"running a mud." You can change anything about the
lib after you download it. It's your mud game. I don't
care what you do with it. But you're encouraged
to share your work with me.
* If you need to do something like forking development
and distributing your own DS-based lib, you should
use the Public Domain version, not this version. For
info, see: http://dead-souls.net/ds-II-faq.html
* I expect this to be enough information so you
know what you can and can't do lawfully with
this software. I can't stand licensing discussion,
and will not enter into a debate with you about
what copyright means. I will not answer any
further questions on the subject. This document
is the final word on the matter. If in doubt,
refer to your local laws and regulations concerning
intellectual property.
- Bill Sanchez aka Cratylus @ Dead Souls, aka Cratylus @ Frontiers
November 2007

37
README.txt Normal file
View File

@ -0,0 +1,37 @@
The Dead Souls 2 Mud Library
Released December 2005
GENERAL FAQ: http://dead-souls.net/ds-faq.html
ADMIN FAQ: http://dead-souls.net/ds-admin-faq.html
CREATOR FAQ: http://dead-souls.net/ds-creator-faq.html
INSTALL FAQ: http://dead-souls.net/ds-inst-faq.html
ED TUTORIAL: http://dead-souls.net/editor.html
CREATION SYSTEM (aka OLC, aka QCS) : http://dead-souls.net/example.html
This software is provided as-is. Getting it running
and getting it working is on you, not me. make sure you go
through the install FAQ. There's a version archived here in
the ./www subdirectory.
Some years ago, Descartes @ Nightmare chose to retire his
Nightmare mudlib from distribution. Yet some folks felt
that it was a fine lib, and many were sorry to see it go.
This mudlib is based on that old warhorse. It is entirely
free from those NM IV licensing problems. It is in a state
as bug-free as I could make it, with my limited resources
and faculties. I make it available so that a new generation of
mudders can experience the joy of creating with LPC in a way
that is easy to set up, intuitive to modify, and simple to maintain.
Please review /doc/old/README for more historical background.
Have fun!
-Cratylus @ Dead Souls
This document last updated: 28 Jan 2008

46
UNIX_INSTRUCTIONS.txt Normal file
View File

@ -0,0 +1,46 @@
If you're on Ubuntu, you may need to apt-get bison and libc6.
See: http://dead-souls.net/ds-inst-faq.html#9 for details.
Then perform the following steps:
1) cd to the directory where all mud files reside. Called $MUDHOME
in the rest of this document.
2) cd to fluffos-2*
3) type ./configure
4) type: make install
5) edit $MUDHOME/bin/mudos.cfg (provided). The two to change are:
mudlib directory and binary directory. For example, if your $MUDHOME
is /home/joe/mud, then the mudlib directory line will look like this:
/home/joe/mud/lib
and bin:
/home/joe/mud/bin
6) edit $MUDHOME/bin/startmud (provided) and change the $MUDHOME
stuff.
7) manually run the mud $MUDHOME/bin/driver $MUDHOME/bin/mudos.cfg
8) telnet to your machine, using the port specified in mudos.cfg. For
example: telnet localhost 6666
9) Create a new user. Just answer the questions. Make sure you are
the first person to log in, because that person is automatically
given admin privileges.
10) You'll get booted out. Reboot the MUD, telnet back in, and you're
now running Your Very Own MUD.
11) If you have problems, review the FAQ: http://dead-souls.net/ds-inst-faq.html
12) If this doesn't help, search http://lpmuds.net/forum/ for clues. This procedure works perfectly on SuSE 10 32/64bit, Solaris 10 SPARC/x86, OSX, and various other systems, but I can't possibly vouch for every unix flavor and compiler suite out there. If the compile fails, try the local_options file in extra/
13) If there is something actually wrong or missing in this documentation, please
ask for help on the Dead Souls support forum at http://lpmuds.net/forum/

42
WINDOWS_INSTRUCTIONS.txt Normal file
View File

@ -0,0 +1,42 @@
YOU MUST READ THIS URL: http://dead-souls.net/ds-inst-faq.html
-------------------------------------------------------------
WARNING: Do NOT modify the file called
mudos.cfg. Doing so WILL cause the driver to fail.
You must use c:\ds as your mud folder. To rename the
mud, use the admintool command after you log in.
WARNING: Dead Souls is NOT supported on WinME or Win98 or earlier
versions of windows.
-------------------------------------------------------------
1) unzip the distribution file.
2) move the directory to c:\
3) there should now be a c:\ds folder, containing bin, lib, etc. If
there isn't one, rename the directory you just created to c:\ds
If Dead Souls isn't in c:\ds , it won't run.
For example, there should be a c:\ds\bin, c:\ds\lib, etc.
4) double-click on runmud.bat
5) telnet to your machine, using the port specified in bin/mudos.cfg. For example: telnet localhost 6666
6) Create a new user. Just answer the questions. Make sure you are
the first person to log in, because that person is automatically
given admin privileges.
7) You'll get booted out. Telnet back in, and you're now running Your
Very Own MUD.
8) If there is something actually wrong or missing in this documentation, please
ask for help on the Dead Souls support forum at http://lpmuds.net/forum/
9) If you have connection problems, try again with your firewall disabled.
10) See the FAQ if you still have problems: http://dead-souls.net/ds-inst-faq.html

14
bin/README Normal file
View File

@ -0,0 +1,14 @@
To allow name and port changes from admintool, mudos.cfg
is not a link to a file inside the mudlib.
If you hose that file or that link, copy the original
in this directory (mudos.cfg.bak) to ../lib/secure/cfg/mudos.cfg
and recreate the link.
The commands, from this directory, are:
--------------------------------------
cp mudos.cfg.bak ../lib/secure/cfg/mudos.cfg
ln -s ../lib/secure/cfg/mudos.cfg mudos.cfg

150
bin/mudos.cfg Normal file
View File

@ -0,0 +1,150 @@
###############################################################################
# Customizable runtime config file for MudOS #
# NOTE: All paths specified here are relative to the mudlib directory except #
# for mudlib directory, and binary directory. #
# Lines beginning with a # or a newline are ignored. #
###############################################################################
# name of this mud
name : DeadSoulsNew
# port number to accept users on
external_port_1 : telnet 6666
# pathname of mudlib
mudlib directory : ../lib
# pathname of driver/config dir
binary directory : ../bin
# the address server is an external program that lets the mud translate
# internet names to numbers (and vice versa). select an unused port.
address server ip : localhost
address server port : 8099
# fd6 stuff is what allows portbind to work properly. If
# you want to have the mud accept connections on port 23 but run
# as non-root, you uncomment the two fd6 lines below and issue the
# appropriate portbind command to start the mud.
#fd6 port : 23
#fd6 kind : telnet
# debug.log and author/domain stats are stored here
log directory : /log
# the directories which are searched by #include <...>
# for multiple dirs, separate each path with a ':'
include directories : /secure/include:/include
# Directory to save binaries in. (if BINARIES is defined)
save binaries directory : /secure/save/binaries
# the file which defines the master object
master file : /secure/daemon/master
# the file where all global simulated efuns are defined.
simulated efun file : /secure/sefun/sefun
# file to swap out objects; not used if time to swap is 0
swap file : /secure/tmp/swap
# alternate debug.log file name (assumed to be in specified 'log directory')
debug log file : runtime
# This is an include file which is automatically #include'd in all objects
global include file : <global.h>
# if an object is left alone for a certain time, then the
# function clean_up will be called. This function can do anything,
# like destructing the object. If the function isn't defined by the
# object, then nothing will happen.
# This time should be substantially longer than the swapping time.
time to clean up : 2100000000
# How long time until an unused object is swapped out.
# Machine with too many players and too little memory: 900 (15 minutes)
# Machine with few players and lot of memory: 10000
# Machine with infinite memory: 0 (never swap).
time to swap : 0
# How many seconds until an object is reset again.
time to reset : 2100000000
# Maximum number of bits in a bit field. They are stored in printable
# strings, 6 bits per byte.
maximum bits in a bitfield : 1200
# Max number of local variables in a function.
maximum local variables : 35
# Maximum amount of "eval cost" per thread - execution is halted when
# it is exceeded.
maximum evaluation cost : 5000000
# This is the maximum array size allowed for one single array.
maximum array size : 64000
# This is the maximum allowed size of a variable of type 'buffer'.
maximum buffer size : 400000
# Max size for a mapping
maximum mapping size : 64000
# Max inherit chain size
inherit chain size : 30
# maximum length of a string variable
maximum string length : 200000
# Max size of a file allowed to be read by 'read_file()'.
maximum read file size : 200000
# max number of bytes you allow to be read and written with read_bytes
# and write_bytes
maximum byte transfer : 10000
# Reserve an extra memory area from malloc(), to free when we run out
# of memory and allow the mudlib to shutdown.
# If this value is 0, no area will be reserved.
reserved size : 0
# Define the size of the shared string hash table. This number should
# a prime, probably between 1000 and 30000; if you set it to about 1/5
# of the number of distinct strings you have, you will get a hit ratio
# (number of comparisons to find a string) very close to 1, as found strings
# are automatically moved to the head of a hash chain. You will never
# need more, and you will still get good results with a smaller table.
hash table size : 7001
# Object hash table size.
# Define this like you did with the strings; probably set to about 1/4 of
# the number of objects in a game, as the distribution of accesses to
# objects is somewhat more uniform than that of strings.
object table size : 1501
# default no-matching-action message
default fail message : What?
# default message when error() occurs (optional)
default error message : Something *REALLY* bad just happened.
###############################################################################
# The following aren't currently used or implemented (yet) #
###############################################################################
# maximum number of users in the game (unused currently)
maximum users : 40
# Define the maximum stack size of the stack machine. This stack will also
# contain all local variables and arguments. (unused currently)
evaluator stack size : 1000
# Define the size of the compiler stack. This defines how complex
# expressions the compiler can parse. (unused currently)
compiler stack size : 200
# Define the maximum call depth for functions. (unused currently)
maximum call depth : 30
# There is a hash table for living objects, used by find_living().
# (unused currently)
living hash table size : 100

150
bin/mudos.cfg.orig Normal file
View File

@ -0,0 +1,150 @@
###############################################################################
# Customizable runtime config file for MudOS #
# NOTE: All paths specified here are relative to the mudlib directory except #
# for mudlib directory, and binary directory. #
# Lines beginning with a # or a newline are ignored. #
###############################################################################
# name of this mud
name : DeadSoulsNew
# port number to accept users on
external_port_1 : telnet 6666
# pathname of mudlib
mudlib directory : ../lib
# pathname of driver/config dir
binary directory : ../bin
# the address server is an external program that lets the mud translate
# internet names to numbers (and vice versa). select an unused port.
address server ip : localhost
address server port : 8099
# fd6 stuff is what allows portbind to work properly. If
# you want to have the mud accept connections on port 23 but run
# as non-root, you uncomment the two fd6 lines below and issue the
# appropriate portbind command to start the mud.
#fd6 port : 23
#fd6 kind : telnet
# debug.log and author/domain stats are stored here
log directory : /log
# the directories which are searched by #include <...>
# for multiple dirs, separate each path with a ':'
include directories : /secure/include:/include
# Directory to save binaries in. (if BINARIES is defined)
save binaries directory : /secure/save/binaries
# the file which defines the master object
master file : /secure/daemon/master
# the file where all global simulated efuns are defined.
simulated efun file : /secure/sefun/sefun
# file to swap out objects; not used if time to swap is 0
swap file : /secure/tmp/swap
# alternate debug.log file name (assumed to be in specified 'log directory')
debug log file : runtime
# This is an include file which is automatically #include'd in all objects
global include file : <global.h>
# if an object is left alone for a certain time, then the
# function clean_up will be called. This function can do anything,
# like destructing the object. If the function isn't defined by the
# object, then nothing will happen.
# This time should be substantially longer than the swapping time.
time to clean up : 2100000000
# How long time until an unused object is swapped out.
# Machine with too many players and too little memory: 900 (15 minutes)
# Machine with few players and lot of memory: 10000
# Machine with infinite memory: 0 (never swap).
time to swap : 0
# How many seconds until an object is reset again.
time to reset : 2100000000
# Maximum number of bits in a bit field. They are stored in printable
# strings, 6 bits per byte.
maximum bits in a bitfield : 1200
# Max number of local variables in a function.
maximum local variables : 35
# Maximum amount of "eval cost" per thread - execution is halted when
# it is exceeded.
maximum evaluation cost : 5000000
# This is the maximum array size allowed for one single array.
maximum array size : 64000
# This is the maximum allowed size of a variable of type 'buffer'.
maximum buffer size : 400000
# Max size for a mapping
maximum mapping size : 64000
# Max inherit chain size
inherit chain size : 30
# maximum length of a string variable
maximum string length : 200000
# Max size of a file allowed to be read by 'read_file()'.
maximum read file size : 200000
# max number of bytes you allow to be read and written with read_bytes
# and write_bytes
maximum byte transfer : 10000
# Reserve an extra memory area from malloc(), to free when we run out
# of memory and allow the mudlib to shutdown.
# If this value is 0, no area will be reserved.
reserved size : 0
# Define the size of the shared string hash table. This number should
# a prime, probably between 1000 and 30000; if you set it to about 1/5
# of the number of distinct strings you have, you will get a hit ratio
# (number of comparisons to find a string) very close to 1, as found strings
# are automatically moved to the head of a hash chain. You will never
# need more, and you will still get good results with a smaller table.
hash table size : 7001
# Object hash table size.
# Define this like you did with the strings; probably set to about 1/4 of
# the number of objects in a game, as the distribution of accesses to
# objects is somewhat more uniform than that of strings.
object table size : 1501
# default no-matching-action message
default fail message : What?
# default message when error() occurs (optional)
default error message : Something *REALLY* bad just happened.
###############################################################################
# The following aren't currently used or implemented (yet) #
###############################################################################
# maximum number of users in the game (unused currently)
maximum users : 40
# Define the maximum stack size of the stack machine. This stack will also
# contain all local variables and arguments. (unused currently)
evaluator stack size : 1000
# Define the size of the compiler stack. This defines how complex
# expressions the compiler can parse. (unused currently)
compiler stack size : 200
# Define the maximum call depth for functions. (unused currently)
maximum call depth : 30
# There is a hash table for living objects, used by find_living().
# (unused currently)
living hash table size : 100

65
bin/startmud Normal file
View File

@ -0,0 +1,65 @@
#!/bin/bash
if [ $1 ]
then
export DRIVER=$1
else
export DRIVER="driver"
fi
if [ $2 ]
then
export CFG="mudos."$2".cfg"
else
export CFG="mudos.cfg"
fi
echo "driver: "$DRIVER
echo "cfg: "$CFG
# Specify your mud dir here.
MUDHOME=""
# It has been reported that non-US users have problems
# with some .o files because their systems default to
# commas for decimal notation and not periods. The
# following language exports are for the benefit of
# people who run into this problem.
LANG=en_US
LANGUAGE=en_US
LC_ALL=en_US
# Uncomment the following if you're on Solaris 10 with a
# 32 bit compiler and need to get around the 256 FD limit.
# NOTE: It will break things. The correct fix is to compile
# with a 64 bit compiler and set ENABLE_M64 in build.FluffOS to 1
#LD_PRELOAD_32=/usr/lib/extendedFILE.so.1
#export LD_PRELOAD_32
export LANG LANGUAGE LC_ALL MUDHOME
umask 007
ulimit -a
ulimit -n 2048
ulimit -a
while [ true ]; do
cat $MUDHOME/lib/log/runtime >> $MUDHOME/lib/log/runtime.boot
rm $MUDHOME/lib/log/runtime
if [ $MUDHOME ] && [ -f $MUDHOME/bin/$DRIVER ] && [ -f $MUDHOME/bin/$CFG ]
then
$MUDHOME/bin/$DRIVER $MUDHOME/bin/$CFG
else
if [ -f ./$DRIVER ] && [ -f ./$CFG ]
then
./$DRIVER ./$CFG
else
break
fi
fi
done

15
extra/README.txt Normal file
View File

@ -0,0 +1,15 @@
Extras directory
- restore_cfg If you screw up your mudos.cfg file, you can use this to
get it back.
- I added a creremote/ dir with stuff you'll need to take advantage
of Dead Souls RCP support. However, the stuff in this dir is not
Dead Souls stuff, so it is not supported by me.
- crat/ has some scripts I use, if you understand them, great, if
not, don't worry. They're not for you.
- wolfpaw/ has some includes and stuff that are necessary to
run in one of the servers provided by Wolfpaw. If you're not
a customer of theirs, disregard that stuff.

24
extra/crat/column_parse Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/bash
#echo $#
if [ $# -eq 4 ]
then
#echo `awk {'print $1 " " $2 " " $3 " " $4'}`
#echo "whee"
echo $1 $2 $3 $4 >> copyfiles3
else
#echo "Oh NOES!"
if echo $1 | grep "\cp"
then
#echo "ok trying to rewrite"
export FIX=`(echo $3 | perl -pi -e s/"new\/"/"next\/"/)`
echo $1 $2 $3 $FIX
echo $1 $2 $3 $FIX >> copyfiles3
else
export BAR=`(echo $3 | perl -pi -e s/"\/lib"/"next\/lib"/)`
#echo "NEVER MIND, it's a delete: " $1 $2 $BAR $4
echo $1 $2 $BAR $4 >> copyfiles3
fi
fi
echo "ok then"

55
extra/crat/d.c Normal file
View File

@ -0,0 +1,55 @@
#include <lib.h>
#include <save.h>
inherit LIB_DAEMON;
mixed pkginst, name, category, arch, version, desc, pstamp, instdate, status, basedir, vendor, hotline, email;
static void create() {
}
mixed b(string file){
string ret = "", foo = read_file(file);
string *foo_arr = explode(foo, "\n\n");
int i = 0;
string path = path_prefix(file);
string fname = last_string_element(file, "/");
string thingy;
tc("foo_arr: "+sizeof(foo_arr));
foreach(string tmp in foo_arr){
string tmp2, sub = "", *lines = explode(tmp, "\n");
pkginst = name = category = arch = version = desc = pstamp = instdate = status = basedir = vendor = hotline = email = 0;
foreach(string line in lines){
line = trim(line);
if(!strsrch(line, "PKGINST:")) pkginst = replace_string(line, "PKGINST: ", "") + "^";
if(!strsrch(line, "NAME:")) name = replace_string(line, "NAME: ", "") + "^";
if(!strsrch(line, "CATEGORY:")) category = replace_string(line, "CATEGORY: ", "") + "^";
if(!strsrch(line, "ARCH:")) arch = replace_string(line, "ARCH: ", "") + "^";
if(!strsrch(line, "VERSION:")) version = replace_string(line, "VERSION: ", "") + "^";
if(!strsrch(line, "DESC:")) desc = replace_string(line, "DESC: ", "") + "^";
if(!strsrch(line, "PSTAMP:")) pstamp = replace_string(line, "PSTAMP: ", "") + "^";
if(!strsrch(line, "INSTDATE:")) instdate = replace_string(line, "INSTDATE: ", "") + "^";
if(!strsrch(line, "STATUS:")) status = replace_string(line, "STATUS: ", "") + "^";
if(!strsrch(line, "BASEDIR:")) basedir = replace_string(line, "BASEDIR: ", "") + "^";
if(!strsrch(line, "VENDOR:")) vendor = replace_string(line, "VENDOR: ", "") + "^";
if(!strsrch(line, "HOTLINE:")) hotline = replace_string(line, "HOTLINE: ", "") + "^";
if(!strsrch(line, "EMAIL:")) email = replace_string(line, "EMAIL: ", "") + "^";
}
foreach(string element in ({"pkginst", "name", "category", "arch", "version", "basedir", "vendor", "desc", "pstamp", "instdate", "hotline", "status", "email"})){
mixed mx = fetch_variable(element);
string ret2;
if(!mx) ret2 = "NULL^";
else ret2 = mx;
sub += ret2;
}
i++;
//tc("file: "+file+i);
//write_file(file+i, ""+tmp);
//tc("\n\ntmp: "+tmp);
tc("\n\nsub: "+sub);
ret += sub + "\n";
}
thingy = path+"/"+time()+"_"+fname;
tc("thingy: "+thingy);
write_file(thingy, ret, 1);
}

6
extra/crat/enters Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
if !(grep $1 /tmp/foo/diff.txt); then
\rm -f $1
fi

3
extra/crat/gdbinit Normal file
View File

@ -0,0 +1,3 @@
handle SIGPIPE nostop noprint pass
set print pretty on
run ./mudos.cfg

14
extra/crat/indentall Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
rm /tmp/thingy.txt
for i in `find .|grep "\.c"|grep -v "\.cfg"|grep -v "\.css"`
do
if cat $i | grep "@EndText"
then
echo "Skipping $i"
echo $i >> /tmp/thingy.txt
else
echo "Indenting "$i
vim -c "set tabstop=4 shiftwidth=4 expandtab retab" -esc "normal gg=G" -c "wq" $i
fi
done

167
extra/crat/livepatch Normal file
View File

@ -0,0 +1,167 @@
# syntax: livepatch ds2.9a17 limpet [1]
export INDENT=$3
export NEWLIB=$2
export OLDLIB=$1
#vi /root/updaterr$OLD\_r$NEW.c
cd /
date
mkdir /tmp/foo 1>/dev/null 2>/dev/null
rm -rf /tmp/foo/*
cd /tmp/foo
unzip -qd $OLDLIB $HOME/mud/$OLDLIB.zip
#unzip -qd $NEWLIB /misc/data/mud/deadsouls/$NEWLIB.zip
cd /mud/
chmod -R 755 $NEWLIB/lib
tar cfp - $NEWLIB|(cd /tmp/foo;tar xfp -)
cd /tmp/foo
mv $OLDLIB/*/* $OLDLIB/
#mv $NEWLIB/*/* $NEWLIB/
#\rm -f $OLDLIB/lib/secure/include/config.h
#\rm -f $NEWLIB/lib/secure/include/config.h
\rm -f $OLDLIB/lib/secure/cfg/groups*cfg
\rm -f $OLDLIB/lib/secure/cfg/mudos*cfg
\rm -f $OLDLIB/lib/secure/cfg/mudos*win32
\rm -f $NEWLIB/lib/secure/cfg/groups*cfg
\rm -f $NEWLIB/lib/secure/cfg/mudos*cfg
\rm -f $NEWLIB/lib/secure/cfg/mudos*win32
\rm -rf $OLDLIB/lib/secure/save
\rm -rf $OLDLIB/lib/save
\rm -rf $OLDLIB/lib/secure/log
\rm -rf $OLDLIB/lib/secure/upgrades
\rm -rf $OLDLIB/lib/tmp
\rm -rf $OLDLIB/lib/daemon/tmp
\rm -rf $OLDLIB/lib/open
\rm -rf $OLDLIB/lib/log
\rm -rf $NEWLIB/lib/log
\rm -rf $NEWLIB/lib/tmp
\rm -rf $NEWLIB/lib/daemon/tmp
\rm -rf $NEWLIB/lib/open
\rm -rf $NEWLIB/lib/secure/save
\rm -rf $NEWLIB/lib/secure/log
\rm -rf $NEWLIB/lib/secure/upgrades
\rm -rf $NEWLIB/lib/save
\rm -r $NEWLIB/lib/core $OLDLIB/lib/core 1>/dev/null 2>/dev/null
\rm -r $NEWLIB/lib/secure/sefun/native_version.c $OLDLIB/lib/secure/sefun/native_version.c
\cp -f $NEWLIB/lib/secure/daemon/update.patch $NEWLIB/lib/secure/daemon/update.c
\cp -f $OLDLIB/lib/secure/daemon/update.patch $OLDLIB/lib/secure/daemon/update.c
mkdir $OLDLIB/lib/www/cgi 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/lib/daemons 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/verbs/builders 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/cmds/builders 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/secure/cmds/builders 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/secure/daemon/imc2server 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/lib/daemon 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/lib/daemon/include 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/adm 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/armor 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/doors 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/etc 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/meals 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/npc 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/obj 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/room 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/save 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/txt 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/virtual 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/cave/weap 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/doc/phints 1>/dev/null 2>/dev/null
mkdir $OLDLIB/lib/domains/campus/chamber 1>/dev/null 2>/dev/null
if [ $3 ]
then
echo "indenting"
cd $NEWLIB/lib
/contrib/indentall
cd ../../$OLDLIB/lib
/contrib/indentall
cd ../../
else
echo "not indenting"
fi
mv $NEWLIB/lib/secure/lib/connect.c $NEWLIB/lib/secure/lib/connect.real
diff -rq $OLDLIB/lib $NEWLIB/lib > diff.txt
perl -pi -e s/"\:\ "/"\/"/g diff.txt
cd $NEWLIB/
find ./lib -type f -exec /contrib/enters {} \;
rm lib/secure/include/config.h
rm lib/secure/cfg/mudos.cfg
rm lib/secure/cfg/groups.cfg
\rm -rf lib/tmp
\rm -rf lib/log
\rm -rf lib/secure/log
\rm -rf lib/open
\rm -rf lib/secure/save
\rm -rf lib/secure/log
\rm -rf lib/secure/tmp
\rm -rf lib/secure/upgrades
\rm -rf lib/save
tar cfp ../patch.tar lib
cd ..
mv $NEWLIB fukt
unzip -qd $NEWLIB /export/home/$HOME/mud/$NEWLIB.zip
mv $NEWLIB/*/* $NEWLIB/
cd $OLDLIB
tar xfp ../patch.tar
cd ..
\rm -rf $NEWLIB/lib/tmp
\rm -rf $NEWLIB/lib/log
\rm -rf $NEWLIB/lib/secure/log
\rm -rf $NEWLIB/lib/open
\rm -rf $NEWLIB/lib/secure/save
\rm -rf $NEWLIB/lib/secure/log
\rm -rf $NEWLIB/lib/secure/tmp
\rm -rf $NEWLIB/lib/secure/upgrades
\rm -rf $NEWLIB/lib/save
diff -rq $OLDLIB/ $NEWLIB/ > diff2.txt
echo "Anything after this is an imperfection except for the connect.c"
cat diff2.txt
\mv -f lib lib.foo 1>/dev/null 2>/dev/null
tar xfp patch.tar
find ./lib -type f|sort -dr > lib.txt
\mv -f patch patch.foo 1>/dev/null 2>/dev/null
mkdir patch
#\cp -f ~/updaterr$OLD\_r$NEW.c lib/secure/daemon/update.c
\cp -f ~/update.blank lib/secure/daemon/ 1>/dev/null 2>/dev/null
\cp -f ~/instructions\_$OLD\_$NEW.txt patch/instructions.txt 1>/dev/null 2>/dev/null
chown -R 513:513 lib 1>/dev/null 2>/dev/null
chmod -R 775 lib 1>/dev/null 2>/dev/null
mv lib patch/
cat diff2.txt
echo "End imperfections."
date
echo ""
cd patch/lib
find ./ -type f|grep -v "upgrades\.txt" |grep -v "\.html"|grep -v "\.gif" |grep -v "\.o" |grep -v "/news/" > upgrades.txt
find ./ -type f|grep "\.orig" >> upgrades.txt
perl -pi -e s/"\.\/lib"/"\/lib"/g upgrades.txt
perl -pi -e s/"\.\/"/"\/"/g upgrades.txt
echo "/secure/lib/connect.c" >> upgrades.txt
echo "/secure/daemon/master.h" >> upgrades.txt
cp upgrades.txt /tmp/foo/
\cp -f upgrades.txt /mud/$NEWLIB/lib/
echo "-------"
cat upgrades.txt
chmod 755 upgrades.txt
echo "-------"

136
extra/crat/newpatch Normal file
View File

@ -0,0 +1,136 @@
#!/bin/bash -x
export NEWLIB=$2
export OLDLIB=$1
#vi /root/updaterr$OLD\_r$NEW.c
cd /
date
mkdir /tmp/foo
rm -rf /tmp/foo/*
cd /tmp/foo
unzip -qd $OLDLIB $HOME/mud/$OLDLIB.zip
unzip -qd $NEWLIB $HOME/mud/$NEWLIB.zip
mv $OLDLIB/*/* $OLDLIB/
mv $NEWLIB/*/* $NEWLIB/
#\rm -f $OLDLIB/lib/secure/include/config.h
#\rm -f $NEWLIB/lib/secure/include/config.h
\rm -f $OLDLIB/lib/secure/cfg/groups.cfg
\rm -f $OLDLIB/lib/secure/cfg/mudos.cfg
\rm -f $OLDLIB/lib/secure/cfg/mudos.win32
\rm -f $NEWLIB/lib/secure/cfg/groups.cfg
\rm -f $NEWLIB/lib/secure/cfg/mudos.cfg
\rm -f $NEWLIB/lib/secure/cfg/mudos.win32
\rm -r $NEWLIB/lib/core $OLDLIB/lib/core
\rm -r $NEWLIB/lib/secure/sefun/native_version.c $OLDLIB/lib/secure/sefun/native_version.c
#\rm -r $NEWLIB/lib/secure/sefun/mud_info.c $OLDLIB/lib/secure/sefun/mud_info.c
\cp -f $NEWLIB/lib/secure/lib/connect.real $NEWLIB/lib/secure/lib/connect.c
#\rm -r $NEWLIB/lib/secure/lib/connect.c $OLDLIB/lib/secure/lib/connect.c
\cp -f $NEWLIB/lib/secure/daemon/update.patch $NEWLIB/lib/secure/daemon/update.c
\cp -f $OLDLIB/lib/secure/daemon/update.patch $OLDLIB/lib/secure/daemon/update.c
echo "foo" > $NEWLIB/lib/secure/upgrades/files/0^0tmp0^0foo.txt
mkdir $OLDLIB/lib/www/cgi
mkdir $OLDLIB/lib/lib/daemons
mkdir $OLDLIB/lib/verbs/builders
mkdir $OLDLIB/lib/cmds/builders
mkdir $OLDLIB/lib/secure/cmds/builders
mkdir $OLDLIB/lib/secure/daemon/imc2server
mkdir $OLDLIB/lib/lib/daemon
mkdir $OLDLIB/lib/lib/daemon/include
mkdir $OLDLIB/lib/domains/cave
mkdir $OLDLIB/lib/domains/cave/adm
mkdir $OLDLIB/lib/domains/cave/armor
mkdir $OLDLIB/lib/domains/cave/doors
mkdir $OLDLIB/lib/domains/cave/etc
mkdir $OLDLIB/lib/domains/cave/meals
mkdir $OLDLIB/lib/domains/cave/npc
mkdir $OLDLIB/lib/domains/cave/obj
mkdir $OLDLIB/lib/domains/cave/room
mkdir $OLDLIB/lib/domains/cave/save
mkdir $OLDLIB/lib/domains/cave/txt
mkdir $OLDLIB/lib/domains/cave/virtual
mkdir $OLDLIB/lib/domains/cave/weap
mkdir $OLDLIB/lib/doc/phints
mkdir $OLDLIB/lib/domains/campus/chamber
mkdir $OLDLIB/lib/domains/amigara
mkdir $OLDLIB/lib/domains/amigara/adm
mkdir $OLDLIB/lib/domains/amigara/armor
mkdir $OLDLIB/lib/domains/amigara/doors
mkdir $OLDLIB/lib/domains/amigara/etc
mkdir $OLDLIB/lib/domains/amigara/meals
mkdir $OLDLIB/lib/domains/amigara/npc
mkdir $OLDLIB/lib/domains/amigara/obj
mkdir $OLDLIB/lib/domains/amigara/room
mkdir $OLDLIB/lib/domains/amigara/save
mkdir $OLDLIB/lib/domains/amigara/txt
mkdir $OLDLIB/lib/domains/amigara/virtual
mkdir $OLDLIB/lib/domains/amigara/weap
mkdir $OLDLIB/lib/doc/cheats
if [ $3 ]
then
echo "indenting"
cd $NEWLIB/lib
/contrib/indentall
cd ../../$OLDLIB/lib
/contrib/indentall
cd ../../
else
echo "not indenting"
fi
cd /tmp/foo
diff -rq $OLDLIB/lib $NEWLIB/lib > diff.txt
perl -pi -e s/"\:\ "/"\/"/g diff.txt
cd $NEWLIB/
find ./lib -type f -exec /contrib/enters {} \;
rm lib/secure/include/config.h
rm lib/secure/cfg/mudos.cfg
rm lib/secure/cfg/groups.cfg
tar cfp ../patch.tar lib
cd ..
mv $NEWLIB fukt
unzip -qd $NEWLIB /export/home/$HOME/mud/$NEWLIB.zip
mv $NEWLIB/*/* $NEWLIB/
cd $OLDLIB
tar xfp ../patch.tar
cd ..
diff -rq $OLDLIB/ $NEWLIB/ > diff2.txt
echo "Anything after this is an imperfection except for the connect.c"
cat diff2.txt
\mv -f lib lib.foo
tar xfp patch.tar
find ./lib -type f|sort -dr > lib.txt
\mv -f patch patch.foo
mkdir patch
#\cp -f ~/updaterr$OLD\_r$NEW.c lib/secure/daemon/update.c
\cp -f ~/update.blank lib/secure/daemon/
\cp -f ~/instructions\_$OLD\_$NEW.txt patch/instructions.txt
chown -R 513:513 lib
chmod -R 775 lib
mv lib patch/
date
cat diff2.txt
cd patch/lib
find ./ -type f|grep -v "\.html"|grep -v "\.gif" |grep -v "\.o" |grep -v "/news/" > upgrades.txt
find ./ -type f|grep "\.orig" >> upgrades.txt
perl -pi -e s/"\.\/lib"/"\/lib"/g upgrades.txt
perl -pi -e s/"\.\/"/"\/"/g upgrades.txt
mv upgrades.txt ../

182
extra/crat/newver Normal file
View File

@ -0,0 +1,182 @@
#!/bin/bash -x
export INDENT=$3
export NEWLIB=$2
export OLDLIB=$1
cd /
rm -rf /run/shm/foo
mkdir /run/shm/foo
rm -rf /tmp/foo
ln -s /run/shm/foo /tmp/foo
cd /run/shm/foo
unzip -qd $OLDLIB $HOME/mud/$OLDLIB.zip
mv $OLDLIB/ds* next
mkdir new
cd /mud/alpha
tar cfp - . |(cd /run/shm/foo/new;tar xfp -)
rm -rf /run/shm/foo/new/lib/secure/daemon/i3router/bak
rm -rf /run/shm/foo/next/lib/secure/daemon/i3router/bak
rm -rf /run/shm/foo/new/lib/secure/daemon/imc2server/bak
rm -rf /run/shm/foo/next/lib/secure/daemon/imc2server/bak
rm -rf /run/shm/foo/new/lib/upgrades.txt
rm -rf /run/shm/foo/next/lib/upgrades.txt
chmod -R a+r /run/shm/foo/next/lib
chmod -R a+r /run/shm/foo/new/lib
rm -rf /run/shm/foo/new/lib/daemon/tmp
rm -rf /run/shm/foo/new/lib/secure/upgrades
rm -rf /run/shm/foo/new/lib/tmp
mv /run/shm/foo/new/lib/realms/template .
rm -rf /run/shm/foo/new/lib/realms/*
rm -rf /run/shm/foo/new/lib/open/*
mv template /run/shm/foo/new/lib/realms/
rm -rf /run/shm/foo/new/lib/log
rm -rf /run/shm/foo/new/lib/secure/log
rm -rf /run/shm/foo/new/lib/secure/save/postal
rm -rf /run/shm/foo/new/lib/secure/save/players
rm -rf /run/shm/foo/new/lib/secure/save/creators
\rm -rf /run/shm/foo/*~
\rm -rf /run/shm/foo/*/*~
\rm -rf /run/shm/foo/*/*/*~
\rm -rf /run/shm/foo/*/*/*/*~
\rm -rf /run/shm/foo/*/*/*/*/*~
\rm -rf /run/shm/foo/*/*/*/*/*/*~
\rm -rf /run/shm/foo/*/*/*/*/*/*/*~
\rm -rf /run/shm/foo/*/*/*/*/*/*/*/*~
\rm -rf /run/shm/foo/*/*/*/*/*/*/*/*/*~
mkdir /run/shm/foo/next/lib/www/cgi
mkdir /run/shm/foo/next/lib/cmds/builders
mkdir /run/shm/foo/next/lib/secure/cmds/builders
mkdir /run/shm/foo/next/lib/verbs/builders
mkdir /run/shm/foo/next/lib/domains/cave
mkdir /run/shm/foo/next/lib/domains/cave/room
mkdir /run/shm/foo/next/lib/domains/cave/npc
mkdir /run/shm/foo/next/lib/domains/cave/weap
mkdir /run/shm/foo/next/lib/domains/cave/obj
mkdir /run/shm/foo/next/lib/domains/cave/meals
mkdir /run/shm/foo/next/lib/domains/cave/etc
mkdir /run/shm/foo/next/lib/domains/cave/doors
mkdir /run/shm/foo/next/lib/domains/cave/armor
mkdir /run/shm/foo/next/lib/domains/cave/adm
mkdir /run/shm/foo/next/lib/domains/cave/save
mkdir /run/shm/foo/next/lib/domains/cave/txt
mkdir /run/shm/foo/next/lib/domains/cave/virtual
mkdir /run/shm/foo/next/doc/phints
mkdir /run/shm/foo/next/lib/domains/campus/chamber
cd /run/shm/foo
\rm -f new/lib/secure/cfg/*.????.cfg
\rm -f new/lib/secure/cfg/*.????.win32
\rm -f new/lib/secure/include/*.????.h
\rm -f new/lib/secure/cfg/mudos.autobak.????
\rm -f new/lib/news/*.????
\rm -f new/lib/domains/campus/save/charl*
\rm -f next/lib/domains/campus/save/charl*
\rm -f next/lib/domains/town/save/charit*
\cp -f new/lib/secure/daemon/update.patch next/lib/secure/daemon/update.patch
\mv -f new/lib/secure/lib/connect.c new/lib/secure/lib/connect.real
\cp -f new/lib/secure/lib/connect.first.c new/lib/secure/lib/connect.c
\cp -f new/lib/secure/save/backup/config.orig new/lib/secure/include/config.h
\cp -f new/lib/secure/save/backup/config.orig next/lib/secure/save/backup/config.orig
\cp -f new/lib/secure/save/backup/secrets.orig new/lib/secure/include/secrets.h
\cp -f new/lib/secure/save/backup/secrets.orig next/lib/secure/save/backup/secrets.orig
\cp -f new/lib/secure/daemon/imc2.c next/lib/secure/save/backup/imc2.orig
\rm -f next/lib/lib/remote.c
\rm -f new/lib/lib/remote.c
if [ $3 ]
then
echo "indenting new"
#cd $NEWLIB/lib
cd new/lib
/contrib/indentall
cd ../../$OLDLIB/lib
echo ""
echo "indenting next"
sleep 5
/contrib/indentall
cd ../../
else
echo "not indenting"
fi
#/opt/sfw/bin/gdiff -rq new/lib next/lib > diff.txt
cd /run/shm/foo
diff -rq new/lib next/lib > diff.txt
perl -pi -e s/"\:\ "/"\/"/g diff.txt
perl -pi -e s/"\ and\ "/"\ "/g diff.txt
perl -pi -e s/"\ differ"/"\ "/g diff.txt
echo "#!/bin/bash" > diff.sh.1
echo "" >> diff.sh.1
cat diff.txt |grep Files >> diff.sh.1
perl -pi -e s/"Files\ "/"\\\\cp\ \-f\ "/g diff.txt
perl -pi -e s/"Only\ in\ next"/"\\\\rm\ \-f\ "/g diff.txt
perl -pi -e s/"Only\ in\ "/"\\\\cp\ \-rf\ "/g diff.txt
perl -pi -e s/"Files\ "/"diff\ -Nur\ "/g diff.sh.1
cat diff.txt | grep -v "\.prime" | grep -v "lib/core" |grep -v "\.o"|grep -v CMD_EVAL_TMP_FILE|grep -v "lib/secure/tmp/"|grep -v "/lib/estates/"|grep -v "lib/secure/save"| grep -v "lib/save/"|grep -v "/mudos.cfg" |grep -v "/groups.cfg" |grep -v "\.bak"|grep -v "\.swp"> diff2.txt
cat diff.sh.1 | grep -v CMD_EVAL_TMP_FILE|grep -v "lib/secure/tmp/"|grep -v "/lib/estates/"|grep -v "lib/secure/save"| grep -v "lib/save/"|grep -v "/mudos.cfg" |grep -v "/groups.cfg" |grep -v "\.bak"|grep -v "\.swp"> diff.sh
chmod 755 diff.sh
chmod 755 diff.sh.1
#vim diff.txt
#echo "#!/usr/bin/bash" > copyfiles3
echo "#!/bin/bash" > copyfiles3
chmod 755 copyfiles3
cat diff2.txt > copyfiles
cat diff2.txt > copyfiles2
perl -pi -e s/"\ "/"\^\^"/g copyfiles2
#/contrib/parse_test
for i in `cat copyfiles2`
do
export LINE=`(echo $i | perl -pi -e s/"\^\^"/"\ "/g)`
#echo $LINE
echo `/contrib/column_parse $LINE`
done
echo "mkdir next/lib/secure/log/intermud" >> copyfiles3
echo "rm -f /run/shm/foo/next/lib/upgrades.txt" >> copyfiles3
echo "cp -f next/lib/log/open/foo.txt next/lib/secure/log/intermud/" >> copyfiles3
echo "cp -f new/lib/save/books.o next/lib/save/" >> copyfiles3
echo "cp -f new/lib/save/soul.o next/lib/save/" >> copyfiles3
echo "cp -f new/lib/save/rooms.o next/lib/save/" >> copyfiles3
echo "cp -f new/lib/save/races.o next/lib/save/" >> copyfiles3
echo "cp -f new/lib/save/map.o next/lib/save/" >> copyfiles3
echo "cp -f new/lib/save/economy.o next/lib/save/" >> copyfiles3
echo "cp -f new/lib/save/classes.o next/lib/save/" >> copyfiles3
echo "cp -f new/lib/secure/save/inet.o next/lib/secure/save/" >> copyfiles3
echo "cp -f new/lib/secure/save/functions.o next/lib/secure/save/" >> copyfiles3
echo "cp -f new/lib/secure/save/files.o next/lib/secure/save/" >> copyfiles3
echo "cp -f /contrib/newver next/extra/crat/" >> copyfiles3
echo "cp -f /contrib/newpatch next/extra/crat/" >> copyfiles3
echo "cp -f /contrib/livepatch next/extra/crat/" >> copyfiles3
echo "cp -f /contrib/indentall next/extra/crat/" >> copyfiles3
#BLAH BLAH COPY COPY
#cd /run/shm/foo
#mv next $NEWLIB
#chown -R 513:513 $NEWLIB
#chmod -R g+rwx $NEWLIB
#zip -q9r $NEWLIB.zip $NEWLIB
#\cp -f $NEWLIB.zip /mnt/data/mud/deadsouls/
#\cp -f $NEWLIB.zip /mnt/media/open/
#\cp -f $NEWLIB.zip /export/home/$HOME/mud/
bash ./diff.sh.1 > /run/shm/foo/diff.out

34
extra/crat/rr Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
cd i3router
rm *
wget http://$1/router/blacklist.cfg
wget http://$1/router/broadcast_chanlist.h
wget http://$1/router/broadcast_mudlist.h
wget http://$1/router/clean_fd.h
wget http://$1/router/core_stuff.h
wget http://$1/router/debug.h
wget http://$1/router/funcs.h
wget http://$1/router/hosted_channels.h
wget http://$1/router/irn.h
wget http://$1/router/process_channel.h
wget http://$1/router/process_startup_req.h
wget http://$1/router/read_callback.h
wget http://$1/router/readme.txt
wget http://$1/router/remove_mud.h
wget http://$1/router/rsocket.c
wget http://$1/router/send_chanlist_reply.h
wget http://$1/router/send_error.h
wget http://$1/router/send_full_mudlist.h
wget http://$1/router/send_mudlist_updates.h
wget http://$1/router/send_startup_reply.h
wget http://$1/router/server.c
wget http://$1/router/server_log.h
cd ..
mkdir imc2server
cd imc2server
rm *
wget http://$1/server/server.c
wget http://$1/server/server_log.h
wget http://$1/server/ssocket.c

View File

@ -0,0 +1,81 @@
This is part of the Foundation II lib and NOT part of
Dead Souls AT ALL. It's provided as a convenience, but
if it doesn't work, or screws your lib, or you get pwnt
because of it, it's not my fault, and not my problem.
Creremote allows you to edit stuff remotely.
Basically, a creremote session looks like this:
$ ./creremote
CreRemote> connect foo
Character name: cratylus
Password:
foo ip: 192.168.0.70
port: 6656
Connection to Dead Souls.
ls
fee> Directory: /realms/cratylus/
.plan .profile
adm/ area/ bak/
cmds/ customdefs.h log/
tmp/ workroom.bak workroom.c
quit
CreRemote> exit
$
The really cool thing is that you can cd to your
homedir, and from there type, for example:
edit workroom.c
And you'll be editing workroom.c in your local editor, so
you can use vi, or whatever. When you finish, the file
is magically sent to the mud...no need for ftp.
Another cool thing is that it works through routers and
firewalls, so assuming you've set up your router's
port-forwarding correctly, you can use this where ftp
was not available.
Summary:
PROS
* Can cross firewalls (if you do your port forwarding right)
* Uses authentication based on your mud privs.
* Lets you edit files with your favorite UNIX editor (yay!).
CONS
* Probably insecure as hell.
* The windows version is unavailable. Only creremote for UNIX works.
* It probably is buggy. Feel free to submit fixes, but don't expect me to fix it myself.
Instructions:
1) If you're using Solaris, edit creremote and make this line:
$SOCK_STREAM = 1;
Look like this:
$SOCK_STREAM = 2;
2) Copy creremote to your /usr/local/bin/ or wherever you put such stuff.
3) Copy remote.c to $MUDHOME/lib/lib/remote.c
4) You may need to enable it with the mudconfig command, just log into
the mud and type: help mudconfig . As of Alpha 17, updating /secure/daemon/inet
is enough to activate RCP support. Type: netstat to know if the RCP port is open.
5) You may need to edit this line:
$Editor = '/usr/bin/vi';
To reflect your favorite editor, such as:
$Editor = '/usr/local/bin/gvim';
6) Type: ./creremote or /usr/local/bin/creremote, or whatever.
7) Type: connect foo, where "foo" is what you'll call this connection, not the mud.
8) Enter your mud character name.
9) Enter your mud character password.
10) Enter the ip address of the mud.
11) Enter the RCP PORT of the mud (NOT the telnet port). This is usually 10 less
than the telnet port, so if your mud is running on port 6666, the RCP port will be 6656
12) You should connect, unless you messed up or you have network problems. Play
around, enjoy. If it doesn't work, figure it out and tell me what fixed it.
13) To disconnect, type: quit
14) To close creremote, type: exit
-Cratylus
28Nov06

254
extra/creremote/creremote Normal file
View File

@ -0,0 +1,254 @@
#!/usr/bin/perl
$MUD = "";
$Character = "";
$Password = "";
$Machine = "";
$Port = 0;
$Editor = '/usr/bin/vi';
$LocalEditFile = "/tmp/creremote.$$";
print "CreRemote> ";
while(<>) {
chop;
if( $_ ) {
@tmp = split(/ /, $_);
$cmd = shift(@tmp);
$args = join(' ', @tmp);
if( ! $MUD ) {
if( $cmd eq "connect" ) {
&cmdConnect($args);
}
elsif( $cmd eq "help" ) {
&cmdHelp($args);
}
elsif( $cmd eq "exit" ) {
exit;
}
elsif( substr($cmd, 0, 1) eq "!" ) {
system(substr($cmd, 1, length($cmd) - 1));
}
else {
print "Bad command: $cmd $args\n";
}
}
else {
if( $cmd eq "connect" ) {
print "You are already connected to $MUD.\n";
}
elsif( $cmd eq "quit" ) {
close(S);
$MUD = "";
$Buffer = "";
$InEdit = 0;
$EditFile = "";
}
elsif( $cmd eq "edit" ) {
$EditFile = $args;
system("rm $LocalEditFile") if -f $LocalEditFile;
print S "$cmd $args\n";
$x = 1;
while( $x ) { if( -f $LocalEditFile ) { $x = 0; } }
@bugger = stat($LocalEditFile);
$sz = $bugger[7];
$tme = $bugger[9];
system("$Editor $LocalEditFile");
@bugger = stat($LocalEditFile);
if( $bugger[7] == 0 || $tme == $bugger[9] ) {
$EditFile = "";
system("rm $LocalEditFile");
}
else {
$Buffer = "";
open(LEF, $LocalEditFile);
while(<LEF>) { $Buffer = "$Buffer$_"; }
close(LEF);
print S "100 ".length($Buffer)." $EditFile\n";
$EditFile = "";
sleep(2);
print S $Buffer;
$Buffer = "";
system("rm $LocalEditFile");
}
}
elsif( $cmd eq "100" ) {
print "Illegal command.\n";
}
elsif( substr($cmd, 0, 1) eq "!" ) {
system(substr($cmd, 1, length($cmd) - 1));
}
else {
print S "$cmd $args\n";
}
}
}
print "CreRemote> " unless $MUD;
}
sub cmdConnect {
local($mud) = shift(@_);
local($rcfile) = $ENV{'HOME'} || './';
$rcfile = $rcfile."/.creremoterc";
local($found) = 0;
local($writerc) = 0;
if( -f $rcfile ) {
open(RCFILE, $rcfile);
while(<RCFILE>) {
chop;
local(@words) = split;
local($thismud) = shift(@words);
if( ! $charname && $thismud eq $mud ) {
$Character = shift(@words);
$Password = shift(@words);
$Machine= shift(@words);
$Port = shift(@words);
$found = 1;
}
}
close(RCFILE);
}
if( ! $found ) {
print "Character name: ";
chop($Character = <>);
print "Password: ";
system 'stty', '-echo';
chop($Password = <>);
system 'stty', 'echo';
print "\n$mud ip: ";
chop($Machine = <>);
print "port: ";
chop($Port = <>);
$writerc = 1;
}
$MUD = $mud;
if( ! $Character || !$MUD || ! $Password || ! $Machine || ! $Port ) {
print "Vital information is missing\n";
return;
}
$AF_INET = 2;
$SOCK_STREAM = 1;
$SIG{'INT'} = 'killconnection';
$port = $Port;
$sockaddr = 'S n a4 x8';
chop($hostname = `hostname`);
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) =
gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($Machine);
$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);
if( !socket(S, $AF_INET, $SOCK_STREAM, $proto) ) {
print "Error creating socket for $MUD: $!\n";
$MUD = "";
$Character = "";
$Password = "";
$Machine = "";
$Port = "";
return;
}
if( !bind(S, $this) ) {
print "Error binding to $MUD: $!\n";
$MUD = "";
$Character = "";
$Password = "";
$Machine = "";
$Port = "";
return;
}
if( !connect(S, $that) ) {
print "Error connecting to $MUD: $!\n";
$MUD = "";
$Character = "";
$Password = "";
$Machine = "";
$Port = "";
return;
}
if( $writerc ) {
open(NRCFILE, ">> $rcfile");
print NRCFILE "$MUD $Character $Password $Machine $Port\n";
close(NRCFILE);
}
select(S); $| = 1; select(STDOUT);
if( $child = fork ) {
print S "login $Character $Password\n";
return;
}
else {
while(<S>) {
if( $InEdit > 0 ) {
$Buffer = "$Buffer$_";
if( length($Buffer) == $InEdit ) {
$InEdit = 0;
open(LEF, ">$LocalEditFile");
print LEF $Buffer;
close(LEF);
while( -f $LocalEditFile ) { }
$Buffer = "";
$InEdit = 0;
print "$MUD> ";
}
}
else {
chop;
local(@borg) = split;
$remcmd = shift(@borg);
if ( $remcmd == 100 ) {
$InEdit = shift(@borg);
if( ! $InEdit ) {
system("touch $LocalEditFile");
while( -f $LocalEditFile ) { }
$Buffer = "";
$InEdit = 0;
print "$MUD> ";
}
}
elsif( $remcmd == 500 ) {
$format = "Directory: %s\n";
$tmpx = @borg - 1;
if( $tmpx ) {
while($tmpx--) {
if( $tmpx % 3 == 0 ) { $format = "$format%20s\n"; }
else { $format = "$format%20s"; }
}
}
printf($format, @borg);
print "\n$MUD> ";
}
else {
local($out) = join(' ', @borg);
print "$out\n$MUD> ";
}
}
}
exit;
}
}
sub cmdHelp {
print "CreRemote is a way to work on a MUD without physically\n";
print "being on that MUD. When you first issue the CreRemote\n";
print "command, you are given the CreRemote prompt. At that time\n";
print "you are not connected to any MUD. You can issue the\n";
print "following commands from the CreRemote prompt:\n";
print "\tconnect <mud>\n";
print "\texit\n\n";
print "Once connect to a MUD, the commands available to you may\n";
print "vary from MUD to MUD, generally you will have commands like:\n";
print "cd, ls, update, mkdir, rmdir, rm, mv, cp, etc.\n";
print "No matter whcih MUD, you will have the command \"edit\"\n";
print "which allows you to edit your files with your favourite UNIX\n";
print "editor. The default is vi, however, it will use the value\n";
print "of your EDITOR environment variable.\n";
print "When connecting to a MUD, remember to specify its RCP port,\n";
print "NOT its MUD port. This is generally MUD port - 10.\n";
}

101
extra/creremote/remote.c Normal file
View File

@ -0,0 +1,101 @@
/* /lib/remote.c
* from the Foundation II LPC Library
* handles security for cre access via the remote creator protocol
* created by Descartes of Borg 950505
*/
#include <lib.h>
inherit LIB_DAEMON;
private static string Directory, Home;
static void create() {
daemon::create();
SetNoClean(1);
Directory = Home = "/" +
implode(explode(file_name(this_object()), "/")[0..<3], "/");
if( strsrch(Directory, REALMS_DIRS) ) call_out( (: Destruct :), 0 );
}
string eventWriteFile(string file, string str) {
file = absolute_path(Directory, file);
if( base_name(this_object()) == LIB_REMOTE )
return "50 Failed to write file: " + file;
if( file_size(file) > -1 && !rm(file) )
return "50 Failed to write file: " + file;
if( !write_file(file, str) ) return "50 Failed to write file: " + file;
else return "110 File " + file + " written.";
}
string eventReadFile(string file) {
string tmp;
if( base_name(this_object()) == LIB_REMOTE ) return "";
file = absolute_path(Directory, file);
if( !(tmp = read_file(file)) ) return "";
else return tmp;
}
string eventCommand(string cmd, string arg) {
string *files;
object ob;
string tmp;
if( base_name(this_object()) == LIB_REMOTE ) return 0;
switch(cmd) {
case "ls":
if( !arg || arg == "" ) arg = Directory;
switch(file_size(arg)) {
case -2:
if( arg[<1] != '/' ) arg += "/";
files = ({ arg });
files += map(get_dir(arg),
(: (file_size($(arg) + $1) == -2) ? $1 + "/" : $1 :));
return implode(files, "\t");
case -1:
return 0;
default:
return arg;
}
case "mkdir":
arg = absolute_path(Directory, arg);
if( file_size(arg) != -1 ) return 0;
if( !mkdir(arg) ) return 0;
else return "Directory created.";
case "cd":
arg = absolute_path(Directory, arg);
if( !arg || arg == "" ) Directory = Home;
else if( !((int)master()->valid_read(arg, this_object(), "cd")) )
return 0;
else Directory = arg;
return Directory;
case "rm":
arg = absolute_path(Directory, arg);
if( !rm(arg) ) return 0;
else return arg + " deleted.";
case "rmdir":
arg = absolute_path(Directory, arg);
if( !rmdir(arg) ) return 0;
else return arg + " deleted.";
case "mv":
files = explode(arg, " ");
if( sizeof(files) != 2 ) return 0;
files[0] = absolute_path(Directory, files[0]);
files[1] = absolute_path(Directory, files[1]);
if( !rename(files[0], files[1]) ) return 0;
else return files[0] + " renamed to " + files[1] + ".";
case "update":
arg = absolute_path(Directory, arg);
if( arg[<2..] == ".c" ) arg = arg[0..<3];
if( ob = find_object(arg) ) {
if( !((int)ob->eventDestruct()) )
return "Failed to destruct original object.";
}
tmp = catch(call_other(arg, "???"));
if( tmp )
return "Error in loading object: " + replace_string(tmp, "\n", "\t");
else return arg + ": successfully loaded.";
}
return 0;
}

View File

@ -0,0 +1 @@
Machine MINGW32_NT-5.1 REMORA 1.0.10(0.46/3/2) 2004-03-15 07:17 i686 unknown Configure version 5

24
extra/mingw/configure.h Normal file
View File

@ -0,0 +1,24 @@
#define INCL_STDLIB_H
#define INCL_TIME_H
#define INCL_FCNTL_H
#define INCL_DOS_H
#define INCL_SYS_STAT_H
#define INCL_LIMITS_H
#define USE_STRUCT_DIRENT
#define INCL_STDARG_H
#define HAS_MEMMOVE
#define RAND
#define HAS_STRERROR
#define HAS_GETCWD
#define SIZEOF_INT 4
#define SIZEOF_PTR 4
#define SIZEOF_SHORT 2
#define SIZEOF_FLOAT 4
#define SIZEOF_INT 4
#define SIZEOF_PTR 4
#define SIZEOF_SHORT 2
#define SIZEOF_FLOAT 4
#define UINT32 unsigned long
#define CONFIGURE_VERSION 5

150
extra/restore_cfg Normal file
View File

@ -0,0 +1,150 @@
###############################################################################
# Customizable runtime config file for MudOS #
# NOTE: All paths specified here are relative to the mudlib directory except #
# for mudlib directory, and binary directory. #
# Lines beginning with a # or a newline are ignored. #
###############################################################################
# name of this mud
name : DeadSoulsNew
# port number to accept users on
external_port_1 : telnet 6666
# absolute pathname of mudlib
mudlib directory : /CHANGE/THIS/PATH/lib
# absolute pathname of driver/config dir
binary directory : /CHANGE/THIS/PATH/bin
# the address server is an external program that lets the mud translate
# internet names to numbers (and vice versa). select an unused port.
address server ip : localhost
address server port : 8099
# fd6 stuff is what allows portbind to work properly. If
# you want to have the mud accept connections on port 23 but run
# as non-root, you uncomment the two fd6 lines below and issue the
# appropriate portbind command to start the mud.
#fd6 port : 23
#fd6 kind : telnet
# debug.log and author/domain stats are stored here
log directory : /log
# the directories which are searched by #include <...>
# for multiple dirs, separate each path with a ':'
include directories : /secure/include:/include
# Directory to save binaries in. (if BINARIES is defined)
save binaries directory : /secure/save/binaries
# the file which defines the master object
master file : /secure/daemon/master
# the file where all global simulated efuns are defined.
simulated efun file : /secure/sefun/sefun
# file to swap out objects; not used if time to swap is 0
swap file : /secure/tmp/swap
# alternate debug.log file name (assumed to be in specified 'log directory')
debug log file : runtime
# This is an include file which is automatically #include'd in all objects
global include file : <global.h>
# if an object is left alone for a certain time, then the
# function clean_up will be called. This function can do anything,
# like destructing the object. If the function isn't defined by the
# object, then nothing will happen.
# This time should be substantially longer than the swapping time.
time to clean up : 2100000000
# How long time until an unused object is swapped out.
# Machine with too many players and too little memory: 900 (15 minutes)
# Machine with few players and lot of memory: 10000
# Machine with infinite memory: 0 (never swap).
time to swap : 0
# How many seconds until an object is reset again.
time to reset : 2100000000
# Maximum number of bits in a bit field. They are stored in printable
# strings, 6 bits per byte.
maximum bits in a bitfield : 1200
# Max number of local variables in a function.
maximum local variables : 35
# Maximum amount of "eval cost" per thread - execution is halted when
# it is exceeded.
maximum evaluation cost : 5000000
# This is the maximum array size allowed for one single array.
maximum array size : 64000
# This is the maximum allowed size of a variable of type 'buffer'.
maximum buffer size : 400000
# Max size for a mapping
maximum mapping size : 64000
# Max inherit chain size
inherit chain size : 30
# maximum length of a string variable
maximum string length : 200000
# Max size of a file allowed to be read by 'read_file()'.
maximum read file size : 200000
# max number of bytes you allow to be read and written with read_bytes
# and write_bytes
maximum byte transfer : 10000
# Reserve an extra memory area from malloc(), to free when we run out
# of memory and allow the mudlib to shutdown.
# If this value is 0, no area will be reserved.
reserved size : 0
# Define the size of the shared string hash table. This number should
# a prime, probably between 1000 and 30000; if you set it to about 1/5
# of the number of distinct strings you have, you will get a hit ratio
# (number of comparisons to find a string) very close to 1, as found strings
# are automatically moved to the head of a hash chain. You will never
# need more, and you will still get good results with a smaller table.
hash table size : 7001
# Object hash table size.
# Define this like you did with the strings; probably set to about 1/4 of
# the number of objects in a game, as the distribution of accesses to
# objects is somewhat more uniform than that of strings.
object table size : 1501
# default no-matching-action message
default fail message : What?
# default message when error() occurs (optional)
default error message : Something *REALLY* bad just happened.
###############################################################################
# The following aren't currently used or implemented (yet) #
###############################################################################
# maximum number of users in the game (unused currently)
maximum users : 40
# Define the maximum stack size of the stack machine. This stack will also
# contain all local variables and arguments. (unused currently)
evaluator stack size : 1000
# Define the size of the compiler stack. This defines how complex
# expressions the compiler can parse. (unused currently)
compiler stack size : 200
# Define the maximum call depth for functions. (unused currently)
maximum call depth : 30
# There is a hash table for living objects, used by find_living().
# (unused currently)
living hash table size : 100

51
extra/wolfpaw/configure.h Normal file
View File

@ -0,0 +1,51 @@
#define INCL_STDLIB_H
#define INCL_UNISTD_H
#define INCL_TIME_H
#define USE_TZSET
#define INCL_SYS_TIMES_H
#define INCL_FCNTL_H
#define INCL_SYS_TIME_H
#define INCL_LIMITS_H
#define INCL_LOCALE_H
#define INCL_NETINET_IN_H
#define INCL_ARPA_INET_H
#define INCL_SYS_TYPES_H
#define INCL_SYS_IOCTL_H
#define INCL_SYS_SOCKET_H
#define INCL_NETDB_H
#define INCL_ARPA_TELNET_H
#define INCL_SYS_SOCKETVAR_H
#define INCL_SYS_STAT_H
#define INCL_DIRENT_H
#define USE_STRUCT_DIRENT
#define INCL_SYS_RESOURCE_H
#define INCL_SYS_WAIT_H
#define INCL_CRYPT_H
#define INCL_SYS_SYSMACROS_H
#define INCL_STDARG_H
#define INCL_DLFCN_H
#define DRAND48
#define USE_BSD_SIGNALS
#define SIGNAL_ERROR SIG_ERR
#define INLINE inline
#define CONST const
#define HAS_UALARM
#define HAS_STRERROR
#define HAS_GETCWD
#define RUSAGE
#define TIMES
#define HAS_GETTIMEOFDAY
#define HAS_FCHMOD
#define SIZEOF_INT 4
#define SIZEOF_PTR 4
#define SIZEOF_SHORT 2
#define SIZEOF_LONG 4
#define SIZEOF_FLOAT 4
#define UINT32 unsigned long
#define CONFIGURE_VERSION 5
#define MAXSHORT ((1 << (sizeof(short)*8)) - 1)
#define USHRT_MAX (MAXSHORT)
#define USE_STRUCT_DIRENT
#define RTLD_LAZY 1
#define INADDR_NONE (unsigned int)0xffffffff

270
extra/wolfpaw/macros.h Normal file
View File

@ -0,0 +1,270 @@
#ifndef MACROS_H
#define MACROS_H
#ifdef __STDC__
#define ANSI_STRING_HACK(x) #x
#define DONT_ASK_WHY(x) (x)
#define WHERE (__FILE__ ":" DONT_ASK_WHY(x))
#else
#define WHERE "non-ansi compilers are a pain"
#endif
/*
* Some useful macros...
*/
#ifdef BUFSIZ
# define PROT_STDIO(x) (x ()
#endif /* BUFSIZ */
/* ANSI/K&R compatibility stuff;
*
* The correct way to prototype a function now is:
*
* foobar (int, char *);
*
* foobar (int x, char * y) { ... }
*/
/* xlc can't handle an ANSI protoype followed by a K&R def, and varargs
* functions must be done K&R (b/c va_dcl is K&R style) so don't prototype
* vararg function arguments under AIX
*/
#if defined(__STDC__) || defined(WIN32)
# define VOLATILE volatile
# define SIGNED signed
#else /* __STDC__ */
# define VOLATILE
# define SIGNED
#endif /* __STDC__ */
/* do things both ways ... */
#define V_START(vlist, last_arg) va_start(vlist, last_arg)
#define V_VAR(type, var, vlist)
#define SAFE(x) do { x } while (0)
/*
Define for MALLOC, FREE, REALLOC, and CALLOC depend upon what malloc
package and optional wrapper is used. This technique is used because
overlaying system malloc with another function also named malloc doesn't
work on most mahines that have shared libraries. It will also let
us keep malloc stats even when system malloc is used.
Please refer to options.h for selecting malloc package and wrapper.
*/
#if (defined(SYSMALLOC) + defined(SMALLOC) + defined(BSDMALLOC) + defined(MMALLOC)) > 1
!Only one malloc package should be defined
#endif
#if (defined(WRAPPEDMALLOC) + defined(DEBUGMALLOC)) > 1
!Only one wrapper (at most) should be defined
#endif
#if defined(DO_MSTATS) && defined(SYSMALLOC)
!'DO_MSTATS' not available with 'SYSMALLOC'
#endif
#if defined (WRAPPEDMALLOC) && !defined(IN_MALLOC_WRAPPER)
# define MALLOC(x) wrappedmalloc(x)
# define FREE(x) wrappedfree(x)
# define REALLOC(x, y) wrappedrealloc(x, y)
# define CALLOC(x, y) wrappedcalloc(x, y)
# define DXALLOC(x, t, d) xalloc(x)
# define DMALLOC(x, t, d) MALLOC(x)
# define DREALLOC(x, y, t, d) REALLOC(x,y)
# define DCALLOC(x, y, t, d) CALLOC(x,y)
#else
# if defined(DEBUGMALLOC) && !defined(IN_MALLOC_WRAPPER)
# define MALLOC(x) debugmalloc(x, 0, (char *)0)
# define DMALLOC(x, t, d) debugmalloc(x, t, d)
# define DXALLOC(x, t, d) debugmalloc(x, t, d)
# define FREE(x) debugfree(x)
# define REALLOC(x,y) debugrealloc(x,y,0,(char *)0)
# define DREALLOC(x,y,tag,desc) debugrealloc(x,y,tag,desc)
# define CALLOC(x,y) debugcalloc(x,y,0,(char *)0)
# define DCALLOC(x,y,tag,desc) debugcalloc(x,y,tag,desc)
# else
# include "my_malloc.h"
# endif
#endif
#if !defined(MALLOC) && !defined(EDIT_SOURCE)
!You need to specify a malloc package in local_options/options.h
#endif
#define ALLOCATE(type, tag, desc) ((type *)DXALLOC(sizeof(type), tag, desc))
#define CALLOCATE(num, type, tag, desc) ((type *)DXALLOC(sizeof(type[1]) * (num), tag, desc))
#define RESIZE(ptr, num, type, tag, desc) ((type *)DREALLOC((void *)ptr, sizeof(type) * (num), tag, desc))
#ifdef DEBUG
# define IF_DEBUG(x) x
# define DEBUG_CHECK(x, y) if (x) fatal(y)
# define DEBUG_CHECK1(x, y, a) if (x) fatal(y, a)
# define DEBUG_CHECK2(x, y, a, b) if (x) fatal(y, a, b)
#else
# define IF_DEBUG(x)
# define DEBUG_CHECK(x, y)
# define DEBUG_CHECK1(x, y, a)
# define DEBUG_CHECK2(x, y, a, b)
#endif
#if !defined(EDIT_SOURCE) && !defined(_FUNC_SPEC_)
#define COPY2(x, y) ((char *)(x))[0] = ((char *)(y))[0]; \
((char *)(x))[1] = ((char *)(y))[1]
#define LOAD2(x, y) ((char *)&(x))[0] = *y++; \
((char *)&(x))[1] = *y++
#define STORE2(x, y) *x++ = ((char *)(&(y)))[0]; \
*x++ = ((char *)(&(y)))[1]
#define COPY4(x, y) ((char *)(x))[0] = ((char *)(y))[0]; \
((char *)(x))[1] = ((char *)(y))[1]; \
((char *)(x))[2] = ((char *)(y))[2]; \
((char *)(x))[3] = ((char *)(y))[3]
#define LOAD4(x, y) ((char *)&(x))[0] = *y++; \
((char *)&(x))[1] = *y++; \
((char *)&(x))[2] = *y++; \
((char *)&(x))[3] = *y++
#define STORE4(x, y) *x++ = ((char *)(&(y)))[0]; \
*x++ = ((char *)(&(y)))[1]; \
*x++ = ((char *)(&(y)))[2]; \
*x++ = ((char *)(&(y)))[3]
#define COPY8(x, y) ((char *)(x))[0] = ((char *)(y))[0]; \
((char *)(x))[1] = ((char *)(y))[1]; \
((char *)(x))[2] = ((char *)(y))[2]; \
((char *)(x))[3] = ((char *)(y))[3]; \
((char *)(x))[4] = ((char *)(y))[4]; \
((char *)(x))[5] = ((char *)(y))[5]; \
((char *)(x))[6] = ((char *)(y))[6]; \
((char *)(x))[7] = ((char *)(y))[7]
#define LOAD8(x, y) ((char *)&(x))[0] = *y++; \
((char *)&(x))[1] = *y++; \
((char *)&(x))[2] = *y++; \
((char *)&(x))[3] = *y++; \
((char *)&(x))[4] = *y++; \
((char *)&(x))[5] = *y++; \
((char *)&(x))[6] = *y++; \
((char *)&(x))[7] = *y++;
#define STORE8(x, y) *x++ = ((char *)(&(y)))[0]; \
*x++ = ((char *)(&(y)))[1]; \
*x++ = ((char *)(&(y)))[2]; \
*x++ = ((char *)(&(y)))[3]; \
*x++ = ((char *)(&(y)))[4]; \
*x++ = ((char *)(&(y)))[5]; \
*x++ = ((char *)(&(y)))[6]; \
*x++ = ((char *)(&(y)))[7]
#if SIZEOF_SHORT == 2
#define COPY_SHORT(x, y) COPY2(x,y)
#define LOAD_SHORT(x, y) LOAD2(x,y)
#define STORE_SHORT(x, y) STORE2(x,y)
#else
#endif
#if SIZEOF_INT == 4
#define INT_32 int
#endif
#if SIZEOF_LONG == 4
#define COPY_INT(x, y) COPY4(x,y)
#define LOAD_INT(x, y) LOAD4(x,y)
#define STORE_INT(x, y) STORE4(x,y)
#else
#if SIZEOF_LONG == 8
#define COPY_INT(x, y) COPY8(x,y)
#define LOAD_INT(x, y) LOAD8(x,y)
#define STORE_INT(x, y) STORE8(x,y)
#else
#endif
#endif
#if SIZEOF_FLOAT == 4
#define COPY_FLOAT(x, y) COPY4(x,y)
#define LOAD_FLOAT(x, y) LOAD4(x,y)
#define STORE_FLOAT(x, y) STORE4(x,y)
#else
#endif
#if SIZEOF_PTR == 4
# define COPY_PTR(x, y) COPY4(x,y)
# define LOAD_PTR(x, y) LOAD4(x,y)
# define STORE_PTR(x, y) STORE4(x,y)
# define POINTER_INT int
# define INS_POINTER ins_int
#else
# if SIZEOF_PTR == 8
# define COPY_PTR(x, y) COPY8(x,y)
# define LOAD_PTR(x, y) LOAD8(x,y)
# define STORE_PTR(x, y) STORE8(x,y)
# define POINTER_INT long
# define INS_POINTER ins_long
# else
# endif
#endif
#endif
#ifndef _FUNC_SPEC_
char *xalloc (int);
# ifdef DEBUGMALLOC
char *int_string_copy (const char * const, char *);
char *int_string_unlink (const char *, char *);
char *int_new_string (int, char *);
char *int_alloc_cstring (const char *, char *);
# else
char *int_string_copy (const char * const);
char *int_string_unlink (const char *);
char *int_new_string (int);
char *int_alloc_cstring (const char *);
# endif
#endif
#ifdef DEBUGMALLOC
# define string_copy(x,y) int_string_copy(x, y)
# define string_unlink(x,y) int_string_unlink(x, y)
# define new_string(x,y) int_new_string(x, y)
# define alloc_cstring(x,y) int_alloc_cstring(x, y)
#else
# define string_copy(x,y) int_string_copy(x)
# define string_unlink(x,y) int_string_unlink(x)
# define new_string(x,y) int_new_string(x)
# define alloc_cstring(x,y) int_alloc_cstring(x)
#endif
#ifndef INLINE
# ifdef WIN32
# define INLINE extern __inline
# define INLINE_STATIC __inline
# else
# define INLINE
# endif
#endif
#ifndef INLINE_STATIC
# define INLINE_STATIC static INLINE
#endif
/* The ANSI versions must take an unsigned char, and must work on EOF. These
* versions take a (possibly signed) char, and do not work correctly on EOF.
*
* Note that calling isdigit(x) where x is a signed char with x < 0 (i.e.
* high bit set) invokes undefined behavior.
*/
#define uisdigit(x) isdigit((unsigned char)x)
#define uislower(x) islower((unsigned char)x)
#define uisspace(x) isspace((unsigned char)x)
#define uisalnum(x) isalnum((unsigned char)x)
#define uisupper(x) isupper((unsigned char)x)
#define uisalpha(x) isalpha((unsigned char)x)
#define uisxdigit(x) isxdigit((unsigned char)x)
#define uisascii(x) isascii((unsigned char)x)
#define uisprint(x) isprint((unsigned char)x)
#endif

View File

@ -0,0 +1 @@
-lresolv -lcrypt -lnsl -lm -lz

View File

@ -0,0 +1,40 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
void *malloc32(int size){
register unsigned long *res = (unsigned long *)malloc(size+sizeof(long));
if(!res){
perror("malloc: ");
exit(-1);
}
*res=size;
return &res[1];
}
void free32(void *p){
register unsigned long *mem = (unsigned long *)p;
mem--;
free(mem);
}
void *realloc32(void *p, int size){
register unsigned long *mem = (unsigned long *)p;
unsigned int oldsize;
oldsize = mem[-1];
void *newmem = malloc32(size);
oldsize = oldsize<size?oldsize:size;
memcpy(newmem, mem, oldsize);
free(--mem);
return (void *)newmem;
}
void *calloc32(int num, int size){
register void *p;
size *= num;
if ((p = malloc32(size)))
memset(p, 0, size);
return (p);
}

View File

@ -0,0 +1,145 @@
#define _GNU_SOURCE
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct freeblocks{
unsigned long *block;
struct freeblocks *next;
} *freelist = NULL;
static char *where = NULL;
static long blocksize = 0;
void *malloc64(int size){
if(!blocksize){
char *tmp = (char *)sbrk(0); //end of heap
char *tmp2 = (char *)&size; //end of stack
char *tmp3 = (char *)0x4000000000; //libs, how do we get the actual address??
//printf("%ul %ul %ul", tmp, tmp2, tmp3);
if(tmp3 < tmp2 && tmp < tmp3){ //oops libraries in the middle, find the biggest gap we're assuming libs are smaller than 4GB total
if((tmp3 - tmp) > (tmp2 - tmp3)){
tmp2 = tmp3 - (long)4 * 1024 * 1024 * 1024;
} else {
tmp = tmp3 + (long)4 * 1024 * 1024 * 1024;
}
}
long total = tmp2 - tmp; //memory available
total -= (long)4 * 1024 * 1024 * 1024; //leave some for the libc malloc (4GB)
blocksize = total/10000000; //10 million allocations of over 4k should be enough for anyone (at least 40 Gb requested at that point, in reality probably at least 10 times more!)
blocksize -= blocksize % 4096;
where = tmp + (long)4 * 1024 * 1024 * 1024;
where -= (long)where % 4096;
//printf("start %xl: blocksize: %xl\n", (long)where, blocksize);
}
if(size < 4088){
register unsigned long *res = (unsigned long *)malloc(size+sizeof(long));
if(!res){
perror("malloc: ");
exit(-1);
}
*res=size;
return &res[1];
}
register unsigned long *res;
if(size < blocksize){
if(!freelist){
res = (unsigned long *)mmap(where, size+sizeof(long),MAP_FIXED|PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
if(res != where){
perror("mmap failed! (55)");
printf("where = %lx\n", where);
res = (unsigned long *)malloc(size+sizeof(long));
if(!res){
perror("malloc: ");
exit(-1);
}
*res=size;
return &res[1];
}
where += blocksize;
}else{
res = (unsigned long *)mmap(freelist->block, size+sizeof(long),MAP_FIXED|PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
if(res != freelist->block)
perror("mmap failed! (60)");
struct freeblocks *tmp = freelist;
freelist = freelist->next;
free(tmp);
}
} else {
//just in case something big comes along
int thissize = size / 4096;
thissize++;
res = (unsigned long *)mmap(where, size+sizeof(long),MAP_FIXED|PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
if(res != where)
perror("mmap failed! (72)");
where += (thissize*4096);
}
if((long)res == -1){
perror("malloc: ");
exit(-1);
}
*res=size;
return &res[1];
}
void free64(void *p){
register unsigned long *mem = (unsigned long *)p;
mem--;
if(mem < (unsigned long *)sbrk(0) || mem > (unsigned long *)where)
free(mem);
else{
munmap(mem, *mem+sizeof(long));
struct freeblocks *bl = (struct freeblocks *)malloc(sizeof(struct freeblocks));
bl->block = mem;
bl->next = freelist;
freelist = bl;
}
}
void *realloc64(void *p, int size){
register unsigned long *mem = (unsigned long *)p;
unsigned int oldsize;
mem--;
oldsize = *mem+sizeof(long);
if(mem < (unsigned long *)sbrk(0) || mem > (unsigned long *)where){
if(size < 4088){
mem = (unsigned long *)realloc(mem, size + sizeof(long));
*mem = size;
return (void *)&mem[1];
} else {
mem++;
unsigned long *newmem = (unsigned long *)malloc64(size);
memcpy(newmem, mem, oldsize-sizeof(long));
mem--;
free(mem);
return (void *)newmem;
}
}
if(size < 4088){
mem++;
unsigned long *newmem = (unsigned long *)malloc(size+sizeof(long));
*newmem = size;
newmem++;
memcpy(newmem, mem, size);
free64(mem);
return (void *)newmem;
}
mem = (unsigned long *)mremap(mem, oldsize, size+sizeof(long), 1);
*mem = size;
return (void *)&mem[1];
}
void *calloc64(int num, int size){
register void *p;
size *= num;
if ((p = malloc64(size)))
memset(p, 0, size);
return (p);
}

View File

@ -0,0 +1,9 @@
The file "Artistic" is included because a small part of the driver source
is derived from Larry Wall's Perl package (namely the hashing code
used in the mappings implementation). Previously, we used the GNU Copyleft
because the "Artistic" option wasn't then available. Since the "Artistic"
license is more similar to Lars Pensk|'s original Copyright than is the GNU
Copyleft, we have chosen to use Artistic instead of the Copyleft (as
is allowed by the terms Larry Wall sets forth in the Perl 4.036 README).
Where there is any conflict between Lars' copyright and the Artistic license,
Lars' copyright should take precedence.

318
fluffos-2.23-ds03/Bugs Normal file
View File

@ -0,0 +1,318 @@
The internal message passing functions should be cleaned up. Currently, a lot
of stuff calls add_message() directly, while other stuff uses tell_object()
and friends. One consequence of this is that even with INTERACTIVE_CATCH_TELL
defined, not all of the output flows through catch_tell() [ed, for example,
doesn't, as well as some other efuns].
-----
In the MudOS v22a36 the livings efun gives back HIDDEN things too.
I don't know why objects used that strange construction.
I think, it's new form would be more usable.
As i see this HIDDEN stuff has many leaks, like:
you can always create an object that you put into all rooms, and look
for this_player() in the init apply.
So even if you correct all efuns like livings, heartbeats, named_livings
and so on, it will never be perfect.
solve for livings and objects:
------------------------------- cut here ----------------------------------
1831c1831
< int nob, apply_valid_hide, hide_is_valid = 0;
---
> int nob, display_hidden=-1;
1836d1835
< apply_valid_hide = 1;
1844,1848c1843,1845
< if (apply_valid_hide) {
< apply_valid_hide = 0;
< hide_is_valid = valid_hide(current_object);
< }
< if (hide_is_valid)
---
> if (display_hidden==-1)
> display_hidden = valid_hide(current_object);
> if (!display_hidden)
1876c1873
< int display_hidden = 0, t_sz, i,j, num_arg = st_num_arg;
---
> int display_hidden = -1, t_sz, i,j, num_arg = st_num_arg;
1890a1888,1889
> if (display_hidden==-1)
> display_hidden = valid_hide(current_object);
1892,1893d1890
< display_hidden = 1 + !!valid_hide(current_object);
< if (!(display_hidden & 2))
---------------------------------- cut here --------------------------------
Comment: possibly a better solution is to check O_HIDDEN where O_DESTRUCTED
is checked. valid_hide() would be checked when objects load, and would
set a O_CAN_SEE_HIDDEN bit. Then every time we run across a
FRAME_OB_CHANGE, do:
if (current_object & O_CAN_SEE_HIDDEN)
object_mask = O_DESTRUCTED;
else
object_mask = O_DESTRUCTED | O_HIDDEN;
Code elsewhere would then look something like:
if (sv->type == T_OBJECT && (sv->u.ob->flags & object_mask)) {
free_object(sv->u.ob, "...");
*sv = const0;
}
This would be much more effective at preventing objects from detecting the
existence of hidden objects. It would also fix this one:
Various efuns which call valid_hide() don't realize it can error, causing
them to leak if master::valid_hide() throws an error.
-----
If an include file doesn't end in a newline, something screws up in the
linked buffer code, causing odd compile errors.
Line numbers get messed up when files don't end in a newline?
-----
RUNTIME_LOADING needs -rdynamic passed in the link on some OS's?
(reported for a gcc-linux system; possibly a mixed a.out/elf?)
-----
This gives the wrong error message:
unlock the door with the key
Trying interpretation: unlock:the:door:with:the:key:
Trying rule: OBJ with OBJ
parse_rule
parse_obj:
Found noun: door
parse_rule
Matched literal: with
parse_obj:
Found noun: key
parse_rule
we_are_finished
Trying can_unlock_obj_with_obj ...
Trying can_unlock_obj_word_obj ...
Trying can_verb_obj_word_obj ...
Trying can_verb_rule ...
Trying can_unlock_obj_with_obj ...
Return value was: 1
Trying direct_unlock_obj_with_obj ...
Return value was: 1
Trying indirect_unlock_obj_with_obj ...
Return value was: 0
You can't unlock the thing with that.
exiting parse_rule ...
parse_rule
exiting parse_rule ...
parse_rule
we_are_finished
Trying can_unlock_obj_with_obj ...
Trying can_unlock_obj_word_obj ...
Trying can_verb_obj_word_obj ...
Trying can_verb_rule ...
Trying can_unlock_obj_with_obj ...
Return value was: 1
exiting parse_rule ...
Done trying to match OBJ
parse_rule
last match to error ...
Changing last match.
parse_obj:
Found noun: key
parse_rule
we_are_finished
Trying can_unlock_obj_with_obj ...
Trying can_unlock_obj_word_obj ...
Trying can_verb_obj_word_obj ...
Trying can_verb_rule ...
Trying can_unlock_obj_with_obj ...
Return value was: 1
Trying indirect_unlock_obj_with_obj ...
Return value was: 0
You can't unlock the thing with that.
exiting parse_rule ...
parse_rule
exiting parse_rule ...
parse_rule
we_are_finished
Trying can_unlock_obj_with_obj ...
Trying can_unlock_obj_word_obj ...
Trying can_verb_obj_word_obj ...
Trying can_verb_rule ...
Trying can_unlock_obj_with_obj ...
Return value was: 1
Have better match; aborting ...
exiting parse_rule ...
Done trying to match OBJ
parse_rule
Matched literal: with
parse_obj:
Found noun: key
parse_rule
we_are_finished
Trying can_unlock_obj_with_obj ...
Trying can_unlock_obj_word_obj ...
Trying can_verb_obj_word_obj ...
Trying can_verb_rule ...
Trying can_unlock_obj_with_obj ...
Return value was: 1
Trying indirect_unlock_obj_with_obj ...
Return value was: 0
You can't unlock the thing with that.
exiting parse_rule ...
parse_rule
exiting parse_rule ...
parse_rule
we_are_finished
Trying can_unlock_obj_with_obj ...
Trying can_unlock_obj_word_obj ...
Trying can_verb_obj_word_obj ...
Trying can_verb_rule ...
Trying can_unlock_obj_with_obj ...
Return value was: 1
Have better match; aborting ...
exiting parse_rule ...
Done trying to match OBJ
parse_rule
last match to error ...
Literal not found in forward search
parse_rule
last match to error ...
Literal not found in forward search
parse_rule
Ran out of words to parse.
Done trying to match OBJ
There is no door here.
-----
It still seems possible for regexp(explode(read_file(...), "\n"), ...) to
crash, but I can't reproduce it.
-----
#pragma optimize bug:
;; Function room_of
049d: local LV0
049f: !
04a0: || 0006 (04a7)
04a3: transfer_local LV0
04a5: objectp
04a6: !
04a7: branch_when_zero 0003 (04ab)
04aa: return_zero
04ab: branch 0007 (04b3)
04ae: local LV1
04b0: (void)assign_local LV0
04b2: break_point
04b3: local LV0
04b5: environment
04b7: local_lvalue LV1
04b9: assign
04ba: bbranch_when_non_zero 000d (04ae)
04bd: transfer_local LV0
04bf: return
04c0: return_zero
object room_of(object obj) {
object ob;
if(!obj || !objectp(obj)) return 0;
while(ob=environment(obj)) obj=ob;
return obj;
}
-----
heart_beat() is not shadowable
-----
mixed a;
do {} while (a = ({ a, "" }));
Profezzorn@TMI-2
Comment:
It would be nice if things like this, where all the memory (VM too)
is sucked up by a runaway program, didn't cause the driver to
shutdown ("Out of memory").
### Nope, this evals out, need to do more work to make it run out of memory
-Sym (note: which is not the same as if the driver errors with "Out
of memory)
Yet another comment: Whether it evals out or runs out of mem obviously depends
on the ratio of MAX_EVAL_COST to available memory ...
-----
Range/switch search should be binary, not linear. (in LPC->C)
-----
Probably need a test to see if bison's output actually compiles in
./build.Mudos; on a lot of AIX systems bison's use of alloca() fails.
-Beek
-------
One can call private functions in inherited objects via call_out.
------
verbs that no longer have handlers should be deleted from the parser list
---
Line numbers can be screwed up by macro expansion. Consider the following:
#define IGNORE(x)
#define USE_ONCE(x) x
#define USE_TWICE(x) x
// The end of the next line never gets counted.
IGNORE("foo\
bar")
// The end of the next line is counted once.
USE_ONCE("foo\
bar")
// The end of the next line is counted twice.
USE_TWICE("foo\
bar")
So the IGNORE() and USE_TWICE() cases with screw up line numbering.
Fixing this is non-trivial, since macro expansions are reinserted into
the input stream. Outside of quotes, it was handled by replacing
'\n' with ' ' which is semantically equivalent. Inside quotes, one has
to do something like count the newlines as they are parsed, and then
have add_input() keep track of how many artificial newlines it has created,
so these can be ignored, which requires a check every time current_line++
is done ...
There must be a better fix :)
---
codefor int i,j; ({ i++, j})[1]; return i;
;; Function eval_function
0000: break_point
/* Missing:
* local_lvalue LV0
* inc(x)
*/
0001: local LV0
0003: return

2217
fluffos-2.23-ds03/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,220 @@
As MudOS is moving too slow to keep our driver hacks apart, we now call our own
FluffOS :)
new in FluffOS 1.36
Fixed crasher when doing restore_variable("(//)")
Fixed crasher when using 256 local variables in a function pointer
new in FluffOS 1.35
Fixed crasher when too many classes are used (parser using error result)
Fixed crasher with efun:: in function pointers when the efun override wasn't allowed
new in FluffOS 1.34
Fixed crashers in the reference keeping linked list
Fixed crasher when connections are not routed to any object
Changed compiling for -DDEBUG to work with modern glibc (turrican)
Fixed bug in regprop() (turrican)
Fixed crasher in max/min (woom)
new in FluffOS 1.33
Fixed typo in above line
Added vowel/add_a and num_classes efuns (Woom)
Added max/min/rell_MdN efuns (Woom)
Corrected functions/variables prototype (reported by Woom)
Changed makefile so make -j<number> works most of the time
Fixed ++ on LPC floats (reported by Woom)
Fixed error message + crasher in element_of()
new in FluffOS 1.32
Fix for nomask and shadows (simon@boo.org)
Make tab warnings optional (Skullslayer@Realms of the Dragon)
Compile fix in interpret.c (Skullslayer@Realms of the Dragon)
this_object() is now the default argument to base_name();
Fixed crasher in terminal_colour()
new in FluffOS 1.31
Fixed crasher in terminal_colour()
Changed heartbeats to run relative to mud time (time() in the mud) and never
never skip them anymore
Changed eval cost code to use signals, removed kernel module code and the
(VERY) slow fallback code there was before
new in FluffOS 1.30
added driver apply for mxp reply tags received from clients
fixed crasher in functions() (DEBUG mode, probably corrupted memory)
fixed optimizer bug (Pelle Johansson peljo105 at student.liu.se) (from the
mudos develop mailing list)
new in FluffOS 1.29
fixed bug in terminal_colour()
can now be compiled with tcc (you need to add a -DTCC flag)
no longer use alloca in bison
new in FluffOS 1.28
fixes to compile with other settings than the DW ones (Skullslayer@Realms of the Dragon)
fix in reverse DNS lookup (Skullslayer@Realms of the Dragon)
properly do the zlib stuff (Skullslayer@Realms of the Dragon)
terminal_colour fix (pinkfish)
new element_of efun which takes a random element from an array
readded pluralize cases that were accidently lost in the last version
new in FluffOS 1.27
update to terminal_colour() (Pinkfish)
added option to use mmap instead of sbrk for included malloc packages
new in FluffOS 1.26
check resets every 5 minutes
new malloc package (GNU)
new in FluffOS 1.25
fixed crasher in icode.c (Pinkfish)
close external ports for external commands(they don't need the telnet port etc)
new in FluffOS 1.24
added mxp support (Pinkfish)
updated with respect to MudOS v22.2b14
new in FluffOS 1.23
fixed crasher in sprintf
fixed crasher in compressed files (by pinkfish)
new in FluffOS 1.22
fixed compiling a development version
eval_cost reset for each call_out()ed function
some fixes to pluralize()
new in FluffOS 1.21
changed allocating structure for efun function pointers to allocate space for
a full function pointer struct
fixed the bug in mapping *map=({([])}); map[0]["bing"] = 1;
no longer convert floats to doubles and back when they go on the LPC stack
warn for tabs and MSDOS ^M chars in source code
removed some debugging printfs
new in FluffOS 1.20
fixed some array size issues
cleaned up some source (used pointer + x to index instead of pointer[x])
fixed some lint warnings
fixed compiling a DEBUG driver
fixed compiling with TRACE defined
added check for corrupted objects in debug mode
fixed buffer overruns and underruns in pluralize
new get_garbage() efun, return objects with no external references that are
not in other objects and not shadowing anything
new in FluffOS 1.19
unlink the shared function name string in functions() before returning it.
fixed compile errors with the intel(R) C++ compiler(7.0)
new in FluffOS 1.18
call the mudlib crash function even when printing the error trace gave a
fatal error as well.
added check for destructed objects in apply_low()
new in FluffOS 1.17
fixed writing over shared strings (yay const!)
fixed some buffer overflows
new in FluffOS 1.16
stop parsing after illegal to inherit error (crasher)
fixed some uninitialised variables
started using 'const'
new in FluffOS 1.15
many local buffers (on the stack) are now bigger to avoid overflow
class names, class member names and function names are no longer stored as
name, but as classname, membername and funcname instead (for easier
debugging)
now uses the v22.2 database code instead of forward ported v22.1
fixed bug in call_other type warnings
new in FluffOS 1.14
changed size of a local sprintf buffer from 100 to 1024 (100 must be really
easy to reach)
changed object struct name field to obname, there are too many struct fields
called name.
fixed malloc selecting code
removed part of the crasher fix of 1.13
new in FluffOS 1.13
fixed crasher in global_ref_list cleanup (just the crasher, i suspect the
list is borken as well
added base_name() efun
new in FluffOS 1.12
updated with respect to MudOS v22.2b13
removed some mixing of signed and unsigned chars
added mmap based malloc option (MMALLOC)
added option to make call_other type errors warnings
new in FluffOS 1.11
shuffle() efun by Taffyd
crasher fixes (copied from divided skys)
memory leak fix (also from DS)
new in FluffOS 1.10:
fixed bug in reference_allowed where invis would stop working
changed the return value of save_object to the amount of bytes (uncompressed)
after the line with the object name (#/global/player)
exit forked driver if exec fails in external commands, rather than having
multiple drivers going.
new in FluffOS 1.9:
some small fixes to reference_allowed
fixed (i hope) endless loop in compressed output
new in FluffOS 1.8:
reference_allowed efun (by Taffyd)
fixed crasher in ... when used in building arrays (reported by Presto).
avoid using it for that though, it's _very_ inefficient.
new in FluffOS 1.7:
return of the event() efun
member_array extended for partial searches and searching from the end of the
array
query_num(): returns the int argument as a string in the (1 -> one), optional
second argument specifies where it starts returning "many"
query_multiple_short(): see discworld lib docs, done by Taffyd.
new in FluffOS 1.6:
this changelog is now in the FluffOS archive!
fixed crasher in dumpstat (used by mem_info)
added (optional) type checking for call_other calls
changed variable assignment type checking from warnings to errors, using the
parser's warning system changed the current file/line variables, and
this could happen during compilation...
updated options.h
new in FluffOS 1.5:
fixed crasher after errors in save_object. (reported by pinkfish)
fixed crasher in interpret caused by find_line return a pointer to a local var
fixed crasher with switch statements that only contain a default case, they
are no longer allowed (reported by Vashti)
new in FluffOS 1.4:
added compressedp efun, it shows if an interactive uses MCCP (pinkfish)
fixed crasher in type checking code during compilation error (reported by
sightblinder)
fixed crasher in compressedp
new in FluffOS 1.3:
fixed crasher with buffer overflow in output
fixed loading compressed save files
new in FluffOS 1.2:
updated with respect to MudOS v22.2b12
fixed eval cost bug for first object loaded after the preload
increased line buffer size for loading compressed save files
new in FluffOS 1.1:
Uses a kernal module to get cpu times.
FluffOS 1.0:
changes since MudOS v22.2b11 (as far as i can remember)
Type warnings added
compressed save files
eval limit is now based on time taken, rather than substracting random numbers
to account for actions.
Many bug fixes :)
Wodan.

View File

@ -0,0 +1,460 @@
As MudOS is moving too slow to keep our driver hacks apart, we now call our own
FluffOS :), note: where it says Cratylus, I got it from his version, usually
someone else did the work, but I don't know how to find who did what there.
FluffOS 2.23
added a terminal_colour_replace apply, this will be called with every string between two %^ delimiters, and will be replaced with whatever is returned.
fixed protocol number for GMCP
fixed sprintf code for MSSP uptime
added defer efun, it takes a function pointer that will be called when the current function ends (even if that was caused by a runtime)
the old range behaviour warning for negative array indexes is now optional
the driver can now be compiled to use either struct or class for structs, or even allow both
fixed crasher in uniq_array
fixed crasher in socket_status
added missing ',' in non iconv driver pcre support
FluffOS 2.22
fixed potential crasher in pcre_extract
removed limit for number of matches in pcre efuns
added classes() efun (woom)
classes(ob) returns a list of class names available in ob
classes(ob, 1) returns the same list, with all the fields in the class (type and name)
you can now have more than 256 Globals (qwer@lpmuds.net)
added postgres support (unagi@lpmuds.net)
fixed zmp crash
removed some obsolete malloc options
FluffOS 2.21
small cleanup in malloc32
added gmcp support
gmcp_enable() gets called when a user has gmcp
gmcp() will get called with any received message
send_gmcp(string) will send the string as a gmcp message
has_gmcp(object) returns if the object supports gmcp
fixed sorting when the compare function returns values that don't fit in a 32 bit int.
fixed memory leak in sorting
new deep_inventory functionality (tiz)
it can now take an array of objects, and a function pointer that can return
0 don't include this object or it's contents
1 do include
2 include this object but not it's contents
3 don't include this object but do add the contents
the function will be called with one object from the inventory (for each object looked at)
fixed memory leak in new deep_inventory
added pcre support (Volothamp@Final Realms)
string pcre_version(void);
version of the pcre lib
mixed pcre_match(string | string *, string, void | int);
like the regexp efun
mixed *pcre_assoc(string, string *, mixed *, mixed | void);
like reg_assoc
string *pcre_extract(string, string);
extract matching parts
string pcre_replace(string, string, string *);
string replace, one entry in the array for each match
string pcre_replace_callback(string, string, string | function, ...);
string replace uses a callback to get the replace string (called with the matched string and match number, starting with 0)
mapping pcre_cache(void);
returns content of the pcre cache (not all that useful)
fixed memory leaks in pcre efuns
fixed crashers in pcre efuns
small optimisation in reg_assoc and pcre_assoc
fixed memory leak in compiling files
restore_object will no longer randomly set 0 values as undefined
fixed crasher in asking for an unused config setting
sprintf buffer is now big enough for max string size
fixed crasher in async_db_exec (never seen for real, but it was possible!)
db_fetch will no longer randomly return some 0s as undefined
dwlib package now has a replace_dollars function which searches for patterns starting with a $ only, otherwise the same as replace() (but faster as it only scans once)
FluffOS 2.20
more error checks in malloc64
bigger arrays (up to 2^31 elements)
bigger mappings (see arrays)
more efficient clean_up()
setting sockets to close on exec done in a more compatible way (only worked on rather new linux kernels)
no longer sends mccp messages when already compressed (fixes older cmud versions)
some cleanups for compiler warnings
new roulette_wheel() efun in the dwlib package (Woom)
new replace_objects() efun int the dwlib package (replaces all object references in the argument with filenames recursively)
check_valid_path apply now also used for compile paths (source files)
32BIT fix (Kalinash)
use less chars for string hashes (faster)
correctly do tables in (s)printf with utf-8 strings
use the already existing precalculated string hashes more often
save string length for bigger strings as well instead of using strlen on strings > 64k all the time
NetBSD IPV6 fix (Tiz)
fixed crasher in reference_allowed() (in dwlib.c)
FluffOS 2.19
attempt to fix string block alignments. hopefuly helps sparc64
open sockets as close on exec if available (so they don't end up in external programs started from the driver)
fix conflict between ed and solaris (both used the same define!)
fix bug with freeing an object table in backend.c
some fixes for sparc64 (Kalinash)
added missing Mysql data types so they don't always get returned as 0 anymore
changed some optional efun args to default to 0 instead for slightly cleaner code (Woom)
new addition to pluralize() (diff from Cratylus)
FluffOS 2.18
compiles for netbsd (tiz)
make more empty arrays point to the_null_array, saves memory and allows
comparing with ({}) to see if arrays are empty (reported by Woom)
clear this_user etc when runtimes get us all the way back to backend()
fix the inherits() return value if the inherit was indirectly inherited
(reported by Woom)
member_array now return -1 for failure if you search beyond the end of the array
(reported by Woom)
no longer loops forever when adding a reference whole destructing things with
too many references
fixed crasher in async db_exec
fixed crasher in filedescriptor leak fix
parser changed to be less strict (Cratylus)
stop wasting memory if repeat_string would exceed max string size (reported by woom)
fixed crasher in pragma optimize
FluffOS 2.17
math package updates: Added vector norm, dotprod, distance, angle.
Also added log2() and round() which works on floats (surprisingly useful).
Added int args to the efuns as apppropriate (Hamlet)
fixed above so the int args actually work without needing casts for the result
fixed 64bit malloc for large allocations (never happened on dw, so I doubt it was a problem!)
added 32bit malloc (malloc32) which is sysmalloc with realloc replaced by
malloc->memcpy->free, saves lots of memory
telnet environment support (Cratylus)
windows compile fix for add_action (Cratylus)
added dtrace support! just define DTRACE in local_options if you have it
zmp support
zmp calls from the client result in an apply on the player object
zmp_command(string command, string *args);
sending zmp is done with
send_zmp(string command, string *args);
check if a player supports zmp, returns 1 if they do, 0 otherwise.
has_zmp(object player)
note: zmp protocol is just a way to transfer information for zmp packages,
You'll still need to implement those in LPC
fixed the use of select()
compiles with C++ again (with dw's local_options anyway)
even more places to look for mysql libs
fixed profiling recursive functions
fixed profiling when a runtime error happens
fixed filedescriptor leak with compressed save files
fixed crasher in unloading object programs (this should have happened constantly
, so there's probably a bug preventing this from actually happening most
of the time).
the driver now finishes all async IO before finishing shutdown()
blocked socket fix for lpc network sockets (Hamlet)
package async now does sql!
async_db_exec(int db, string request, function callback);
don't use the same database handle with this call if you also use it
with db_exec(), just make an extra connection for your async sql.
new efun restore_from_string(string savedata), does what it says on the tin,
the string format is the same as a save file.
added optional int argument to request_term_size(). If 0, the client is asked
_not_ to offer any further term size updates (Hamlet, suggested by Detah)
FluffOS 2.16
improved single char mode support (Cratylus)
this includes some new efuns:
int query_charmode(object);
int remove_charmode(object);
int remove_get_char(object);
efun to send nullbytes (Raudhrskal)
int send_nullbyte(object);
improved ed failure mess (Cratylus)
new no arguments version of save_object, which returns the save string
fix to stop iconv looping forever
faster hashing for big strings (now stops after 1000 chars)
some new predefines (Cratylus)
async io fixes, sadly now requires pthreads
parser update (Cratylus)
sqlite support (Ajandurah@Demonslair)
compile warning fixes (Ajandurah@Demonslair)
crypto and sha1 package (Ajandurah@Demonslair)
added MSSP support, the driver will call get_mud_stats() on the master ob,
which should return a mapping with the keys/values, if a value is an
array of strings they'll all be sent as values for that key. The driver
send the NAME (from config file) PLAYERS and UPTIME values if the
function doesn't exist, if it does but didn't include one of those fields
the driver will add the field as those are required.
new malloc option malloc64 which tries to avoid needing big copies on realloc by spreading all allocations a few MB apart in virtual memory.
FluffOS 2.15:
IPV6 support
class stats (Skullslayer@Realms of the Dragon)
some console additions see 'help' in the console (Hamlet)
some 64 bit fixes (Woom)
compiles with C90 compilers (that's 19!!! years ago now) (Kalinash@lpmuds.net)
added string_difference(string, string) which returns the difference between strings as a number (Woom)
updated MySQL support (Shadyman@lpmuds.net)
fixed crasher when the master apply doesn't allow an object to be created
FluffOS 2.14:
fixed crasher in async writes.
fixed bug in switch/case when using more than 2GB memory
check 64 bit lib before 32 bit version for mysql
support classes in member_array
fixed copyright statement in regex file
fixed memory leak in large shared strings
fixed some memory leaks in async io
use clone_object sefun (if present) when cloning objects with new() (Kalinash)
FluffOS 2.13:
oh no! unlucky number
removed binaries support
fixed crasher in restore_string
fixed some new compiler warnings (gcc 4.3)
some cleanups in comm.c (Cratylus@Dead souls)
cygwin and other changes in build.FluffOS (Cratylus@Dead souls)
set program_t to {0} for silly OSes that don't clear BBS memory (Cratylus@Dead souls)
(I think there may be more places that could go wrong!)
changed locale to "C" (Cratylus@Dead souls)
Added a console, mostly for debugging use. If driver is started directly
rather than through a script, add argument -C and it has a
command-line. try 'help'. HAS_CONSOLE must be defined in
local_options. (hamlet)
fixed crasher where we did remove_interactive when people go netdead, bad idea!
FluffOS 2.12:
Crasher fixes in using a mudlib error handler (Cratylus@Dead souls)
some mingw fixes (Cratylus@Dead souls)
new localoptions.ds (Cratylus@Dead souls)
rework of ed to do larger output chunks, more configurability, and bugfixes:
mixed receive_ed(string msg, string fname) apply in playerob to
doctor the text (return 0 to have ed output to screen, 1 to have ed
output nothing, or return a new string for ed to output). Need to
define RECEIVE_ED in options.h. ed_start() and ed() take optional
final arg specifying lines on user's screen. Indentant fixed for
'foreach' and lines with only '//'. z++ and z-- now work. Optional
new compile-time defines: ED_INDENT_CASE (should we indent 'case'
after 'switch'?) and ED_INDENT_SPACES <num> for how far autoindent
will indent each level. (hamlet)
fixed several crashers (comm.c and simulate.c) related to using vsprintf
instead of vsnprintf. (hamlet)
added CFG_MAX_GLOBAL_VARIABLES to options.h. Old setting was an arbitrary 256.
(hamlet)
async writes with compression
fixed some memory leaks
stuff I forgot, it's been too long!
slightly useful sfuns if you use async:
void decode(object ob, int flag, function cb, string saved){
string *lines = explode(saved, "\n");
mixed vars = filter(variables(ob,1), (:strsrch($1[1], "nosave") == -1:));
vars = map(vars, (:$1[0]:));
if(!flag)
map(vars, bind((:store_variable($1, 0):), ob));
vars = allocate_mapping(vars, 1);
foreach(string line in lines){
if(line[0] == '#')
continue;
else {
int i = strsrch(line, ' ');
if(vars[line[0..i-1]])
evaluate(bind((:store_variable, line[0..i-1], restore_variable(line[i+1\..]):), ob));
}
}
evaluate(cb);
}
void restore_object_async(string name, int flag, function cb){
async_read(name, (: decode, previous_object(), flag, cb :));
}
void save_object_async(string name, int flag, function cb){
mixed vars = filter(variables(previous_object(),1), (:strsrch($1[1], "nosave"\) == -1:));
string *lines = allocate(sizeof(vars)+1);
vars = map(vars, (:$1[0]:));
lines[0] = "#"+base_name(previous_object())+".c";
for(int i = 0; i < sizeof(vars); i++){
string val = save_variable(evaluate(bind((:fetch_variable, vars[i]:), previ\ous_object())));
if(flag & 1 || val)
lines[i+1] = vars[i] + " " + val;
}
async_write(name, implode(lines, "\n"), flag | 1, cb);
}
FluffOS 2.11:
stop eval_cost() adding to the time you're allowed to run. (libc return a time
longer than the set time if you query the remaining time right after
restarting the timer!
reset_eval_cost() now stops working after 100*max eval cost.
hopefully fixed readfile with lines beyond max readsize.
FluffOS 2.10:
can be compiled with g++
fix bugs in using arrays as sets
int *a=({1<<31,0}); return a-a
fixed crash in the children efun (hamlet)
FluffOS 2.9:
removed amiga support.
included most DS changes, should work on windows now (except for over
evaluation errors)
changed alist_cmp to work on longs rather than int, and store program offsets
as 32 bit ints (instead of 64 (with room for 32) which fixed crashing
with 64 bit on solaris and stopped crashing on linux when using over
2GB memory.
added package async for async read and write support.
removed some dead code
fixed crasher in read_file() (i hope)
fixed makefile so it doesn't rebuild everything all the time
slightly bigger buffers for lex.c so it can load files quicker.
made buffer handling in loading compressed save files a bit smarter
fixed bug in children()
actually calculate the hash values for objects again, oops.
fixed crasher in event()
moved some functions to package contrib:
int num_classes( object );
returns the amount of class definitions in the object
mixed assemble_class( mixed * );
returns a class with fields filled in from the array arg
mixed *disassemble_class( mixed );
returns an array with all class elements
mixed fetch_class_member( mixed, int );
same as disassemble_class(mixed)[int];
mixed store_class_member( mixed, int, mixed );
set a class member by offset
mixed *shuffle(mixed *);
shuffle array members around and return the array (original is changed as
well!)
mixed element_of(mixed *);
same as array[random(sizeof(array))]
mixed max( mixed *, int | void );
returns the max value in the array, or the index of that value if the
second argument is present and not 0
mixed min( mixed *, int | void );
see max, but then lowest
mixed abs( int | float );
guess.
FluffOS 2.8:
use a hash table for the children() efun
set the usec field in the select timeout
fixed sending sending byte value 255 (this will break any code that tries to
send telnet code, but that shouldn't be needed anyway and it didn't work
on UTF enabled drivers already.
removed a lot of casts to int, C does that by default, so it's not needed.
replaced whashstr with a simpler, faster (on modern CPUs) hash that isn't
limited to 16 bit results
fixed to_int so it doesn't truncate to 32 bit on 64 bit systems
now fills in maxrss in rusage on linux
changed from SIGALRM to SIGVTALRM, so other processes can't mess up the eval
time
added a __LINE__ predefine for the line number
changed mappings to use the hash function rather than pointer values for a
better spread over the hash table
the flag argument to functions() now uses 1 for extra info, 2 for limiting
the returned functions to those that are not inherited, those can be
combined (3)
replace_html and replace_mxp do the < to &lt; etc conversions
random() can now return larger than 32 bit numbers
commented out a recursion check in the parser so DS can parse its commands
FluffOS 2.7:
fixes to compile with a Dead Souls config
changed free_object() and free_program() to overwrite the freed address
(idea and first version by Pinkfish)
terminate string results of filter_string()
disable run time type checking if strict types isn't on
allow adding objects to strings (adds filename)
fixed crasher in DEBUG mode
send too long eval errors to the mudlib error handler, there's no real reason
not to!
fixed crasher for 64 bit dead souls
possibly fixed some bugs in shuffling around code for free_object
allow string a="dsfsd"; a+=10; it used to give a parse error! the code to
handle it was there though
read_file() can now read compressed files.
write_file() now has an extra flag (2) that can be ORed with the existing one
to write/append compressed files
add_ref() destruct objects with high ref counts (they're usually on the way to
wrap around to 0, which is where you crash).
FluffOS 2.6:
current_time is now 64 bit on 64 bit platforms, all ready for 2038 now, I think :)
fixed crasher in ed on big files with long lines (i hope)
new default arguments for destruct, virtualp, inherits (this_object) and ctime (time())
removed some code duplication in call_function_pointer()
switch(number){
case ..1:
return "low";
case 2:
return "middle";
case 3..:
return "high";
}
now works!
new WOMBLES config option that disallows spaces in ({ ([ (: :) ]) }) when used
for arrays, mappings and functionals.
fixed 64 bit compiles so you don't need to use one specific compiler with no optimisations anymore
made the objects list double linked so destruct doesn't have to walk the whole
list to find the previous object in the list.
fixed compiling without shadows support
FluffOS 2.5:
some pluralize() fixes (woom)
fixed zonetime() and is_daylight_savings_time()
FluffOS 2.4:
new efuns for sending telnet sequences:
void request_term_type();
void start_request_term_type();
void request_term_size();
restore_object now calls restore_lost_variable() if a variable in the save file
doesn't exist in the object, the arguments are the value and name of
the saved variable.
fixed crasher in event() when one of the earlier objects destructs an object
that still would have gotten the event.
FluffOS 2.3:
fixed event efun (from 1.40)
added MAX_INT and SIZEOFINT predefines (from 1.40)
fixed leftover PROT1V macro use
replace is an efun now
virtual base obs are no longer seen as clones
FluffOS 2.2:
removed some more object swapping code
fixed memory leak in restoring gzipped save files
improved LPC function profiling
fixed ref counts in class/array efuns
FluffOS 2.1:
added str_to_arr, and arr_to_str efuns to convert between strings and UTF-32 arrays
added strwidth efun
fixed refs() for strings
FluffOS 2.0:
different from Fluffos 1.36:
changed integer type to 64 bit, and some other 64 bit cleanups, as 64 bit ints
change the way things work for the LPC side of things, I changed the major
number to 2.
removed swapping, the OS can do it much better than us.
removed LPC_TO_C as it has been broken for as long as i can remember (MudOSv21
times)
removed the annoying PROT P1 etc macros if you still use a K&R compiler it's
time to upgrade!
removed varargs.h support
removed warnings during compiling (with supplied localoptions file)
removed gdbm files as they couldn't even be used (no spec file!)
removed dw specific debugging code
added iconv support
If activated:
All text in the mud is UTF-8
int set_encoding(string); //sets the encoding for this_players
string to_utf8(string, string); //convert enc encoded str to UTF-8
string utf8_to(string, string); //convert UTF-8 encoded str to enc
some additions to pluralize() (woom)
new functions in dwlib package (woom)
mixed abs( int | float );
mixed assemble_class( mixed * );
mixed *disassemble_class( mixed );
mixed fetch_class_member( mixed, int );
void store_class_member( mixed, int, mixed );

View File

@ -0,0 +1,158 @@
###############################################################################
# Customizable runtime config file for MudOS v21 #
###############################################################################
# NOTE: All paths specified here are relative to the mudlib directory except #
# for mudlib directory, and binary directory. #
# Lines beginning with a # or a newline are ignored. #
###############################################################################
# name of this mud
name : testsuite
# for machines with multiple IP addresses, this specifies which one to use. this
# replaces the SERVER_IP compile-time define.
#mud ip : 255.255.255.255
# if MudOS inherits an open file descriptor #6 from its parent process, it uses
# that as an additional login port. the 'port #' for internal purposes (debug
# messages, argument to connect, etc.) and kind should be set here. acceptable
# port types are: ascii, binary, mud or telnet. this replaces the FD6_KIND and
# FD6_PORT compile-time defines.
#fd6 kind : telnet
#fd6 port : 23
# the address server is an external program that lets the mud translate
# internet names to numbers (and vice versa). select an unused port.
address server ip : localhost
address server port : 9997
# absolute pathname of mudlib
mudlib directory : /home/mmessier/mudos/mudos/beta/testsuite
# absolute pathname of driver/config dir
binary directory : /home/mmessier/mudos/mudos/beta/testsuite
# debug.log and author/domain stats are stored here
log directory : /log
# the directories which are searched by #include <...>
# for multiple dirs, separate each path with a ':'
include directories : /include
# Directory to save binaries in. (if BINARIES is defined)
save binaries directory : /binaries
# the file which defines the master object
master file : /single/master
# the file where all global simulated efuns are defined.
simulated efun file : /single/simul_efun
# file to swap out objects; not used if time to swap is 0
swap file : /single/swapfile
# alternate debug.log file name (assumed to be in specified 'log directory')
debug log file : debug.log
# This is an include file which is automatically #include'd in all objects
global include file : "/include/globals.h"
# if an object is left alone for a certain time, then the
# function clean_up will be called. This function can do anything,
# like destructing the object. If the function isn't defined by the
# object, then nothing will happen.
# This time should be substantially longer than the swapping time.
time to clean up : 1200
# How long time until an unused object is swapped out.
# Machine with too many players and too little memory: 900 (15 minutes)
# Machine with few players and lot of memory: 10000
# Machine with infinite memory: 0 (never swap).
time to swap : 600
# How many seconds until an object is reset again.
time to reset : 1800
# Maximum number of bits in a bit field. They are stored in printable
# strings, 6 bits per byte.
maximum bits in a bitfield : 1200
# Max number of local variables in a function.
maximum local variables : 30
# Maximum amount of "eval cost" per thread - execution is halted when
# it is exceeded.
maximum evaluation cost : 500000
# This is the maximum array size allowed for one single array.
maximum array size : 15000
# This is the maximum allowed size of a variable of type 'buffer'.
maximum buffer size : 400000
# Max size for a mapping
maximum mapping size : 15000
# Max inherit chain size
inherit chain size : 30
# maximum length of a string variable
maximum string length : 200000
# Max size of a file allowed to be read by 'read_file()'.
maximum read file size : 200000
# max number of bytes you allow to be read and written with read_bytes
# and write_bytes
maximum byte transfer : 200000
# Reserve an extra memory area from malloc(), to free when we run out
# of memory and allow the mudlib to shutdown.
# If this value is 0, no area will be reserved.
reserved size : 0
# Define the size of the shared string hash table. This number should
# a prime, probably between 1000 and 30000; if you set it to about 1/5
# of the number of distinct strings you have, you will get a hit ratio
# (number of comparisons to find a string) very close to 1, as found strings
# are automatically moved to the head of a hash chain. You will never
# need more, and you will still get good results with a smaller table.
hash table size : 7001
# Object hash table size.
# Define this like you did with the strings; probably set to about 1/4 of
# the number of objects in a game, as the distribution of accesses to
# objects is somewhat more uniform than that of strings.
object table size : 1501
# default no-matching-action message
default fail message : What?
# default message when error() occurs (optional)
default error message :
# the external ports we support
external_port_1 : telnet 4000
external_port_2 : binary 4001
###############################################################################
# The following aren't currently used or implemented (yet) #
###############################################################################
# maximum number of users in the game (unused currently)
maximum users : 40
# Define the maximum stack size of the stack machine. This stack will also
# contain all local variables and arguments. (unused currently)
evaluator stack size : 1000
# Define the size of the compiler stack. This defines how complex
# expressions the compiler can parse. (unused currently)
compiler stack size : 200
# Define the maximum call depth for functions. (unused currently)
maximum call depth : 30
# There is a hash table for living objects, used by find_living().
# (unused currently)
living hash table size : 100

View File

@ -0,0 +1,19 @@
This game, LPmud, is copyright by Lars Pensj|, 1990, 1991.
Source code herein refers to the source code, and any executables
created from the same source code.
All rights reserved. Permission is granted to extend and modify the
source code provided subject to the restriction that the source code may
not be used in any way whatsoever for monetary gain.
******
The name MudOS is copyright 1991-1992 by Erik Kay, Adam Beeman, Stephan Iannce
and John Garnett. LPmud copyright restrictions still apply.
In addition, the entire package is copyright 1995 by Tim Hollebeek.
******
FluffOS is a range of patches to MudOS distributed as the patched source tree for convenience.
LPmud and MudOS copyright restrictions still apply.

View File

@ -0,0 +1,31 @@
The program was written originally by
Lars Pensj|, April 1989 (lars@cd.chalmers.se).
Other credits:
The regexp package was made by Henry Spencer.
The ed package was not done by me. See the file ed.c for information.
Bit manipulations was implemented by pell@lysator.liu.se who also found
several bugs that had eluded me for months.
Valuable help and hints from: Mark Nagel, James Seidman, Moonchilde and more.
Roland Dunkerley III fixed for-loops, do-while and the operators ++ and --.
Sean T Barrett made smalloc.c.
Lennart Augustsson convinced me to implement a compiler for a virtual
stack machine. He also implemented the built-in preprocessor.
John S. Price found and fixed many bugs.
The shadow idea was "forwarded" to me by John S. Price from Team Cthulhu
(Bill Burdick, Roy Riggs, Mitch Adler).
Michael Malone, Michael O'Reilly, Klaus Rennecke, J|rn Rennecke and
Germano Caronni found and fixed a large amount of bugs.
Petri Wessman fixed changes for SCO unix and AIX.

View File

@ -0,0 +1,99 @@
Read the Credits.LPmud file for credit information on the original LPmud
driver (that upon which MudOS is based). LPmud was originally written
by Lars Pensj|, April 1989.
The following information is not guaranteed to be complete. (I
apologize in advance if I have forgotten anyone). For more information
read the './doc/driver/done-mudos' and './src/ChangeLog' files.
We would like to thank the following muds for extensive testing and numerous
bug reports:
TMI, Portals, Overdrive, Genocide, TMI-2, Vincent's Hollow, DreamShadow,
Nightmare, Nanvaent, and many others.
The MudOS driver was a team effort with specific contributions from the
following people:
Erik Kay (Wayfarer) - runtime config system, message() efun, and others.
John Garnett (Truilkan) - improved mappings implementation, process_input
and write_prompt callbacks, C++ style comments, lazy resets,
master::valid_override callback, improved shared string management, and
others.
Dwayne Fontenot (Jacques) - major rewrite of comm.c, TCP socket efuns,
ported to AIX 3.2.
Dave Richards (Cynosure/Cygnus) - UDP socket efuns, enhanced TCP socket efuns,
ported MudOS to the Sequent Symmetry (System V Release 3),
and the time_expression() efun.
Stephen Iannce (Huthar) - children() and message() efuns, extensive testing of
the socket efunctions.
Joel York (Shadowhawk) - multiple arguments version of input_to(), dprint
option to ed.
Bob Farmer (Blackthorn) - fixed various efuns to honor the hidden object
flags, several new efuns, porting to DEC Alpha and others, bug fixes,
and others.
James Waldrop (Sulam) - helped with reorganizing the huge switch in
interpret.c into efunctions.c.
Michael Bundy - provided patches allowing MudOS to run on System V Release 4.
(built on Dave Richard's System V Release 3 port).
Luke Mewborn (Zak) - provided patches allowing MudOS to run on 386BSD
Olav Kolbu (Aragorn) - provided patches allowing MudOS to run on Linux 0.99.3,
many bug reports and misc fixes, countless compilation errors
Darin Johnson (Darin) - provided various patches and optimizations (including
combining prelang.y and postlang.y into compiler.y).
David Bennett (Pinkfish) - provided enhancements for parse_command and for the
telnet negotiation code in comm.c (as well as various other small bug
fixes), and the resolve() efun.
John Fehr (Wildcard) - provided patches allowing MudOS to run on Amiga
Anthon Pang (Robocoder) - provided various patches, optimize function
table search, amiga support
Tim Hollebeek (Beek) - LPC->C and patches, compiler rewrite, new function
pointers, etc
Ti-Ming Chiang (Symmetry, Cloud) - Countless optimizations; array, mapping and
save_object rewrites
Svata Dedic (Belgarat) - Win32 fixes, parser fixes, misc fixes
Martin Tyler (Burty) - lex.c fixes, other misc fixes
Troels Therkelsen (Qualin) - numerous bug reports and ideas
Maarten de Jong - amiga compilation via gcc
George Reese (Descartes) - bug reports, original Win32 port, mSQL support
Mark ? (Mystic) - tons of ideas; fixes for exotic options settings
Skeeter Hartwig (Jihad) - numerous bug reports
David Rudy (Aule) - optimizations; high usage testing and stability patches
Greg Stein (Deathblade) - various fixes and bug reports
Ben Gras (Fermat) - MD5 crypt(), various fixes
Kars de Jong (Turrican) - various bug fixes
Simon Matthews (Andrew) - MySQL support, various patches and bug reports
and tons of others who have accidentally been omitted
--
Thanks to Adam Beeman (Buddha) for making numerous suggestions on
improving the MudOS driver and for providing the TMI site as the original
MudOS development site.

View File

View File

@ -0,0 +1,59 @@
addr_server:
1 - error creating the socket or first arg was not a port #
2 - setsockopt() failed or port # was not a number
3 - error binding the socket (socket in use?)
4 - getsockname() failed
5 - couldn't create SIGPIPE handler
8 - set_socket_nonblocking() failed
10 - listen() failed
make_func:
1 - general fatal error
-1 - error opening a file
-2 - error opening OPC_PROF
-3 - error opening OPCODES
driver exit codes:
Note: the mudlib can send a shutdown code as an argument to shutdown.
Check your mudlib for documentation.
-3 - a crash occured while trying to exit via master::crash()
-2 - driver successfully shutdown via master::crash()
-1 - (a) The config file 'include dirs' setting was malformed
(b) bad definition of EXTRACT_UCHAR or memmove()
(c) no config file
(d) Illegal flag syntax
(e) Bad mudlib directory
(f) Master object failed to load
(g) Simul efun object failed to load
(one existed, but had errors)
(h) SIGUSR1 was recieved
(i) error in comfing file
0 - normal shutdown
1 - error creating user connection socket
or obscure fatal error in set_inc_list
or master called shutdown() from create()
or memset() failed
2 - setsockopt() failed
or driver out of memory and no reserve exists
3 - bind() failed
or driver ran out of memory again after freeing reserve
4 - getsockname() failed
5 - error setting up SIGPIPE handler
8 - error in set_socket_nonblocking()
129 - uncaught SIGHUP
130 - uncaught SIGINT (control-C)
131 - uncaught SIGQUIT (control-\)
132 - uncaught SIGILL (illegal instruction)
133 - uncaught SIGTRAP (trace trap)
134 - uncaught SIGABRT (MudOS abort due to failed assertion)
135 - uncaught SIGEMT
136 - uncaught SIGFPE (arithmetic exception)
137 - uncaught SIGKILL
138 - uncaught SIGBUS (bus error)
139 - uncaught SIGSEGV (seg fault)
140 - uncaught SIGSYS (bad system call)
143 - uncaught SIGTERM
144 - uncaught SIGUSR1
145 - uncaught SIGUSR2

View File

@ -0,0 +1,257 @@
# YOU DO NOT NEED TO CONFIGURE ANYTHING IN THIS FILE.
#
# RUN THE SHELL SCRIPT ./build.MudOS to generate the Makefiles, and follow
# its instructions.
#
############################################################################
#
# **** TARGETS AND THEIR CORRECT USAGE ****
#
# COMPILATION TARGETS:
#
# all: compile all the files
#
# install: make all, then move the files to the correct directories
#
# remake: remove the object files and generated files, and recompile
# NO reconfiguration is done, etc.
#
# depend: automatically create dependency info
#
#
# 'CLEAN' TARGETS:
#
# neat: remove object files and generated files (used by remake)
#
# clean: in addition to neat, also remove .orig and .rej files,
# cores, lint files, emacs backups, tag files, yacc debug
# files, generated Makefiles, generated binaries, and
# generated dependency info
#
# spotless: make clean, then remove ALL CONFIGURATION AND CUSTOMIZATION
# useful for creating distributions
#
# ---- REALLY COMPLEX OPTIONS YOU PROBABLY DON'T WANT TO TOUCH -----
#
# NeXT: link with MallocDebug if you have a NeXT with NeXTOS 2.1 or later and
# you wish to search for memory leaks (see /NextDeveloper/Apps/MallocDebug).
# Note: linking with MallocDebug will cause the virtual size of the
# driver process to reach appoximately 40MB however the amount of real memory
# used will remain close to normal.
#EXTRALIBS=-lMallocDebug -lsys_s
#
# ---- DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW ALOT ABOUT HOW
# MUDOS WORKS INTERNALLY ----
OVERRIDES=$(MAKEOVERRIDES)
# **************************************************************************
# **** NOTE: If you add something here, also add it to the OBJ= rule below,
# **** or non-GNU makes will die
# **************************************************************************
SRC=grammar.tab.c lex.c main.c rc.c interpret.c simulate.c file.c object.c \
backend.c array.c mapping.c comm.c ed.c regexp.c buffer.c crc32.c \
malloc.c mallocwrapper.c class.c efuns_main.c efuns_port.c \
call_out.c otable.c dumpstat.c stralloc.c hash.c \
port.c reclaim.c parse.c simul_efun.c sprintf.c program.c \
compiler.c avltree.c icode.c trees.c generate.c scratchpad.c \
socket_efuns.c socket_ctrl.c qsort.c eoperators.c socket_err.c md.c \
disassembler.c uvalarm.c $(STRFUNCS) \
replace_program.c master.c function.c \
debug.c crypt.c applies_table.c add_action.c eval.c fliconv.c console.c
all: $(OBJDIR) cc.h main_build
main_build2: $(DRIVER_BIN) addr_server portbind
main_build: files
$(MAKE) main_build2
VPATH = $(OBJDIR)
OBJ=$(addprefix $(OBJDIR)/,$(subst .c,.o,$(SRC)))
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) $(OPTIMIZE) -o $@ -c $<
$(OBJDIR)/lex.o: lex.c preprocess.c cc.h grammar.tab.c
$(OBJDIR)/grammar.tab.o: grammar.tab.c opcodes.h
$(OBJDIR):
mkdir -p $(OBJDIR)
which_makefile:
echo MakeIsGNU
grammar.tab.c: grammar.y
$(YACC) grammar.y
-rm -f grammar.tab.*
sed "s/y.tab.c/grammar.tab.c/g" y.tab.c > grammar.tab.c
-mv y.tab.h grammar.tab.h
packages/packages.a: packages/*.c
$(MAKE) -C packages 'CC=$(CC)' 'CFLAGS=$(CFLAGS) $(OPTIMIZE)' 'OBJDIR=../$(OBJDIR)' 'RANLIB=$(RANLIB)' 'A=$(A)' 'O=$(O)'
$(DRIVER_BIN): packages/packages.a $(OBJ) dtrace_compile
-mv -f $(DRIVER_BIN) $(DRIVER_BIN).old
$(PROOF) $(CC) $(CFLAGS) $(OPTIMIZE) $(OBJ) `./dtrace_compile` -o $(DRIVER_BIN) packages/packages.a $(EXTRALIBS) `cat system_libs`
dtrace_compile: dtrace_compile.c local_options
$(CC) dtrace_compile.c -o dtrace_compile
addr_server: files $(OBJDIR)/addr_server.o $(OBJDIR)/socket_ctrl.o $(OBJDIR)/port.o addr_server.h
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/socket_ctrl.o $(OBJDIR)/addr_server.o $(OBJDIR)/port.o \
-o addr_server `cat system_libs`
portbind: $(OBJDIR)/portbind.o
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/portbind.o -o portbind `cat system_libs`
remake: neat all
customize:
-cp ../local_options .
-cp ../system_libs .
-cp ../configure.h .
depend: opcodes.h grammar.tab.c cc.h efunctions.h efun_defs.c configure.h
-rm tmpdepend
for i in *.c; do $(CC) -MM -DDEPEND $$i >>tmpdepend; done
sed -e "s!^[^ ]!$(OBJDIR)/&!" <tmpdepend >Dependencies
-rm tmpdepend
cc.h: GNUmakefile
rm -f cc.h
echo "/* this file automatically generated by the Makefile */" > cc.h
echo '#define COMPILER "$(CC)"' >> cc.h
echo '#define OPTIMIZE "$(OPTIMIZE)"' >> cc.h
echo '#define CFLAGS "$(CFLAGS) $(OPTIMIZE)"' >> cc.h
echo '#define OBJDIR "$(OBJDIR)"' >> cc.h
# the touches here are necessary to fix the modification times; link(2) does
# 'modify' a file
files: edit_source sysmalloc.c debugmalloc.c wrappedmalloc.c options.h op_spec.c func_spec.c packages/Makefile.pre packages/GNUmakefile.pre configure.h grammar.y.pre
./edit_source -options -malloc -build_func_spec '$(CPP) $(CFLAGS)' \
-process grammar.y.pre
./edit_source -process packages/Makefile.pre
./edit_source -process packages/GNUmakefile.pre
./edit_source -build_efuns -build_applies
touch mallocwrapper.c
touch malloc.c
touch files
make_func.tab.c: make_func.y cc.h
$(YACC) $(YFLAGS) make_func.y
-rm -f make_func.tab.c
mv y.tab.c make_func.tab.c
configure.h: edit_source build.FluffOS
-if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
rm -f configuration; \
touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
echo "Skipping configuration ..."; \
else \
./edit_source -configure; \
echo "Machine `uname -a` Configure version 5" > configuration; \
fi
$(OBJDIR)/edit_source.o: edit_source.c preprocess.c cc.h
edit_source: $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o
$(CC) $(CFLAGS) $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o -o edit_source
# don't optimize these two
$(OBJDIR)/edit_source.o: edit_source.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJDIR)/make_func.tab.o: make_func.tab.c
$(CC) $(CFLAGS) -o $@ -c $<
tags: $(SRC)
ctags $(SRC)
TAGS: $(SRC)
etags $(SRC)
install: all
-mkdir $(INSTALL_DIR)
$(INSTALL) $(DRIVER_BIN) $(INSTALL_DIR)
$(INSTALL) addr_server $(INSTALL_DIR)
$(INSTALL) portbind $(INSTALL_DIR)
Makefiles: Makefile.in NMakefile.in
Makefile.in: edit_source Makefile.in.pre Makefile.master
./edit_source -process Makefile.in.pre
NMakefile.in: edit_source NMakefile.in.pre Makefile.master
./edit_source -process NMakefile.in.pre
nothing:
# remove local configuration
spotless: clean
-rm -f configure.h local_options system_libs configuration
-rm -f options_incl.h
-rm -f *.diffs
-find . -name "*~" -print | xargs rm
-rm -f 1.out 2.out
# get ready for recompile
neat:
-(cd packages; $(MAKE) "A=$(A)" "O=$(O)" clean)
-rm -rf $(OBJDIR) *.$(O) *.tab.c *.tab.h
-rm -f efun_defs.c option_defs.c
-rm -f opcodes.h efunctions.h opc.h efun_protos.h
-rm -f malloc.c mallocwrapper.c
-rm -f func_spec.cpp applies.h applies_table.c files
-rm -f grammar.y comptest* a.out *.exe
-rm -f packages/Makefile packages/GNUmakefile packages/packages
# remove everything except configuration
clean: neat
-rm -f Makefile.MudOS GNUmakefile.MudOS
-rm -f cc.h edit_source
-rm -f core y.output testsuite/core testsuite/tmp/*
-rm -f testsuite/OPCPROF.* testsuite/opc.*
-rm -rf testsuite/binaries testsuite/single/swapfile.*
-rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
-rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
-rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
-find . -name "*~" -print | xargs rm
-find . -name "*.orig" -print | xargs rm
-find . -name "*.rej" -print | xargs rm
-rm -f *.ln tags TAGS
-rm -f $(DRIVER_BIN) $(DRIVER_BIN).old addr_server portbind *.exe
-rm -f Dependencies tmpdepend
-touch Dependencies
# remove everything
distclean: neat
-rm -f Makefile.MudOS GNUmakefile.MudOS
-rm -f cc.h edit_source
-rm -f core y.output testsuite/core testsuite/tmp/*
-rm -f testsuite/OPCPROF.* testsuite/opc.*
-rm -rf testsuite/binaries testsuite/single/swapfile.*
-rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
-rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
-rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
-find . -name "*~" -print | xargs rm
-find . -name "*.orig" -print | xargs rm
-find . -name "*.rej" -print | xargs rm
-rm -f *.ln tags TAGS
-rm -f $(DRIVER_BIN) $(DRIVER_BIN).old addr_server portbind
-rm -f *.exe
-rm -f configure.h system_libs options_incl.h insttest configuration
-rm -f 1.out 2.out
-rm -f local_options
-rm -f dtrace_compile
-rm -f trash_me.bat trash_me.err
-cp -f GNUmakefile.in GNUmakefile
-rm -f Dependencies tmpdepend
-rm -f semantic* packages/semantic*
-touch Dependencies
include Dependencies

View File

@ -0,0 +1,256 @@
MAKE=gmake
SHELL=/bin/sh
OBJDIR=obj
DRIVER_BIN=driver
PROOF=
STRFUNCS=
INSTALL=install -c
INSTALL_DIR=../bin
OPTIMIZE=-Wall -Wundef -DPEDANTIC -Wmissing-declarations
CPP=gcc -E
CFLAGS=-D__USE_FIXED_PROTOTYPES__ -DHAVE_ZLIB -g -DDEBUG -DDEBUG_MACRO -rdynamic
CC=gcc
YACC=bison -d -y
RANLIB=ranlib
A=a
O=o
# YOU DO NOT NEED TO CONFIGURE ANYTHING IN THIS FILE.
#
# RUN THE SHELL SCRIPT ./build.MudOS to generate the Makefiles, and follow
# its instructions.
#
############################################################################
#
# **** TARGETS AND THEIR CORRECT USAGE ****
#
# COMPILATION TARGETS:
#
# all: compile all the files
#
# install: make all, then move the files to the correct directories
#
# remake: remove the object files and generated files, and recompile
# NO reconfiguration is done, etc.
#
# depend: automatically create dependency info
#
# Makefiles: update Makefile.in and GNUmakefile.in from Makefile.master
# (only necessary after making changes to Makefile.master)
#
# 'CLEAN' TARGETS:
#
# neat: remove object files and generated files (used by remake)
#
# clean: in addition to neat, also remove .orig and .rej files,
# cores, lint files, emacs backups, tag files, yacc debug
# files, generated Makefiles, generated binaries, and
# generated dependency info
#
# spotless: make clean, then remove ALL CONFIGURATION AND CUSTOMIZATION
# useful for creating distributions
#
# ---- REALLY COMPLEX OPTIONS YOU PROBABLY DON'T WANT TO TOUCH -----
#
# NeXT: link with MallocDebug if you have a NeXT with NeXTOS 2.1 or later and
# you wish to search for memory leaks (see /NextDeveloper/Apps/MallocDebug).
# Note: linking with MallocDebug will cause the virtual size of the
# driver process to reach appoximately 40MB however the amount of real memory
# used will remain close to normal.
#EXTRALIBS=-lMallocDebug -lsys_s
#
# ---- DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW ALOT ABOUT HOW
# MUDOS WORKS INTERNALLY ----
OVERRIDES=$(MAKEOVERRIDES)
# **************************************************************************
# **** NOTE: If you add something here, also add it to the OBJ= rule below,
# **** or non-GNU makes will die
# **************************************************************************
SRC=grammar.tab.c lex.c main.c rc.c interpret.c simulate.c file.c object.c \
backend.c array.c mapping.c comm.c ed.c regexp.c swap.c buffer.c crc32.c \
malloc.c mallocwrapper.c class.c efuns_main.c efuns_port.c \
call_out.c otable.c dumpstat.c stralloc.c hash.c \
port.c reclaim.c parse.c simul_efun.c sprintf.c program.c \
compiler.c avltree.c icode.c trees.c generate.c scratchpad.c \
socket_efuns.c socket_ctrl.c qsort.c eoperators.c socket_err.c md.c \
disassembler.c binaries.c ualarm.c $(STRFUNCS) \
replace_program.c ccode.c cfuns.c compile_file.c master.c function.c \
debug.c crypt.c applies_table.c add_action.c
all: $(OBJDIR) cc.h files main_build
main_build: $(DRIVER_BIN) addr_server portbind
parallel:
$(MAKE) -k -l -j 6 cc.h files
$(MAKE) -k -l -j 6 main_build
VPATH = $(OBJDIR)
OBJ=$(addprefix $(OBJDIR)/,$(subst .c,.o,$(SRC)))
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) $(OPTIMIZE) -o $@ -c $<
$(OBJDIR)/lex.o: lex.c preprocess.c cc.h grammar.tab.c
$(OBJDIR)/grammar.tab.o: grammar.tab.c opcodes.h
$(OBJDIR):
mkdir -p $(OBJDIR)
which_makefile:
echo MakeIsGNU
grammar.tab.c: grammar.y
$(YACC) grammar.y
-rm -f grammar.tab.*
sed "s/y.tab.c/grammar.tab.c/g" y.tab.c > grammar.tab.c
-mv y.tab.h grammar.tab.h
packages/packages.a: packages/parser.c packages/contrib.c
$(MAKE) -C packages 'CC=$(CC)' 'CFLAGS=$(CFLAGS) $(OPTIMIZE)' 'OBJDIR=../$(OBJDIR)' 'RANLIB=$(RANLIB)' 'A=$(A)' 'O=$(O)'
mudlib/mudlib.a:
$(MAKE) -C mudlib 'CC=$(CC)' 'CFLAGS=$(CFLAGS) $(OPTIMIZE)' 'OBJDIR=../$(OBJDIR)' 'RANLIB=$(RANLIB)' 'A=$(A)' 'O=$(O)'
$(DRIVER_BIN): packages/packages.a mudlib/mudlib.a $(OBJ)
-mv -f $(DRIVER_BIN) $(DRIVER_BIN).old
$(PROOF) $(CC) $(CFLAGS) $(OPTIMIZE) $(OBJ) -o $(DRIVER_BIN) packages/packages.a mudlib/mudlib.a $(EXTRALIBS) `cat system_libs`
addr_server: files $(OBJDIR)/addr_server.o $(OBJDIR)/socket_ctrl.o $(OBJDIR)/port.o addr_server.h
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/socket_ctrl.o $(OBJDIR)/addr_server.o $(OBJDIR)/port.o \
-o addr_server `cat system_libs`
portbind: $(OBJDIR)/portbind.o
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/portbind.o -o portbind `cat system_libs`
remake: neat all
customize:
-cp ../local_options .
-cp ../system_libs .
-cp ../configure.h .
depend: opcodes.h grammar.tab.c cc.h efunctions.h efun_defs.c configure.h
-rm tmpdepend
for i in *.c; do $(CC) -MM -DDEPEND $$i >>tmpdepend; done
sed -e "s!^[^ ]!$(OBJDIR)/&!" <tmpdepend >Dependencies
-rm tmpdepend
cc.h: GNUmakefile
rm -f cc.h
echo "/* this file automatically generated by the Makefile */" > cc.h
echo '#define COMPILER "$(CC)"' >> cc.h
echo '#define OPTIMIZE "$(OPTIMIZE)"' >> cc.h
echo '#define CFLAGS "$(CFLAGS) $(OPTIMIZE)"' >> cc.h
echo '#define OBJDIR "$(OBJDIR)"' >> cc.h
# the touches here are necessary to fix the modification times; link(2) does
# 'modify' a file
files: edit_source sysmalloc.c smalloc.c bsdmalloc.c debugmalloc.c wrappedmalloc.c options.h op_spec.c func_spec.c mudlib/Makefile.pre mudlib/GNUmakefile.pre packages/Makefile.pre packages/GNUmakefile.pre configure.h grammar.y.pre
./edit_source -options -malloc -build_func_spec '$(CPP) $(CFLAGS)' \
-process grammar.y.pre
./edit_source -process packages/Makefile.pre
./edit_source -process packages/GNUmakefile.pre
./edit_source -process mudlib/Makefile.pre
./edit_source -process mudlib/GNUmakefile.pre
./edit_source -build_efuns -build_applies
touch mallocwrapper.c
touch malloc.c
touch files
make_func.tab.c: make_func.y cc.h
$(YACC) $(YFLAGS) make_func.y
-rm -f make_func.tab.c
mv y.tab.c make_func.tab.c
configure.h: edit_source build.MudOS
-if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
rm -f configuration; \
touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
echo "Skipping configuration ..."; \
else \
./edit_source -configure; \
echo "Machine `uname -a` Configure version 5" > configuration; \
fi
$(OBJDIR)/edit_source.o: edit_source.c preprocess.c cc.h
edit_source: $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o
$(CC) $(CFLAGS) $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o -o edit_source
# don't optimize these two
$(OBJDIR)/edit_source.o: edit_source.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJDIR)/make_func.tab.o: make_func.tab.c
$(CC) $(CFLAGS) -o $@ -c $<
tags: $(SRC)
ctags $(SRC)
TAGS: $(SRC)
etags $(SRC)
install: all
-mkdir $(INSTALL_DIR)
$(INSTALL) $(DRIVER_BIN) $(INSTALL_DIR)
$(INSTALL) addr_server $(INSTALL_DIR)
$(INSTALL) portbind $(INSTALL_DIR)
Makefiles: Makefile.in GNUmakefile.in NMakefile.in
Makefile.in: edit_source Makefile.in.pre Makefile.master
./edit_source -process Makefile.in.pre
GNUmakefile.in: edit_source GNUmakefile.in.pre Makefile.master
./edit_source -process GNUmakefile.in.pre
NMakefile.in: edit_source NMakefile.in.pre Makefile.master
./edit_source -process NMakefile.in.pre
nothing:
# remove local configuration
spotless: clean
-rm -f configure.h local_options system_libs configuration
-rm -f options_incl.h
-rm -f *.diffs
-find . -name "*~" -print | xargs rm
# get ready for recompile
neat:
-(cd packages; $(MAKE) "A=$(A)" "O=$(O)" clean)
-(cd mudlib; $(MAKE) "A=$(A)" "O=$(O)" clean)
-rm -rf $(OBJDIR) *.$(O) *.tab.c *.tab.h
-rm -f efun_defs.c option_defs.c
-rm -f opcodes.h efunctions.h opc.h efun_protos.h
-rm -f malloc.c mallocwrapper.c
-rm -f func_spec.cpp applies.h applies_table.c files
-rm -f grammar.y comptest* a.out
-rm -f packages/Makefile packages/GNUmakefile packages/packages
# remove everything except configuration
clean: neat
-rm -f Makefile.MudOS GNUmakefile.MudOS
-rm -f cc.h edit_source
-rm -f core y.output testsuite/core testsuite/tmp/*
-rm -f testsuite/OPCPROF.* testsuite/opc.*
-rm -rf testsuite/binaries testsuite/single/swapfile.*
-rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
-rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
-rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
-find . -name "*~" -print | xargs rm
-find . -name "*.orig" -print | xargs rm
-find . -name "*.rej" -print | xargs rm
-rm -f *.ln tags TAGS
-rm -f $(DRIVER_BIN) $(DRIVER_BIN).old addr_server portbind
-rm -f Dependencies tmpdepend
-touch Dependencies
include Dependencies

View File

@ -0,0 +1,257 @@
# YOU DO NOT NEED TO CONFIGURE ANYTHING IN THIS FILE.
#
# RUN THE SHELL SCRIPT ./build.MudOS to generate the Makefiles, and follow
# its instructions.
#
############################################################################
#
# **** TARGETS AND THEIR CORRECT USAGE ****
#
# COMPILATION TARGETS:
#
# all: compile all the files
#
# install: make all, then move the files to the correct directories
#
# remake: remove the object files and generated files, and recompile
# NO reconfiguration is done, etc.
#
# depend: automatically create dependency info
#
#
# 'CLEAN' TARGETS:
#
# neat: remove object files and generated files (used by remake)
#
# clean: in addition to neat, also remove .orig and .rej files,
# cores, lint files, emacs backups, tag files, yacc debug
# files, generated Makefiles, generated binaries, and
# generated dependency info
#
# spotless: make clean, then remove ALL CONFIGURATION AND CUSTOMIZATION
# useful for creating distributions
#
# ---- REALLY COMPLEX OPTIONS YOU PROBABLY DON'T WANT TO TOUCH -----
#
# NeXT: link with MallocDebug if you have a NeXT with NeXTOS 2.1 or later and
# you wish to search for memory leaks (see /NextDeveloper/Apps/MallocDebug).
# Note: linking with MallocDebug will cause the virtual size of the
# driver process to reach appoximately 40MB however the amount of real memory
# used will remain close to normal.
#EXTRALIBS=-lMallocDebug -lsys_s
#
# ---- DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW ALOT ABOUT HOW
# MUDOS WORKS INTERNALLY ----
OVERRIDES=$(MAKEOVERRIDES)
# **************************************************************************
# **** NOTE: If you add something here, also add it to the OBJ= rule below,
# **** or non-GNU makes will die
# **************************************************************************
SRC=grammar.tab.c lex.c main.c rc.c interpret.c simulate.c file.c object.c \
backend.c array.c mapping.c comm.c ed.c regexp.c buffer.c crc32.c \
malloc.c mallocwrapper.c class.c efuns_main.c efuns_port.c \
call_out.c otable.c dumpstat.c stralloc.c hash.c \
port.c reclaim.c parse.c simul_efun.c sprintf.c program.c \
compiler.c avltree.c icode.c trees.c generate.c scratchpad.c \
socket_efuns.c socket_ctrl.c qsort.c eoperators.c socket_err.c md.c \
disassembler.c uvalarm.c $(STRFUNCS) \
replace_program.c master.c function.c \
debug.c crypt.c applies_table.c add_action.c eval.c fliconv.c console.c
all: $(OBJDIR) cc.h main_build
main_build2: $(DRIVER_BIN) addr_server portbind
main_build: files
$(MAKE) main_build2
VPATH = $(OBJDIR)
OBJ=$(addprefix $(OBJDIR)/,$(subst .c,.o,$(SRC)))
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) $(OPTIMIZE) -o $@ -c $<
$(OBJDIR)/lex.o: lex.c preprocess.c cc.h grammar.tab.c
$(OBJDIR)/grammar.tab.o: grammar.tab.c opcodes.h
$(OBJDIR):
mkdir -p $(OBJDIR)
which_makefile:
echo MakeIsGNU
grammar.tab.c: grammar.y
$(YACC) grammar.y
-rm -f grammar.tab.*
sed "s/y.tab.c/grammar.tab.c/g" y.tab.c > grammar.tab.c
-mv y.tab.h grammar.tab.h
packages/packages.a: packages/*.c
$(MAKE) -C packages 'CC=$(CC)' 'CFLAGS=$(CFLAGS) $(OPTIMIZE)' 'OBJDIR=../$(OBJDIR)' 'RANLIB=$(RANLIB)' 'A=$(A)' 'O=$(O)'
$(DRIVER_BIN): packages/packages.a $(OBJ) dtrace_compile
-mv -f $(DRIVER_BIN) $(DRIVER_BIN).old
$(PROOF) $(CC) $(CFLAGS) $(OPTIMIZE) $(OBJ) `./dtrace_compile` -o $(DRIVER_BIN) packages/packages.a $(EXTRALIBS) `cat system_libs`
dtrace_compile: dtrace_compile.c local_options
$(CC) dtrace_compile.c -o dtrace_compile
addr_server: files $(OBJDIR)/addr_server.o $(OBJDIR)/socket_ctrl.o $(OBJDIR)/port.o addr_server.h
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/socket_ctrl.o $(OBJDIR)/addr_server.o $(OBJDIR)/port.o \
-o addr_server `cat system_libs`
portbind: $(OBJDIR)/portbind.o
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/portbind.o -o portbind `cat system_libs`
remake: neat all
customize:
-cp ../local_options .
-cp ../system_libs .
-cp ../configure.h .
depend: opcodes.h grammar.tab.c cc.h efunctions.h efun_defs.c configure.h
-rm tmpdepend
for i in *.c; do $(CC) -MM -DDEPEND $$i >>tmpdepend; done
sed -e "s!^[^ ]!$(OBJDIR)/&!" <tmpdepend >Dependencies
-rm tmpdepend
cc.h: GNUmakefile
rm -f cc.h
echo "/* this file automatically generated by the Makefile */" > cc.h
echo '#define COMPILER "$(CC)"' >> cc.h
echo '#define OPTIMIZE "$(OPTIMIZE)"' >> cc.h
echo '#define CFLAGS "$(CFLAGS) $(OPTIMIZE)"' >> cc.h
echo '#define OBJDIR "$(OBJDIR)"' >> cc.h
# the touches here are necessary to fix the modification times; link(2) does
# 'modify' a file
files: edit_source sysmalloc.c debugmalloc.c wrappedmalloc.c options.h op_spec.c func_spec.c packages/Makefile.pre packages/GNUmakefile.pre configure.h grammar.y.pre
./edit_source -options -malloc -build_func_spec '$(CPP) $(CFLAGS)' \
-process grammar.y.pre
./edit_source -process packages/Makefile.pre
./edit_source -process packages/GNUmakefile.pre
./edit_source -build_efuns -build_applies
touch mallocwrapper.c
touch malloc.c
touch files
make_func.tab.c: make_func.y cc.h
$(YACC) $(YFLAGS) make_func.y
-rm -f make_func.tab.c
mv y.tab.c make_func.tab.c
configure.h: edit_source build.FluffOS
-if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
rm -f configuration; \
touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
echo "Skipping configuration ..."; \
else \
./edit_source -configure; \
echo "Machine `uname -a` Configure version 5" > configuration; \
fi
$(OBJDIR)/edit_source.o: edit_source.c preprocess.c cc.h
edit_source: $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o
$(CC) $(CFLAGS) $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o -o edit_source
# don't optimize these two
$(OBJDIR)/edit_source.o: edit_source.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJDIR)/make_func.tab.o: make_func.tab.c
$(CC) $(CFLAGS) -o $@ -c $<
tags: $(SRC)
ctags $(SRC)
TAGS: $(SRC)
etags $(SRC)
install: all
-mkdir $(INSTALL_DIR)
$(INSTALL) $(DRIVER_BIN) $(INSTALL_DIR)
$(INSTALL) addr_server $(INSTALL_DIR)
$(INSTALL) portbind $(INSTALL_DIR)
Makefiles: Makefile.in NMakefile.in
Makefile.in: edit_source Makefile.in.pre Makefile.master
./edit_source -process Makefile.in.pre
NMakefile.in: edit_source NMakefile.in.pre Makefile.master
./edit_source -process NMakefile.in.pre
nothing:
# remove local configuration
spotless: clean
-rm -f configure.h local_options system_libs configuration
-rm -f options_incl.h
-rm -f *.diffs
-find . -name "*~" -print | xargs rm
-rm -f 1.out 2.out
# get ready for recompile
neat:
-(cd packages; $(MAKE) "A=$(A)" "O=$(O)" clean)
-rm -rf $(OBJDIR) *.$(O) *.tab.c *.tab.h
-rm -f efun_defs.c option_defs.c
-rm -f opcodes.h efunctions.h opc.h efun_protos.h
-rm -f malloc.c mallocwrapper.c
-rm -f func_spec.cpp applies.h applies_table.c files
-rm -f grammar.y comptest* a.out *.exe
-rm -f packages/Makefile packages/GNUmakefile packages/packages
# remove everything except configuration
clean: neat
-rm -f Makefile.MudOS GNUmakefile.MudOS
-rm -f cc.h edit_source
-rm -f core y.output testsuite/core testsuite/tmp/*
-rm -f testsuite/OPCPROF.* testsuite/opc.*
-rm -rf testsuite/binaries testsuite/single/swapfile.*
-rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
-rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
-rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
-find . -name "*~" -print | xargs rm
-find . -name "*.orig" -print | xargs rm
-find . -name "*.rej" -print | xargs rm
-rm -f *.ln tags TAGS
-rm -f $(DRIVER_BIN) $(DRIVER_BIN).old addr_server portbind *.exe
-rm -f Dependencies tmpdepend
-touch Dependencies
# remove everything
distclean: neat
-rm -f Makefile.MudOS GNUmakefile.MudOS
-rm -f cc.h edit_source
-rm -f core y.output testsuite/core testsuite/tmp/*
-rm -f testsuite/OPCPROF.* testsuite/opc.*
-rm -rf testsuite/binaries testsuite/single/swapfile.*
-rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
-rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
-rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
-find . -name "*~" -print | xargs rm
-find . -name "*.orig" -print | xargs rm
-find . -name "*.rej" -print | xargs rm
-rm -f *.ln tags TAGS
-rm -f $(DRIVER_BIN) $(DRIVER_BIN).old addr_server portbind
-rm -f *.exe
-rm -f configure.h system_libs options_incl.h insttest configuration
-rm -f 1.out 2.out
-rm -f local_options
-rm -f dtrace_compile
-rm -f trash_me.bat trash_me.err
-cp -f GNUmakefile.in GNUmakefile
-rm -f Dependencies tmpdepend
-rm -f semantic* packages/semantic*
-touch Dependencies
include Dependencies

View File

@ -0,0 +1,257 @@
MAKE=gmake
SHELL=/bin/sh
OBJDIR=obj
DRIVER_BIN=driver
PROOF=
STRFUNCS=
INSTALL=install -c
INSTALL_DIR=../bin
OPTIMIZE= -O2
CPP=gcc -E
CFLAGS=-D__USE_FIXED_PROTOTYPES__ -DHAVE_ZLIB -rdynamic
CC=icc -ip -wd864,1173 -xK
#CC=gcc -g
YACC=bison -d -y
RANLIB=ranlib
A=a
O=o
# YOU DO NOT NEED TO CONFIGURE ANYTHING IN THIS FILE.
#
# RUN THE SHELL SCRIPT ./build.MudOS to generate the Makefiles, and follow
# its instructions.
#
############################################################################
#
# **** TARGETS AND THEIR CORRECT USAGE ****
#
# COMPILATION TARGETS:
#
# all: compile all the files
#
# install: make all, then move the files to the correct directories
#
# remake: remove the object files and generated files, and recompile
# NO reconfiguration is done, etc.
#
# depend: automatically create dependency info
#
# Makefiles: update Makefile.in and GNUmakefile.in from Makefile.master
# (only necessary after making changes to Makefile.master)
#
# 'CLEAN' TARGETS:
#
# neat: remove object files and generated files (used by remake)
#
# clean: in addition to neat, also remove .orig and .rej files,
# cores, lint files, emacs backups, tag files, yacc debug
# files, generated Makefiles, generated binaries, and
# generated dependency info
#
# spotless: make clean, then remove ALL CONFIGURATION AND CUSTOMIZATION
# useful for creating distributions
#
# ---- REALLY COMPLEX OPTIONS YOU PROBABLY DON'T WANT TO TOUCH -----
#
# NeXT: link with MallocDebug if you have a NeXT with NeXTOS 2.1 or later and
# you wish to search for memory leaks (see /NextDeveloper/Apps/MallocDebug).
# Note: linking with MallocDebug will cause the virtual size of the
# driver process to reach appoximately 40MB however the amount of real memory
# used will remain close to normal.
#EXTRALIBS=-lMallocDebug -lsys_s
#
# ---- DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW ALOT ABOUT HOW
# MUDOS WORKS INTERNALLY ----
OVERRIDES=$(MAKEOVERRIDES)
# **************************************************************************
# **** NOTE: If you add something here, also add it to the OBJ= rule below,
# **** or non-GNU makes will die
# **************************************************************************
SRC=grammar.tab.c lex.c main.c rc.c interpret.c simulate.c file.c object.c \
backend.c array.c mapping.c comm.c ed.c regexp.c swap.c buffer.c crc32.c \
malloc.c mallocwrapper.c class.c efuns_main.c efuns_port.c \
call_out.c otable.c dumpstat.c stralloc.c hash.c \
port.c reclaim.c parse.c simul_efun.c sprintf.c program.c \
compiler.c avltree.c icode.c trees.c generate.c scratchpad.c \
socket_efuns.c socket_ctrl.c qsort.c eoperators.c socket_err.c md.c \
disassembler.c binaries.c ualarm.c $(STRFUNCS) \
replace_program.c ccode.c cfuns.c compile_file.c master.c function.c \
debug.c crypt.c applies_table.c add_action.c
all: $(OBJDIR) cc.h files main_build
main_build: $(DRIVER_BIN) addr_server portbind
parallel:
$(MAKE) -k -l -j 6 cc.h files
$(MAKE) -k -l -j 6 main_build
VPATH = $(OBJDIR)
OBJ=$(addprefix $(OBJDIR)/,$(subst .c,.o,$(SRC)))
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) $(OPTIMIZE) -o $@ -c $<
$(OBJDIR)/lex.o: lex.c preprocess.c cc.h grammar.tab.c
$(OBJDIR)/grammar.tab.o: grammar.tab.c opcodes.h
$(OBJDIR):
mkdir -p $(OBJDIR)
which_makefile:
echo MakeIsGNU
grammar.tab.c: grammar.y
$(YACC) grammar.y
-rm -f grammar.tab.*
sed "s/y.tab.c/grammar.tab.c/g" y.tab.c > grammar.tab.c
-mv y.tab.h grammar.tab.h
packages/packages.a: packages/parser.c packages/contrib.c
$(MAKE) -C packages 'CC=$(CC)' 'CFLAGS=$(CFLAGS) $(OPTIMIZE)' 'OBJDIR=../$(OBJDIR)' 'RANLIB=$(RANLIB)' 'A=$(A)' 'O=$(O)'
mudlib/mudlib.a:
$(MAKE) -C mudlib 'CC=$(CC)' 'CFLAGS=$(CFLAGS) $(OPTIMIZE)' 'OBJDIR=../$(OBJDIR)' 'RANLIB=$(RANLIB)' 'A=$(A)' 'O=$(O)'
$(DRIVER_BIN): packages/packages.a mudlib/mudlib.a $(OBJ)
-mv -f $(DRIVER_BIN) $(DRIVER_BIN).old
$(PROOF) $(CC) $(CFLAGS) $(OPTIMIZE) $(OBJ) -o $(DRIVER_BIN) packages/packages.a mudlib/mudlib.a $(EXTRALIBS) `cat system_libs`
addr_server: files $(OBJDIR)/addr_server.o $(OBJDIR)/socket_ctrl.o $(OBJDIR)/port.o addr_server.h
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/socket_ctrl.o $(OBJDIR)/addr_server.o $(OBJDIR)/port.o \
-o addr_server `cat system_libs`
portbind: $(OBJDIR)/portbind.o
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/portbind.o -o portbind `cat system_libs`
remake: neat all
customize:
-cp ../local_options .
-cp ../system_libs .
-cp ../configure.h .
depend: opcodes.h grammar.tab.c cc.h efunctions.h efun_defs.c configure.h
-rm tmpdepend
for i in *.c; do $(CC) -MM -DDEPEND $$i >>tmpdepend; done
sed -e "s!^[^ ]!$(OBJDIR)/&!" <tmpdepend >Dependencies
-rm tmpdepend
cc.h: GNUmakefile
rm -f cc.h
echo "/* this file automatically generated by the Makefile */" > cc.h
echo '#define COMPILER "$(CC)"' >> cc.h
echo '#define OPTIMIZE "$(OPTIMIZE)"' >> cc.h
echo '#define CFLAGS "$(CFLAGS) $(OPTIMIZE)"' >> cc.h
echo '#define OBJDIR "$(OBJDIR)"' >> cc.h
# the touches here are necessary to fix the modification times; link(2) does
# 'modify' a file
files: edit_source sysmalloc.c smalloc.c bsdmalloc.c debugmalloc.c wrappedmalloc.c options.h op_spec.c func_spec.c mudlib/Makefile.pre mudlib/GNUmakefile.pre packages/Makefile.pre packages/GNUmakefile.pre configure.h grammar.y.pre
./edit_source -options -malloc -build_func_spec '$(CPP) $(CFLAGS)' \
-process grammar.y.pre
./edit_source -process packages/Makefile.pre
./edit_source -process packages/GNUmakefile.pre
./edit_source -process mudlib/Makefile.pre
./edit_source -process mudlib/GNUmakefile.pre
./edit_source -build_efuns -build_applies
touch mallocwrapper.c
touch malloc.c
touch files
make_func.tab.c: make_func.y cc.h
$(YACC) $(YFLAGS) make_func.y
-rm -f make_func.tab.c
mv y.tab.c make_func.tab.c
configure.h: edit_source build.MudOS
-if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
rm -f configuration; \
touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
echo "Skipping configuration ..."; \
else \
./edit_source -configure; \
echo "Machine `uname -a` Configure version 5" > configuration; \
fi
$(OBJDIR)/edit_source.o: edit_source.c preprocess.c cc.h
edit_source: $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o
$(CC) $(CFLAGS) $(OBJDIR)/edit_source.o $(OBJDIR)/hash.o $(OBJDIR)/make_func.tab.o -o edit_source
# don't optimize these two
$(OBJDIR)/edit_source.o: edit_source.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJDIR)/make_func.tab.o: make_func.tab.c
$(CC) $(CFLAGS) -o $@ -c $<
tags: $(SRC)
ctags $(SRC)
TAGS: $(SRC)
etags $(SRC)
install: all
-mkdir $(INSTALL_DIR)
$(INSTALL) $(DRIVER_BIN) $(INSTALL_DIR)
$(INSTALL) addr_server $(INSTALL_DIR)
$(INSTALL) portbind $(INSTALL_DIR)
Makefiles: Makefile.in GNUmakefile.in NMakefile.in
Makefile.in: edit_source Makefile.in.pre Makefile.master
./edit_source -process Makefile.in.pre
GNUmakefile.in: edit_source GNUmakefile.in.pre Makefile.master
./edit_source -process GNUmakefile.in.pre
NMakefile.in: edit_source NMakefile.in.pre Makefile.master
./edit_source -process NMakefile.in.pre
nothing:
# remove local configuration
spotless: clean
-rm -f configure.h local_options system_libs configuration
-rm -f options_incl.h
-rm -f *.diffs
-find . -name "*~" -print | xargs rm
# get ready for recompile
neat:
-(cd packages; $(MAKE) "A=$(A)" "O=$(O)" clean)
-(cd mudlib; $(MAKE) "A=$(A)" "O=$(O)" clean)
-rm -rf $(OBJDIR) *.$(O) *.tab.c *.tab.h
-rm -f efun_defs.c option_defs.c
-rm -f opcodes.h efunctions.h opc.h efun_protos.h
-rm -f malloc.c mallocwrapper.c
-rm -f func_spec.cpp applies.h applies_table.c files
-rm -f grammar.y comptest* a.out
-rm -f packages/Makefile packages/GNUmakefile packages/packages
# remove everything except configuration
clean: neat
-rm -f Makefile.MudOS GNUmakefile.MudOS
-rm -f cc.h edit_source
-rm -f core y.output testsuite/core testsuite/tmp/*
-rm -f testsuite/OPCPROF.* testsuite/opc.*
-rm -rf testsuite/binaries testsuite/single/swapfile.*
-rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
-rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
-rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
-find . -name "*~" -print | xargs rm
-find . -name "*.orig" -print | xargs rm
-find . -name "*.rej" -print | xargs rm
-rm -f *.ln tags TAGS
-rm -f $(DRIVER_BIN) $(DRIVER_BIN).old addr_server portbind
-rm -f Dependencies tmpdepend
-touch Dependencies
include Dependencies

16
fluffos-2.23-ds03/INSTALL Normal file
View File

@ -0,0 +1,16 @@
Complete installation instructions are available in major releases
(as opposed to minor releases). The major releases also contain
documentation, etc.
Short instructions:
1) edit options.h to suit your tastes
2) type: ./build.MudOS
3) follow the instructions printed on the screen
4) you will need a runtime config file and a mudlib in order to use the driver.
5) look at the example config file in this directory (Config.example)
6) get a MudOS-compatible mudlib. Note that many mudlibs require certain
setting in options.h, so the documentation of the mudlib should be
consulted. Also, note that many mudlibs come prepackaged with a
version of MudOS they are known to work well with.
7) have fun.

View File

@ -0,0 +1,130 @@
It Crashed!!!
by Beek and Robocoder
***
*** Contents
***
1) Introduction
2) General Notes
3) Unattended operation/automation
4) Debugging core files
5) Notes for SAS/C Amiga users
***
*** Introduction
***
This file documents some methods of obtaining crash information which
the MudOS developers may find useful in tracking down hard to reproduce
crashers (serious bugs).
***
*** General Notes
***
Ok, if your driver crashes, and you want to be helpful, here's what you do:
1. recompile the driver with the -g flag. Turning off optimization
is a good idea too. [This can be done by doing a 'make neat' (or gmake),
reruning ./build.MudOS as follows: './build.MudOS debug', then recompile]
2. go to your bin dir and type 'gdb driver' where driver is the name of your
driver executable
3. It should startup, etc. When it's ready, type 'run config.foo' or
whatever you normally do to run the driver, with 'run' instead of the
driver executable name.
4. Wait for the driver to crash (or cause it to crash, if you know how)
5. gdb should give you a prompt again. type 'where'
6. Post the output of the where command along with anything you know
about where/how/why the driver crashed on the MudOS bug report board.
Stuff like example LPC source code, a tail of driver.err and/or
debug.log, etc may be helpful. In some cases the driver writes important
information to those files as it goes down.
If you actually get a traceback, it makes crashes somewhere between
10-100x easier to fix (at least!). Remember to also specify your
driver version (eg 0.9.19), operating system/architecture, and its
version (eg SunOS 5.3).
Note:
If you didn't use 'gcc', but 'cc' instead (for example), to compile the
driver, you will have to use 'dbx' (if you have it). The same
instructions as above apply...just replace instances of 'gdb' with 'dbx'.
***
*** Unattended operation/automation
***
If you want to automate the process of collecting this crash information,
something you can stick this into your startmud script, read this section.
Begin by creating a batchfile with the following contents:
run config.foo >driver.err
where
Replace 'config.foo' with the name of your config file, and 'driver.err'
with whatever you've set up for redirecting the driver's stderr to.
Where you have 'driver' (or whatever you named the executable) in your
startmud script, use (depending on the compiler used):
gdb -batch -x batchfile driver >report
or:
dbx -i driver <batchfile >report
If/when it crashes, send us a copy of the report.
***
*** Debugging core files
***
This section applies to you, if the driver has crashed, leaving a
core file behind. A large core file is a good sign. =) Some users or
systems may set a resource limit on the size of core files, eg
limit coredumpsize 0
preventing them from debugging from the core file. Remove the limit
or skip this section. HP/Apollo (Domain OS) users may be able to use
'/com/tb' to get traceback information.
Using dbx: Using gdb:
dbx driver core gdb driver core
where where
quit quit
Replace 'driver' with the path of your driver executable.
Another useful command is 'print', which can be used to print the
values of variables in the current function, eg
print str
'dbx' users can also use the 'dump' command to display the names and
variable values in a function, eg
dump main >file
***
*** SAS/C (Amiga)
***
If you are using SAS/C, compile with Debug=Symbol and link with AddSym.
It's a good to turn off optimizations with NoOpt and NoOptPeep.
You can use either 'cpr' or 'tb'. For 'cpr', use:
cpr -line -command "where -a; register" driver config.foo >report
Using 'tb' is a bit more involved. In building the driver, you must:
slink with catch.o or catchnr.o to generate snapshot files
so that if/when the driver crashes, the 'tb' utility can be used to process
the snapshot file. catch.o will ask first before creating a snapshot file,
while catchnr.o will not ask -- if the system is in a bad state, and
catchnr.o is unable to complete writing the snapshot file, the filesystem
can be potentially corrupted. Once you have a 'Snapshot.TB' file, use:
tb -l
to obtain detailed traceback information
--- EOF ---

268
fluffos-2.23-ds03/Ideas Normal file
View File

@ -0,0 +1,268 @@
The current implementation of swapping could use a lot of work. Swapping
an object in/out isn't that expensive CPU wise, and can save a decent amount
of memory. The problem is that cloned programs can't swap, which disables
swapping for much of the mud ...
-Beek
-----
7. It would be more real, if a new call_out happen after all the previous
call_outs of the same delay. (because it were called later)
example: call_out("foo",1);
call_out("bar",1);
now bar will be called first and not foo! It's unreal.
could be possible a call_out with 0 delay ? we would use it for
safe destruct object.
Comment:
Ideally, a better fix would be for call_out to have a smaller
granularity, so the second call_out follows the first by whatever the
time difference between the two was. This problem will always happen
if the call_outs are within the granularity, and real small
granularities (microsecond?) may/may not be desirable.
-----
The names of includes which define no code don't have to be saved for
line number purposes (although they are still needed for binaries; see
the other note about merging the two lists)
-----
Master applies should be cached like sefuns are. Currently, APPLY_*
are string constants so they always miss the call_other cache, making
master applies slow. APPLY_CREATE also always misses the cache, but
it's always going to miss anyway so no problem :-). Others like APPLY_ID
etc should be changed to use shared strings so they can hit.
-----
There should be a NO_HEART_BEATS option
-----
we need to made a single-user option for MudOS that doesn't use sockets
at all so that people wanting to run MudOS at schools where programs
aren't allowed to listen on socket (anti-mud policies) can use MudOS
for developing LPC code for another mud.
--john
-----
From: John Garnett <garnett@gestalt.austin.tx.us>
It'd be cool if there were efuns like this:
mapping x;
attach_mapping(mapping x, string filename);
detach_mapping(x);
which would attach mapping x to the database named by filename.
any accesses to the mapping x would in fact manipulate the database.
This would work much the way attached mappings work in Perl.
We could use the dbm database code in UNIX(tm). Only problem is
not all UNIX's have dbm's that support multiple databases per
UNIX process.
-----
In message <9303080120.AA26940@rock.concert.net> Dank writes:
>powerful. This seems "grossly unfair" to our more serious gamers. That's
>why i need to know the best way to implement (either in the driver or in LPC)
>an hb_call_out() efun, that operates exactly as call_out() does, except that
>it calls its function after a set number of _heartbeats_ have elapsed, not
>after a set number of seconds.
> I ran this by Mobydick, and he thought the solution should be sought from
>you driver folks rather than in the mudlib (course, that may be because
>he's a mudlib coder :)
I agree; it does seem that we need a variant of call_out that operates in terms
of number of heartbeats rather than absolute # of seconds. A few ways
to do this.
// optionally change the way call_out() works so that muds can change it if
// they like.
#define CALL_OUT_UNITS_EQUAL_HEARTBEAT /* or some shorter similar thing */
Or we could make a call_out2() efun that operates in the desired heartbeat units
(name it something more appropriate than call_out2()).
-----
hmm, save_object() should probably somehow save the subtype of numbers.
(ie null, undefined, error, etc)
ucs_brf@pip.shsu.edu
Comment: with some of the optimizations lately, the subtype of numbers is
not always reliable longterm ...
-----
An option for persistent swap files (that the driver can restore/recover
from), saving clones and the contents of variables.
### This seems to be a fad and a bad idea, but I'll get flamed for saying
that ...
-----
mudlib_stats uses a linked list, it is fast for insertion; however
lookup is O(n)...this should be hacked to use an AVL tree (ala uid.c)
-- robo
-----
#pragma no_inherit
#pragma no_clone
-- Cygnus & Descartes
Comment:
Unlike regular C, should these two pragmas should generate warnings
(or error out) if the driver wasn't compiled with this option enabled?
Also, adapt Tensor's idea for uniquep() efun...which queries these
flags, telling whether an object is cloneable and/or inheritable
(or not, depending on your point of view).
These aren't object flags as first believed...they have to be stored
in the program structure, so that it can be restored from binaries.
pragma_no_inherit & pragma_no_clone flags should probably be in
simulate.c, disjoint from those in lex.c.
clone_object()
ob = find_object_no_load()
if (ob->prog->flags & P_NO_CLONE)
error("Illegal object to clone\n");
find_object()
find_object2() <- avoid calling this again (for performance)
load_object()
inheritance: (compiler/grammar & lpc_compiler/grammar)
ob = find_object2()
if (ob->prog->flags & P_NO_INHERIT)
yyerror("Illegal object to inherit\n");
lex.c
init pragma_no_inherit
pragma_no_clone
compiler/grammar & lpc_compiler/grammar
set prog flags
-----
Implement compile stacks so we don't have to dump an object (and later
restart the compile) if an inherited object isn't defined yet.
Note: This would entail requiring the use of bison or pre-yacc'ed grammars
since most versions of yacc parsers aren't reentrant. -Beek
Actually, I take this back. One could make the inherit rule look like:
inheritance: type_modifier_list L_INHERIT string_con1 ';'
{
...
ob = find_object2(file);
if (ob == 0) {
push_compiler_globals();
lex_inherit_hook(file);
} else {
lex_loaded_inherit_hook();
}
}
program terminator
{
... import symbols ...
}
terminator:
L_ALREADY_LOADED
| L_JUST_LOADED
{
pop_compiler_globals();
}
etc ... lex_inherit_hook() cues lex to push it's globals and start a new
file; lex_loaded_inherit_hook() cues lex to just return L_ALREADY_LOADED
as the next token (note: in deep inherits this could require a rather
deep yacc stack)
---
Set up grammar dir for pre-byacc'd and/or pre-bison'd parsers for people
with broken 'yacc's.
Support L_ARRAY_CLOSE, L_FUNCTION_CLOSE, and L_MAPPING_CLOSE for consistency;
L_MAPPING_CLOSE requires a bit more work...
-- robo
-----
Threads :)
-----
Exceptions :)
-----
A make_mapping() efun that obeys the tautology:
make_mapping( keys(m), values(m) ) == m
-----
include_list() efun; also, BINARIES saves a list of includes, but error
line numbers do as well; the former should be modified to use the latter's
list (which was added after binaries were)
-----
maybe:
foreach (i, x in ({ 1, 2 }))
foreach (x in ([ 1 : 2, 3 : 4 ]))
foreach (i, j in ({ 1, 2 }), ({ 3, 4, 5 }))
for parallel walking
---
The handling of || and && is still suboptimal; it tests twice, and does
a uneccessary pop for expressions like: (x && y); it completely blows it
on expressions like 1 || 1 || 1;
---
Profiling shows that a significant amount of CPU is wasted copying stack
values around in the parser due to the large size of %union. In most
cases, only 4 (assuming 32 bit) bytes is needed:
4: /* most stuff */
5: decl
8: func_block
so this is a huge waste. The larger ones could be managed from temporary
pools (they might even have FIFO ordering, but be careful about parse errors)
decl seems unavoidable, but 6 should be possible, cutting the size of
the compile stack and mem that needs to be copied down a bit.
func_block is only used by function pointers anyway, so isn't that common.
There is already a stack for the other function temporary and a depth limit
...
-Beek

View File

@ -0,0 +1,12 @@
all:
@echo MudOS is currently configured to use 'GNUmakefile'. Edit 'build.MudOS'
@echo if this is not what you want.
.DEFAULT:
@echo MudOS is currently configured to use 'GNUmakefile'. Edit 'build.MudOS'
@echo if this is not what you want.
nothing:
which_makefile:
echo MakeIsMake

View File

@ -0,0 +1,243 @@
# YOU DO NOT NEED TO CONFIGURE ANYTHING IN THIS FILE.
#
# RUN THE SHELL SCRIPT ./build.MudOS to generate the Makefiles, and follow
# its instructions.
#
############################################################################
#
# **** TARGETS AND THEIR CORRECT USAGE ****
#
# COMPILATION TARGETS:
#
# all: compile all the files
#
# install: make all, then move the files to the correct directories
#
# remake: remove the object files and generated files, and recompile
# NO reconfiguration is done, etc.
#
# depend: automatically create dependency info
#
# Makefiles: update Makefile.in and GNUmakefile.in from Makefile.master
# (only necessary after making changes to Makefile.master)
#
# 'CLEAN' TARGETS:
#
# neat: remove object files and generated files (used by remake)
#
# clean: in addition to neat, also remove .orig and .rej files,
# cores, lint files, emacs backups, tag files, yacc debug
# files, generated Makefiles, generated binaries, and
# generated dependency info
#
# spotless: make clean, then remove ALL CONFIGURATION AND CUSTOMIZATION
# useful for creating distributions
#
# ---- REALLY COMPLEX OPTIONS YOU PROBABLY DON'T WANT TO TOUCH -----
#
# NeXT: link with MallocDebug if you have a NeXT with NeXTOS 2.1 or later and
# you wish to search for memory leaks (see /NextDeveloper/Apps/MallocDebug).
# Note: linking with MallocDebug will cause the virtual size of the
# driver process to reach appoximately 40MB however the amount of real memory
# used will remain close to normal.
#EXTRALIBS=-lMallocDebug -lsys_s
#
# ---- DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW ALOT ABOUT HOW
# MUDOS WORKS INTERNALLY ----
OVERRIDES=$(MAKEOVERRIDES)
# **************************************************************************
# **** NOTE: If you add something here, also add it to the OBJ= rule below,
# **** or non-GNU makes will die
# **************************************************************************
SRC=grammar.tab.c lex.c main.c rc.c interpret.c simulate.c file.c object.c \
backend.c array.c mapping.c comm.c ed.c regexp.c buffer.c crc32.c \
malloc.c mallocwrapper.c class.c efuns_main.c efuns_port.c \
call_out.c otable.c dumpstat.c stralloc.c hash.c \
port.c reclaim.c parse.c simul_efun.c sprintf.c program.c \
compiler.c avltree.c icode.c trees.c generate.c scratchpad.c \
socket_efuns.c socket_ctrl.c qsort.c eoperators.c socket_err.c md.c \
disassembler.c uvalarm.c $(STRFUNCS) \
replace_program.c master.c function.c \
debug.c crypt.c add_action.c eval.c fliconv.c console.c applies_table.c
all: cc.h files main_build
main_build2: $(DRIVER_BIN) addr_server portbind
main_build: files
$(MAKE) main_build2
parallel:
$(MAKE) -k -l -j 6 cc.h files
$(MAKE) -k -l -j 6 main_build
OBJ=grammar.tab.o lex.o main.o rc.o interpret.o simulate.o file.o object.o \
backend.o array.o mapping.o comm.o ed.o regexp.o buffer.o crc32.o \
malloc.o mallocwrapper.o class.o efuns_main.o efuns_port.o \
call_out.o otable.o dumpstat.o stralloc.o hash.o \
port.o reclaim.o parse.o simul_efun.o sprintf.o program.o \
compiler.o avltree.o icode.o trees.o generate.o scratchpad.o \
socket_efuns.o socket_ctrl.o qsort.o eoperators.o socket_err.o md.o \
disassembler.o uvalarm.o $(STRFUNCS) \
replace_program.o master.o function.o \
debug.o crypt.o add_action.o eval.o fliconv.o console.o applies_table.o
.c.o:
$(CC) $(CFLAGS) $(OPTIMIZE) -c $*.c
# Some OS's can't deal with these being created during the make process?
malloc.o: malloc.c
mallocwrapper.o: mallocwrapper.c
lex.o: lex.c preprocess.c cc.h grammar.tab.c
grammar.tab.o: grammar.tab.c opcodes.h
which_makefile:
echo MakeIsMake
grammar.tab.c: grammar.y
$(YACC) grammar.y
-rm -f grammar.tab.*
sed "s/y.tab.c/grammar.tab.c/g" y.tab.c > grammar.tab.c
-mv y.tab.h grammar.tab.h
packages/packages.a: packages/parser.c packages/contrib.c
(cd packages; $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS) $(OPTIMIZE)' 'RANLIB=$(RANLIB)' 'A=$(A)' 'O=$(O)')
$(DRIVER_BIN): packages/packages.a $(OBJ)
-mv -f $(DRIVER_BIN) $(DRIVER_BIN).old
$(PROOF) $(CC) $(CFLAGS) $(OPTIMIZE) $(OBJ) -o $(DRIVER_BIN) packages/packages.a $(EXTRALIBS) `cat system_libs`
addr_server: files addr_server.o socket_ctrl.o port.o addr_server.h
$(CC) $(CFLAGS) $(OPTIMIZE) socket_ctrl.o addr_server.o port.o \
-o addr_server `cat system_libs`
portbind: portbind.o
$(CC) $(CFLAGS) $(OPTIMIZE) portbind.o -o portbind `cat system_libs`
remake: neat all
customize:
-cp ../local_options .
-cp ../system_libs .
-cp ../configure.h .
depend: opcodes.h grammar.tab.c cc.h efunctions.h efun_defs.c configure.h
makedepend *.c
cc.h: Makefile
rm -f cc.h
echo "/* this file automatically generated by the Makefile */" > cc.h
echo '#define COMPILER "$(CC)"' >> cc.h
echo '#define OPTIMIZE "$(OPTIMIZE)"' >> cc.h
echo '#define CFLAGS "$(CFLAGS) $(OPTIMIZE)"' >> cc.h
echo '#define OBJDIR "$(OBJDIR)"' >> cc.h
# the touches here are necessary to fix the modification times; link(2) does
# 'modify' a file
files: edit_source sysmalloc.c smalloc.c bsdmalloc.c debugmalloc.c wrappedmalloc.c options.h op_spec.c func_spec.c packages/Makefile.pre packages/GNUmakefile.pre configure.h grammar.y.pre
./edit_source -options -malloc -build_func_spec '$(CPP) $(CFLAGS)' \
-process grammar.y.pre
./edit_source -process packages/Makefile.pre
./edit_source -process packages/GNUmakefile.pre
./edit_source -build_efuns -build_applies
touch mallocwrapper.c
touch malloc.c
touch files
make_func.tab.c: make_func.y cc.h
$(YACC) $(YFLAGS) make_func.y
-rm -f make_func.tab.c
mv y.tab.c make_func.tab.c
configure.h: edit_source build.FluffOS
-if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
rm -f configuration; \
touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
echo "Skipping configuration ..."; \
else \
./edit_source -configure; \
echo "Machine `uname -a` Configure version 5" > configuration; \
fi
edit_source.o: edit_source.c preprocess.c cc.h
edit_source: edit_source.o hash.o make_func.tab.o
$(CC) $(CFLAGS) edit_source.o hash.o make_func.tab.o -o edit_source
edit_source.o: edit_source.c
$(CC) $(CFLAGS) -c $*.c
make_func.tab.o: make_func.tab.c
$(CC) $(CFLAGS) -c $*.c
hash.o: hash.c
$(CC) $(CFLAGS) $(OPTIMIZE) -c $*.c
tags: force
ctags *.c *.y
TAGS: force
etags *.c *.y
force:
install: all
-mkdir $(INSTALL_DIR)
$(INSTALL) $(DRIVER_BIN) $(INSTALL_DIR)
$(INSTALL) addr_server $(INSTALL_DIR)
$(INSTALL) portbind $(INSTALL_DIR)
Makefiles: Makefile.in GNUmakefile.in NMakefile.in
Makefile.in: edit_source Makefile.in.pre Makefile.master
./edit_source -process Makefile.in.pre
GNUmakefile.in: edit_source GNUmakefile.in.pre Makefile.master
./edit_source -process GNUmakefile.in.pre
NMakefile.in: edit_source NMakefile.in.pre Makefile.master
./edit_source -process NMakefile.in.pre
nothing:
# remove local configuration
spotless: clean
-rm -f configure.h local_options system_libs configuration
-rm -f options_incl.h
-rm -f *.diffs
-find . -name "*~" -print | xargs rm
# get ready for recompile
neat:
-(cd packages; $(MAKE) "A=$(A)" "O=$(O)" clean)
-rm -rf $(OBJDIR) *.$(O) *.tab.c *.tab.h
-rm -f efun_defs.c option_defs.c
-rm -f opcodes.h efunctions.h opc.h efun_protos.h
-rm -f malloc.c mallocwrapper.c
-rm -f func_spec.cpp applies.h applies_table.c files
-rm -f grammar.y comptest* a.out
-rm -f packages/Makefile packages/GNUmakefile packages/packages
# remove everything except configuration
clean: neat
-rm -f Makefile.MudOS GNUmakefile.MudOS
-rm -f cc.h edit_source
-rm -f core y.output testsuite/core testsuite/tmp/*
-rm -f testsuite/OPCPROF.* testsuite/opc.*
-rm -rf testsuite/binaries testsuite/single/swapfile.*
-rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
-rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
-rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
-find . -name "*~" -print | xargs rm
-find . -name "*.orig" -print | xargs rm
-find . -name "*.rej" -print | xargs rm
-rm -f *.ln tags TAGS
-rm -f $(DRIVER_BIN) $(DRIVER_BIN).old addr_server portbind
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@ -0,0 +1,3 @@
%define NORMAL
%include "Makefile.master"

View File

@ -0,0 +1,266 @@
# YOU DO NOT NEED TO CONFIGURE ANYTHING IN THIS FILE.
#
# RUN THE SHELL SCRIPT ./build.MudOS to generate the Makefiles, and follow
# its instructions.
#
############################################################################
#
# **** TARGETS AND THEIR CORRECT USAGE ****
#
# COMPILATION TARGETS:
#
# all: compile all the files
#
# install: make all, then move the files to the correct directories
#
# remake: remove the object files and generated files, and recompile
# NO reconfiguration is done, etc.
#
# depend: automatically create dependency info
#
# Makefiles: update Makefile.in and GNUmakefile.in from Makefile.master
# (only necessary after making changes to Makefile.master)
#
# 'CLEAN' TARGETS:
#
# neat: remove object files and generated files (used by remake)
#
# clean: in addition to neat, also remove .orig and .rej files,
# cores, lint files, emacs backups, tag files, yacc debug
# files, generated Makefiles, generated binaries, and
# generated dependency info
#
# spotless: make clean, then remove ALL CONFIGURATION AND CUSTOMIZATION
# useful for creating distributions
#
# ---- REALLY COMPLEX OPTIONS YOU PROBABLY DON'T WANT TO TOUCH -----
#
# NeXT: link with MallocDebug if you have a NeXT with NeXTOS 2.1 or later and
# you wish to search for memory leaks (see /NextDeveloper/Apps/MallocDebug).
# Note: linking with MallocDebug will cause the virtual size of the
# driver process to reach appoximately 40MB however the amount of real memory
# used will remain close to normal.
#EXTRALIBS=-lMallocDebug -lsys_s
#
# ---- DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW ALOT ABOUT HOW
# MUDOS WORKS INTERNALLY ----
OVERRIDES=$(MAKEOVERRIDES)
# **************************************************************************
# **** NOTE: If you add something here, also add it to the OBJ= rule below,
# **** or non-GNU makes will die
# **************************************************************************
SRC=grammar$(TAB_EXT).c lex.c main.c rc.c interpret.c simulate.c file.c object.c \
backend.c array.c mapping.c comm.c ed.c regexp.c swap.c buffer.c crc32.c \
malloc.c mallocwrapper.c class.c efuns_main.c efuns_port.c \
call_out.c otable.c dumpstat.c stralloc.c hash.c \
port.c reclaim.c parse.c simul_efun.c sprintf.c program.c \
compiler.c avltree.c icode.c trees.c generate.c scratchpad.c \
socket_efuns.c socket_ctrl.c qsort.c eoperators.c socket_err.c md.c \
disassembler.c binaries.c $(STRFUNCS) \
replace_program.c ccode.c cfuns.c compile_file.c master.c function.c \
debug.c crypt.c applies_table.c add_action.c
all: utils cc.h files main_build
main_build: $(DRIVER_BIN) addr_server
OBJ=$(OBJDIR)\grammar$(TAB_EXT).obj $(OBJDIR)\lex.obj $(OBJDIR)\main.obj $(OBJDIR)\rc.obj $(OBJDIR)\interpret.obj \
$(OBJDIR)\simulate.obj $(OBJDIR)\file.obj $(OBJDIR)\object.obj $(OBJDIR)\backend.obj $(OBJDIR)\array.obj \
$(OBJDIR)\mapping.obj $(OBJDIR)\comm.obj $(OBJDIR)\ed.obj $(OBJDIR)\regexp.obj $(OBJDIR)\swap.obj \
$(OBJDIR)\buffer.obj $(OBJDIR)\crc32.obj $(OBJDIR)\malloc.obj $(OBJDIR)\mallocwrapper.obj \
$(OBJDIR)\class.obj $(OBJDIR)\efuns_main.obj $(OBJDIR)\efuns_port.obj $(OBJDIR)\call_out.obj \
$(OBJDIR)\otable.obj $(OBJDIR)\dumpstat.obj $(OBJDIR)\stralloc.obj $(OBJDIR)\hash.obj $(OBJDIR)\port.obj \
$(OBJDIR)\reclaim.obj $(OBJDIR)\parse.obj $(OBJDIR)\simul_efun.obj $(OBJDIR)\sprintf.obj \
$(OBJDIR)\program.obj $(OBJDIR)\compiler.obj $(OBJDIR)\avltree.obj $(OBJDIR)\icode.obj $(OBJDIR)\trees.obj \
$(OBJDIR)\generate.obj $(OBJDIR)\scratchpad.obj $(OBJDIR)\socket_efuns.obj $(OBJDIR)\socket_ctrl.obj \
$(OBJDIR)\qsort.obj $(OBJDIR)\eoperators.obj $(OBJDIR)\socket_err.obj $(OBJDIR)\md.obj \
$(OBJDIR)\disassembler.obj $(OBJDIR)\binaries.obj $(OBJDIR)\add_action.obj \
$(OBJDIR)\replace_program.obj $(OBJDIR)\ccode.obj $(OBJDIR)\cfuns.obj $(OBJDIR)\compile_file.obj \
$(OBJDIR)\crypt.obj $(OBJDIR)\debug.obj $(OBJDIR)\master.obj $(OBJDIR)\function.obj $(OBJDIR)\applies_table.obj
.c{$(OBJDIR)/}.obj:
$(CC) $(CFLAGS) $(OPTIMIZE) -Fo$(OBJDIR)\ -c $<
$(OBJDIR)/lex.obj: lex.c preprocess.c cc.h grammar$(TAB_EXT).c
$(OBJDIR)/grammar$(TAB_EXT).obj: grammar$(TAB_EXT).c opcodes.h
which_makefile:
echo MakeIsNmake
grammar$(TAB_EXT).c: grammar.y
$(YACC) grammar.y
-rm -f grammar$(TAB_EXT).*
sed "s/y$(TAB_EXT).c/grammar$(TAB_EXT).c/g" y$(TAB_EXT).c > grammar$(TAB_EXT).c
-mv y$(TAB_EXT).h grammar$(TAB_EXT).h
packages/packages.lib: packages/parser.c packages/contrib.c
cd packages
$(MAKE) /nologo "CC=$(CC)" "CFLAGS=$(CFLAGS) $(OPTIMIZE)" "OBJDIR=../$(OBJDIR)" \
"RANLIB=$(RANLIB)" "O=$(O)" "A=$(A)"
cd ..
mudlib/mudlib.lib:
cd mudlib
$(MAKE) /nologo "CC=$(CC)" "CFLAGS=$(CFLAGS) $(OPTIMIZE)" "OBJDIR=../$(OBJDIR)" \
"RANLIB=$(RANLIB)" "O=$(O)" "A=$(A)"
cd ..
$(DRIVER_BIN): $(DRIVER_BIN).exe
$(DRIVER_BIN).exe: packages/packages.lib mudlib/mudlib.lib $(OBJ)
-mv -f $(DRIVER_BIN).exe $(DRIVER_BIN).old
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJ) -Fe$(DRIVER_BIN).exe packages/packages.lib mudlib/mudlib.lib \
$(EXTRALIBS) @system_libs
addr_server: addr_server.exe
addr_server.exe: $(OBJDIR)/addr_server.obj $(OBJDIR)/socket_ctrl.obj $(OBJDIR)/port.obj addr_server.h
$(CC) $(CFLAGS) $(OPTIMIZE) $(OBJDIR)/socket_ctrl.obj $(OBJDIR)/addr_server.obj $(OBJDIR)/port.obj \
-Feaddr_server.exe @system_libs
remake: neat all
customize: cp.bat
-cp ..\local_options .
-cp ..\system_libs .
-cp ..\configure.h .
cc.h: Makefile
rm -f cc.h
echo /* this file automatically generated by the Makefile */ > cc.h
echo #define COMPILER "$(CC)" >> cc.h
echo #define OPTIMIZE "$(OPTIMIZE)" >> cc.h
echo #define CFLAGS "$(CFLAGS) $(OPTIMIZE)" >> cc.h
echo #define OBJDIR "$(OBJDIR)" >> cc.h
# the touches here are necessary to fix the modification times; link(2) does
# 'modify' a file
files: edit_source sysmalloc.c smalloc.c bsdmalloc.c debugmalloc.c wrappedmalloc.c options.h op_spec.c func_spec.c mudlib/Makefile.pre mudlib/GNUmakefile.pre packages/Makefile.pre packages/GNUmakefile.pre configure.h grammar.y.pre
.\edit_source -options -malloc -build_func_spec "$(CPP) $(CFLAGS)" \
-process grammar.y.pre
.\edit_source -process packages/Makefile.pre
.\edit_source -process packages/GNUmakefile.pre
.\edit_source -process mudlib/Makefile.pre
.\edit_source -process mudlib/GNUmakefile.pre
.\edit_source -build_efuns -build_applies
touch mallocwrapper.c
touch malloc.c
touch files
make_func$(TAB_EXT).c: make_func.y cc.h
$(YACC) $(YFLAGS) make_func.y
-rm -f make_func$(TAB_EXT).c
mv y$(TAB_EXT).c make_func$(TAB_EXT).c
configure.h: edit_source.exe build.MudOS
if not exist configure.h rm -f configuration
touch configuration
.\edit_source -configure
build.MudOS: buildMudOS.bat
$(OBJDIR)/crypt.obj: ./amiga/crypt.c
$(CC) $(CFLAGS) $(OPTIMIZE) -Fo$(OBJDIR)\ -c .\amiga\crypt.c
utils: touch.exe mudlib/ar.exe packages/ar.exe mv.bat rm.bat packages/rm.bat mudlib/rm.bat cp.bat
rm.bat: Win32/rm.bat
copy Win32\rm.bat .
packages/rm.bat: Win32/rm.bat
copy Win32\rm.bat packages
mudlib/rm.bat: Win32/rm.bat
copy Win32\rm.bat mudlib
mv.bat: Win32/mv.bat
copy Win32\mv.bat .
cp.bat: Win32/cp.bat
copy Win32\cp.bat .
touch.exe: Win32/touch.c
$(CC) Win32/touch.c
packages/ar.exe: mudlib/ar.exe
copy mudlib\ar.exe packages
mudlib/ar.exe: Win32/ar.c
$(CC) -Femudlib/ Win32/ar.c
$(OBJDIR)/edit_source.obj: edit_source.c preprocess.c cc.h
edit_source: edit_source.exe
edit_source.exe: $(OBJDIR)/edit_source.obj $(OBJDIR)/hash.obj $(OBJDIR)/make_func$(TAB_EXT).obj
$(CC) $(CFLAGS) $(OBJDIR)\edit_source.obj $(OBJDIR)\hash.obj $(OBJDIR)\make_func$(TAB_EXT).obj -Feedit_source.exe
# don't optimize these two
$(OBJDIR)/edit_source.obj: edit_source.c
$(CC) $(CFLAGS) -Fo$(OBJDIR)\ -c edit_source.c
$(OBJDIR)/make_func$(TAB_EXT).obj: make_func$(TAB_EXT).c
$(CC) $(CFLAGS) -Fo$(OBJDIR)\ -c make_func$(TAB_EXT).c
install: all
-mkdir $(INSTALL_DIR)
$(INSTALL) $(DRIVER_BIN).exe $(INSTALL_DIR)
$(INSTALL) addr_server.exe $(INSTALL_DIR)
Makefiles: utils Makefile.in GNUmakefile.in NMakefile.in
Makefile.in: edit_source.exe Makefile.in.pre Makefile.master
.\edit_source -process Makefile.in.pre
GNUmakefile.in: edit_source.exe GNUmakefile.in.pre Makefile.master
.\edit_source -process GNUmakefile.in.pre
NMakefile.in: edit_source.exe NMakefile.in.pre Makefile.master
.\edit_source -process NMakefile.in.pre
nothing:
# remove local configuration
spotless: clean
-rm -f configure.h local_options system_libs configuration
-rm -f options_incl.h
-rm -f *.diffs
-find . -name "*~" -print | xargs rm
-rm -f touch.exe mudlib\ar.exe packages\ar.exe mv.bat packages\rm.bat mudlib\rm.bat cp.bat
del rm.bat
# get ready for recompile
neat: rm.bat packages/rm.bat mudlib/rm.bat
-cd packages
-$(MAKE) /nologo "O=$(O)" "A=$(A)" clean
-cd..
-cd mudlib
-$(MAKE) /nologo "O=$(O)" "A=$(A)" clean
-cd..
-deltree /y $(OBJDIR)
-rm *.obj *$(TAB_EXT).c *$(TAB_EXT).h trash_me.bat *.ilk *.pdb
-rm -f efun_defs.c option_defs.c
-rm -f opcodes.h efunctions.h opc.h efun_protos.h
-rm -f malloc.c mallocwrapper.c
-rm -f func_spec.cpp applies.h applies_table.c files
-rm -f grammar.y comptest* a.out
-rm packages\Makefile packages\GNUmakefile packages\packages
-rm packages\*.pdb mudlib\*.pdb
# remove everything except configuration
clean: neat
-rm -f cc.h edit_source.exe
-rm core y.output testsuite\core testsuite\single\swapfile.*
-rm testsuite\OPCPROF.* testsuite\opc.*
-echo y | del testsuite\tmp\*
-deltree /y testsuite\binaries
-rm testsuite\OBJ_DUMP* testsuite\test_file testsuite\testfile
-rm testsuite\tmp_eval_file.c testsuite\sf.o testsuite\ed_test
-rm testsuite\log\log testsuite\log\debug.log testsuite\log\compile
-rm -f $(DRIVER_BIN).exe $(DRIVER_BIN).old addr_server.exe
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@ -0,0 +1,3 @@
%define NMAKE
%include "Makefile.master"

View File

@ -0,0 +1,53 @@
How to make MudOS run as fast as possible on your machine.
1) use appropriate optimization flags for your compiler. If you are using
gcc 2.3+, then you might want to try the following flags:
-O2 -fomit-frame-pointer -fstrength-reduce
Note that some compilers can produce incorrect code at the higher levels of
optimization. If the driver behaves inexplicably, trying lowering the
optimization level. See the Platforms file for more information on
optimization flags for specific platforms. Also type 'man cc' or ask your
system guru if you are interested in finding out optimization flag information
for your particular compiler.
2) choose an appropriate memory management (malloc) package. Some systems
have very slow system mallocs (like the HP snake on which malloc used 30%
of the CPU time allocated to the MudOS driver (according to gprof) for one
popular mud). Both smalloc and bsdmalloc are much more efficient, typically
using less than 1% of the CPU time allocated to the driver. Note that
smalloc is more space efficient than bsdmalloc (though slightly slower).
3) Try to make your mudlib as memory efficient as possible. Include
clean_up() functions in your objects whenever reasonable and remember
to use map_delete() to remove elements from mappings when those elements
are no longer needed. Also take a look at the reclaim_objects() and
reload_object() efuns for saving memory. Don't use array addition
any more than necessary (especially try not to use it inside a loop
for building arrays).
4) Do _not_ define TRACE_CODE in options.h. TRACE_CODE can be useful
when debugging code but it slows down most simple LPC instructions (in
eval_instruction()) by a factor of two.
5) Don't give objects heartbeats (set_heart_beat(1)) unless really
necessary. Do as little in heart_beat() functions as reasonable.
Consider turning off heartbeats when not needed and then restarting
them when again needed.
6) Read the comments in the example config file about hash table size, and
object hash table size--setting proper (large enough) values for these
two hash tables greatly increases overall speed.
7) The opcprof() efun can be used to find out which efunctions are being used
the most. Rewriting mudlib code that makes extensive use of expensive efuns
can improve performance somewhat. In order to find out which efuns are
expensive, compile the driver with the profiling flags (-pg if using gcc)
and produce a gmon.out file. This file can be processed with the gprof
command to find out the percentage of cpu time spent in various different
driver functions.
8) try using the time_expression(expr) function to measure the cpu time used
by various different expressions (time_expression uses the same syntax as
catch()).

View File

@ -0,0 +1,37 @@
MudOS v22.2 should compile and run on the following systems:
DEC Alpha (OSF/1 1.2)
NeXTstation/NeXTcube (NeXT 2.1 and 3.0, 3.1, 3.2)
RS/6000 (AIX 3.x, 4.x)
Sun3 (SunOS)
Sun4 (SunOS 4.x)
Sun4 (SunOS 5.x)
DECstation 2100/3100/5000 (Ultrix 3.1, 4.x)
VAX (Ultrix)
HP Apollo
HP PA-RISC (HP-UX 7.x, 8.x, 9.0x)
HP 68k Motorola (HP-UX)
HP 68k Motorola (BSD 4.3)
Silicon Graphics Indigo, 4D/x and RS4000 Series (IRIX release 4.0.5F, 5.2, 5.3)
Sequent Symmetry (DYNIX/ptx 1.4, 2.0)
Mac Quadra (A/UX 3.0)
Ridge (RISC/os)
IBM PC (Linux 2.2.x and higher)
IBM PC (System V Release 4)
IBM PC (NetBSD, FreeBSD, 386BSD, etc.)
IBM PC (Windows 95/NT using Visual C++; see the windows/ subdirectory)
Macintosh OS X (Darwin)
*Send mail to marius@mudos.org if you experience any problems
compiling or running on these systems. Note that some of these machines have
old versions of yacc and do require bison (a yacc replacement) to compile
MudOS correctly. If you manage to compile and run MudOS on a system other
than one listed here, please send the diffs along with machine and OS
information to the mudos-bugs address.
NOTE: MudOS is NOT officially supported on Windows 95/98/NT/2K. If you can get
it to work, great. If not, too bad. Official support will be forthcoming in
v23.
MSDOS versions of MudOS are available in the /pub/mud/servers/lpc/mudos/msdos
directory on ftp.ccs.neu.edu.

69
fluffos-2.23-ds03/README Normal file
View File

@ -0,0 +1,69 @@
MudOS is an LPmud server (driver) which was originally distributed as an
enhanced version of the LPmud 3.x driver. It does not support COMPAT mode,
but a number of newer mudlibs are available.
This is the source (src) directory from the MudOS v21.x distribution.
Minor releases of MudOS (those with a minor version number after the decimal,
e.g. v20.26) are typically released without installation
instructions, usage instructions, documentation, or other supporting
material (since the size of this other material is fairly large). Releases
of MudOS with version numbers having only one component (e.g. v21) will
be released as a combined source/documentation package (e.g.
MudOS_v21.tar.Z which is the most recent such release)
The minor releases are intended for those who are already familiar with
installing and running MudOS. These fix bugs in older drivers and introduce
new features.
Alpha and beta versions of future versions are available only in the form
of patches.
Typically, only those interested in testing for bugs or in being on the
bleeding edge need install the alpha/beta releases.
When deciding to upgrade, be sure to read the ChangeLog file in the same
directory as this README to find out about the latest changes to MudOS.
In the case of alpha and beta releases, also check out ChangeLog.alpha
and ChangeLog.beta.
In particular, note the changes marked "compat buster" since these describe
changes to the driver which may cause pre-existing mudlibs (such as Lil)
to break in some minor fashion (the ChangeLog should give enough information
to allow affected mudlibs to be fixed).
Notes:
The official support site for MudOS is http://www.mudos.org/
If you believe that you have found a bug in MudOS that is not listed in the
Bugs file, please visit the support site and check through the existing bugs
in the bug database to see if someone else has reported your bug. If nobody
has reported the bug, please submit a bug report. Please try to include as
much information as you possibly can about the bug. If you can provide
details on how to reproduce the problem, that's the best kind of information
you can give. If the driver has crashed, read the file IT_CRASHED included
in this distribution to find out how to collect information for reporting
your crash.
The 'addr_server' file replaces the old hname program. Unlike hname,
addr_server must be started up manually (it takes a single argument which
is the port # the addr_server should listen on -- this port # must also be
specified in the runtime config file). If addr_server doesn't work on your
machine, its okay to run the driver without it (just set your config file
up to point to someone else's addr_server).
If the driver errors out at runtime with a message saying that the
operation is not supported on the socket, then try using cc instead of gcc
(assuming you were using gcc). Alternatively, try uncommenting
NEED_OLD_CPP in the Makefile and then 'make clean' and 'make'.
For more information about LPmuds and MUDs in general try reading
the USENET groups rec.games.mud.{admin,announce,misc,lp,tiny,diku}.
On subdirectories:
amiga/ Contains amiga support files; a crypt package is also
provided for systems missing DES crypt()
include/ Useful #defines for the mudlib to have access to (used by
various efuns)
packages/ This is where efun packages and user efuns should reside

View File

@ -0,0 +1 @@
MudOS v22.2 beta

View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LEN 1024
int main(int argc, char *argv[]) {
char command[MAX_LEN];
int i;
if (strcmp(argv[1], "rcu"))
return -1;
if (!strstr(argv[2], ".lib"))
return -1;
strcpy(command, "lib ");
for (i = 3; i < argc; i++) {
if (!strstr(argv[i], ".obj"))
return -1;
strcat(command, argv[i]);
strcat(command, " ");
}
strcat(command, "/OUT:");
strcat(command, argv[2]);
system(command);
return 0;
}

View File

@ -0,0 +1,17 @@
#define INCL_STDLIB_H
#define INCL_TIME_H
#define INCL_FCNTL_H
#define INCL_DOS_H
#define INCL_LIMITS_H
#define USE_STRUCT_DIRENT
#define INCL_SYS_STAT_H
#define INCL_STDARG_H
#define HAS_MEMMOVE
#define RAND
#define HAS_STRERROR
#define HAS_GETCWD
#define CONST const
#define INLINE
#define UINT32 unsigned long
#define UINT32 unsigned long

View File

@ -0,0 +1,10 @@
@echo off
:loop
if "%1" == "-f" shift
if "%1" == "." shift
if "%1" == ".." shift
if "%1x" == "x" goto end
copy %1
shift
goto loop
:end

View File

@ -0,0 +1,3 @@
@echo off
if "%1" == "-f" shift
move %1 %2

View File

@ -0,0 +1,8 @@
@echo off
:loop
if "%1x" == "x" goto end
if "%1" == "-f" shift
del %1 >nul
shift
goto loop
:end

View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/utime.h>
int main(int argc, char *argv[]) {
int i, handle;
for (i = 1; i <= argc; i++) {
if (access(argv[i], 0) == -1) {
handle = open(argv[i], _O_RDWR | _O_CREAT, _S_IREAD | _S_IWRITE);
close(handle);
} else {
utime(argv[i], NULL);
}
}
return 0;
}

View File

@ -0,0 +1,758 @@
#include "std.h"
#include "comm.h"
#include "backend.h"
#include "add_action.h"
#include "eval.h"
#ifndef NO_ADD_ACTION
#define MAX_VERB_BUFF 100
object_t * hashed_living[CFG_LIVING_HASH_SIZE] = { 0 };
static int num_living_names;
static int num_searches = 1;
static int search_length = 1;
static int illegal_sentence_action;
static char * last_verb;
static object_t * illegal_sentence_ob;
static void notify_no_command (void)
{
union string_or_func p;
svalue_t *v;
if (!command_giver || !command_giver->interactive)
return;
p = command_giver->interactive->default_err_message;
if (command_giver->interactive->iflags & NOTIFY_FAIL_FUNC) {
save_command_giver(command_giver);
v = call_function_pointer(p.f, 0);
restore_command_giver();
free_funp(p.f);
if (command_giver && command_giver->interactive) {
if (v && v->type == T_STRING) {
tell_object(command_giver, v->u.string, SVALUE_STRLEN(v));
}
command_giver->interactive->iflags &= ~NOTIFY_FAIL_FUNC;
command_giver->interactive->default_err_message.s = 0;
}
} else {
if (p.s) {
tell_object(command_giver, p.s, strlen(p.s));
free_string(p.s);
command_giver->interactive->default_err_message.s = 0;
} else {
tell_object(command_giver, default_fail_message, strlen(default_fail_message));
}
}
}
void clear_notify (object_t * ob)
{
union string_or_func dem;
interactive_t *ip = ob->interactive;
dem = ip->default_err_message;
if (ip->iflags & NOTIFY_FAIL_FUNC) {
free_funp(dem.f);
ip->iflags &= ~NOTIFY_FAIL_FUNC;
}
else if (dem.s)
free_string(dem.s);
ip->default_err_message.s = 0;
}
INLINE_STATIC int hash_living_name (const char *str)
{
return whashstr(str) & (CFG_LIVING_HASH_SIZE - 1);
}
object_t *find_living_object (const char* str, int user)
{
object_t **obp, *tmp;
object_t **hl;
if (!str)
return 0;
num_searches++;
hl = &hashed_living[hash_living_name(str)];
for (obp = hl; *obp; obp = &(*obp)->next_hashed_living) {
search_length++;
#ifdef F_SET_HIDE
if ((*obp)->flags & O_HIDDEN) {
if (!valid_hide(current_object))
continue;
}
#endif
if (user && !((*obp)->flags & O_ONCE_INTERACTIVE))
continue;
if (!((*obp)->flags & O_ENABLE_COMMANDS))
continue;
if (strcmp((*obp)->living_name, str) == 0)
break;
}
if (*obp == 0)
return 0;
/* Move the found ob first. */
if (obp == hl)
return *obp;
tmp = *obp;
*obp = tmp->next_hashed_living;
tmp->next_hashed_living = *hl;
*hl = tmp;
return tmp;
}
void remove_living_name (object_t * ob)
{
object_t **hl;
ob->flags &= ~O_ENABLE_COMMANDS;
if (!ob->living_name)
return;
num_living_names--;
DEBUG_CHECK(!ob->living_name, "remove_living_name: no living name set.\n");
hl = &hashed_living[hash_living_name(ob->living_name)];
while (*hl) {
if (*hl == ob)
break;
hl = &(*hl)->next_hashed_living;
}
DEBUG_CHECK1(*hl == 0,
"remove_living_name: Object named %s no in hash list.\n",
ob->living_name);
*hl = ob->next_hashed_living;
free_string(ob->living_name);
ob->next_hashed_living = 0;
ob->living_name = 0;
}
static void set_living_name (object_t * ob, const char *str)
{
int flags = ob->flags & O_ENABLE_COMMANDS;
object_t **hl;
if (ob->flags & O_DESTRUCTED)
return;
remove_living_name(ob);
num_living_names++;
hl = &hashed_living[hash_living_name(str)];
ob->next_hashed_living = *hl;
*hl = ob;
ob->living_name = make_shared_string(str);
ob->flags |= flags;
}
void stat_living_objects (outbuffer_t * out)
{
outbuf_add(out, "Hash table of living objects:\n");
outbuf_add(out, "-----------------------------\n");
outbuf_addv(out, "%d living named objects, average search length: %4.2f\n\n",
num_living_names, (double) search_length / num_searches);
}
void setup_new_commands (object_t * dest, object_t * item)
{
object_t *next_ob, *ob;
/*
* Setup the new commands. The order is very important, as commands in
* the room should override commands defined by the room. Beware that
* init() in the room may have moved 'item' !
*
* The call of init() should really be done by the object itself (except in
* the -o mode). It might be too slow, though :-(
*/
if (item->flags & O_ENABLE_COMMANDS) {
save_command_giver(item);
(void) apply(APPLY_INIT, dest, 0, ORIGIN_DRIVER);
restore_command_giver();
if (item->super != dest)
return;
}
/*
* Run init of the item once for every present user, and for the
* environment (which can be a user).
*/
for (ob = dest->contains; ob; ob = next_ob) {
next_ob = ob->next_inv;
if (ob == item)
continue;
if (ob->flags & O_DESTRUCTED)
error("An object was destructed at call of " APPLY_INIT "()\n");
if (ob->flags & O_ENABLE_COMMANDS) {
save_command_giver(ob);
(void) apply(APPLY_INIT, item, 0, ORIGIN_DRIVER);
restore_command_giver();
if (dest != item->super)
return;
}
if (item->flags & O_DESTRUCTED) /* marion */
error("The object to be moved was destructed at call of " APPLY_INIT "()\n");
if (ob->flags & O_DESTRUCTED) /* Alaron */
error("An object was destructed at call of " APPLY_INIT "()\n");
if (item->flags & O_ENABLE_COMMANDS) {
save_command_giver(item);
(void) apply(APPLY_INIT, ob, 0, ORIGIN_DRIVER);
restore_command_giver();
if (dest != item->super)
return;
}
}
if (dest->flags & O_DESTRUCTED) /* marion */
error("The destination to move to was destructed at call of " APPLY_INIT "()\n");
if (item->flags & O_DESTRUCTED) /* Alaron */
error("The object to be moved was destructed at call of " APPLY_INIT "()\n");
if (dest->flags & O_ENABLE_COMMANDS) {
save_command_giver(dest);
(void) apply(APPLY_INIT, item, 0, ORIGIN_DRIVER);
restore_command_giver();
}
}
/*
* This will enable an object to use commands normally only
* accessible by interactive users.
* Also check if the user is a wizard. Wizards must not affect the
* value of the wizlist ranking.
*/
static void enable_commands (int num)
{
#ifndef NO_ENVIRONMENT
object_t *pp;
#endif
if (current_object->flags & O_DESTRUCTED)
return;
debug(d_flag, ("Enable commands /%s (ref %d)",
current_object->obname, current_object->ref));
if (num) {
current_object->flags |= O_ENABLE_COMMANDS;
set_command_giver(current_object);
} else {
#ifndef NO_ENVIRONMENT
/* Remove all sentences defined for the object */
if (current_object->flags & O_ENABLE_COMMANDS) {
if (current_object->super) {
remove_sent(current_object->super, current_object);
for (pp = current_object->super->contains; pp; pp = pp->next_inv)
remove_sent(pp, current_object);
}
for (pp = current_object->contains; pp; pp = pp->next_inv)
remove_sent(pp, current_object);
}
#endif
current_object->flags &= ~O_ENABLE_COMMANDS;
if (current_object == command_giver)
set_command_giver(0);
}
}
/*
* Find the sentence for a command from the user.
* Return success status.
*/
static int user_parser (char * buff)
{
char verb_buff[MAX_VERB_BUFF];
sentence_t *s;
char *p;
int length;
char *user_verb = 0;
int where;
int save_illegal_sentence_action;
debug(d_flag, ("cmd [/%s]: %s\n", command_giver->obname, buff));
/* strip trailing spaces. */
for (p = buff + strlen(buff) - 1; p >= buff; p--) {
if (*p != ' ')
break;
*p = '\0';
}
if (buff[0] == '\0')
return 0;
length = p - buff + 1;
p = strchr(buff, ' ');
if (p == 0) {
user_verb = findstring(buff);
} else {
*p = '\0';
user_verb = findstring(buff);
*p = ' ';
length = p - buff;
}
if (!user_verb) {
/* either an xverb or a verb without a specific add_action */
user_verb = buff;
}
/*
* copy user_verb into a static character buffer to be pointed to by
* last_verb.
*/
strncpy(verb_buff, user_verb, MAX_VERB_BUFF - 1);
if (p) {
int pos;
pos = p - buff;
if (pos < MAX_VERB_BUFF) {
verb_buff[pos] = '\0';
}
}
save_illegal_sentence_action = illegal_sentence_action;
illegal_sentence_action = 0;
for (s = command_giver->sent; s; s = s->next) {
svalue_t *ret;
object_t *command_object;
if (s->flags & (V_NOSPACE | V_SHORT)) {
if (strncmp(buff, s->verb, strlen(s->verb)) != 0)
continue;
} else {
/* note: if was add_action(blah, "") then accept it */
if (s->verb[0] && (user_verb != s->verb))
continue;
}
/*
* Now we have found a special sentence !
*/
if (!(s->flags & V_FUNCTION))
debug(d_flag, ("Local command %s on /%s",
s->function.s, s->ob->obname));
if (s->flags & V_NOSPACE) {
int l1 = strlen(s->verb);
int l2 = strlen(verb_buff);
if (l1 < l2)
last_verb = verb_buff + l1;
else
last_verb = "";
} else {
if (!s->verb[0] || (s->flags & V_SHORT))
last_verb = verb_buff;
else
last_verb = s->verb;
}
/*
* If the function is static and not defined by current object, then
* it will fail. If this is called directly from user input, then
* the origin is the driver and it will be allowed.
*/
where = (current_object ? ORIGIN_EFUN : ORIGIN_DRIVER);
/*
* Remember the object, to update moves.
*/
command_object = s->ob;
save_command_giver(command_giver);
if (s->flags & V_NOSPACE) {
copy_and_push_string(&buff[strlen(s->verb)]);
} else if (buff[length] == ' ') {
copy_and_push_string(&buff[length + 1]);
} else {
push_undefined();
}
if (s->flags & V_FUNCTION) {
ret = call_function_pointer(s->function.f, 1);
} else {
if (s->function.s[0] == APPLY___INIT_SPECIAL_CHAR)
error("Illegal function name.\n");
ret = apply(s->function.s, s->ob, 1, where);
}
/* s may be dangling at this point */
restore_command_giver();
last_verb = 0;
/* was this the right verb? */
if (ret == 0) {
/* is it still around? Otherwise, ignore this ...
it moved somewhere or dested itself */
if (s == command_giver->sent) {
char buf[256];
if (s->flags & V_FUNCTION) {
sprintf(buf, "Verb '%s' bound to uncallable function pointer.\n", s->verb);
error(buf);
} else {
sprintf(buf, "Function for verb '%s' not found.\n",
s->verb);
error(buf);
}
}
}
if (ret && (ret->type != T_NUMBER || ret->u.number != 0)) {
#ifdef PACKAGE_MUDLIB_STATS
if (command_giver && command_giver->interactive
#ifndef NO_WIZARDS
&& !(command_giver->flags & O_IS_WIZARD)
#endif
)
add_moves(&command_object->stats, 1);
#endif
if (!illegal_sentence_action)
illegal_sentence_action = save_illegal_sentence_action;
return 1;
}
if (illegal_sentence_action) {
switch (illegal_sentence_action) {
case 1:
error("Illegal to call remove_action() [caller was /%s] from a verb returning zero.\n", illegal_sentence_ob->obname);
case 2:
error("Illegal to move or destruct an object (/%s) defining actions from a verb function which returns zero.\n", illegal_sentence_ob->obname);
}
}
}
notify_no_command();
illegal_sentence_action = save_illegal_sentence_action;
return 0;
}
/*
* Take a user command and parse it.
* The command can also come from a NPC.
* Beware that 'str' can be modified and extended !
*/
int parse_command (char * str, object_t * ob)
{
int res;
/* disallow users to issue commands containing ansi escape codes */
#if defined(NO_ANSI) && !defined(STRIP_BEFORE_PROCESS_INPUT)
char *c;
for (c = str; *c; c++) {
if (*c == 27) {
*c = ' '; /* replace ESC with ' ' */
}
}
#endif
save_command_giver(ob);
res = user_parser(str);
restore_command_giver();
return res;
}
/*
* Associate a command with function in this object.
*
* The optinal third argument is a flag that will state that the verb should
* only match against leading characters.
*
* The object must be near the command giver, so that we ensure that the
* sentence is removed when the command giver leaves.
*
* If the call is from a shadow, make it look like it is really from
* the shadowed object.
*/
static void add_action (svalue_t * str, const char *cmd, int flag)
{
sentence_t *p;
object_t *ob;
if (current_object->flags & O_DESTRUCTED)
return;
ob = current_object;
#ifndef NO_SHADOWS
while (ob->shadowing) {
ob = ob->shadowing;
}
/* don't allow add_actions of a static function from a shadowing object */
if ((ob != current_object) && str->type == T_STRING && is_static(str->u.string, ob)) {
return;
}
#endif
if (command_giver == 0 || (command_giver->flags & O_DESTRUCTED))
return;
if (ob != command_giver
#ifndef NO_ENVIRONMENT
&& ob->super != command_giver &&
ob->super != command_giver->super && ob != command_giver->super
#endif
)
return; /* No need for an error, they know what they
* did wrong. */
p = alloc_sentence();
if (str->type == T_STRING) {
debug(d_flag, ("--Add action %s", str->u.string));
p->function.s = make_shared_string(str->u.string);
p->flags = flag;
} else {
debug(d_flag, ("--Add action <function>"));
p->function.f = str->u.fp;
str->u.fp->hdr.ref++;
p->flags = flag | V_FUNCTION;
}
p->ob = ob;
p->verb = make_shared_string(cmd);
/* This is ok; adding to the top of the list doesn't harm anything */
p->next = command_giver->sent;
command_giver->sent = p;
}
/*
* Remove sentence with specified verb and action. Return 1
* if success. If command_giver, remove his action, otherwise
* remove current_object's action.
*/
static int remove_action (const char *act, const char *verb)
{
object_t *ob;
sentence_t **s;
if (command_giver)
ob = command_giver;
else
ob = current_object;
if (ob) {
for (s = &ob->sent; *s; s = &((*s)->next)) {
sentence_t *tmp;
if (((*s)->ob == current_object) && (!((*s)->flags & V_FUNCTION))
&& !strcmp((*s)->function.s, act)
&& !strcmp((*s)->verb, verb)) {
tmp = *s;
*s = tmp->next;
free_sentence(tmp);
illegal_sentence_action = 1;
illegal_sentence_ob = current_object;
return 1;
}
}
}
return 0;
}
/*
* Remove all commands (sentences) defined by object 'ob' in object
* 'user'
*/
#ifndef NO_ENVIRONMENT
void remove_sent (object_t * ob, object_t * user)
{
sentence_t **s;
if (!(user->flags & O_ENABLE_COMMANDS))
return;
for (s = &user->sent; *s;) {
sentence_t *tmp;
if ((*s)->ob == ob) {
#ifdef DEBUG
if (!((*s)->flags & V_FUNCTION))
debug(d_flag, ("--Unlinking sentence %s\n", (*s)->function.s));
#endif
tmp = *s;
*s = tmp->next;
free_sentence(tmp);
illegal_sentence_action = 2;
illegal_sentence_ob = ob;
} else
s = &((*s)->next);
}
}
#endif
#ifdef F_ADD_ACTION
void
f_add_action (void)
{
long flag;
if (st_num_arg == 3) {
flag = (sp--)->u.number;
} else flag = 0;
if (sp->type == T_ARRAY) {
int i, n = sp->u.arr->size;
svalue_t *sv = sp->u.arr->item;
for (i = 0; i < n; i++) {
if (sv[i].type == T_STRING) {
add_action(sp-1, sv[i].u.string, flag & 3);
}
}
free_array((sp--)->u.arr);
} else {
add_action((sp-1), sp->u.string, flag & 3);
free_string_svalue(sp--);
}
pop_stack();
}
#endif
#ifdef F_COMMAND
/*
* Execute a command for an object. Copy the command into a
* new buffer, because 'parse_command()' can modify the command.
* If the object is not current object, static functions will not
* be executed. This will prevent forcing users to do illegal things.
*
* Return cost of the command executed if success (> 0).
* When failure, return 0.
*/
void f_command (void)
{
long rc = 0;
if (current_object && !(current_object->flags & O_DESTRUCTED))
{
char buff[1000];
int save_eval_cost = get_eval();
if (SVALUE_STRLEN(sp) > sizeof(buff) - 1)
error("Too long command.\n");
strncpy(buff, sp->u.string, sizeof(buff));
buff[sizeof(buff) - 1] = 0;
if (parse_command(buff, current_object))
#ifndef WIN32
rc = save_eval_cost - get_eval();
#else
rc = 1;
#endif
}
free_string_svalue(sp);
put_number(rc);
}
#endif
#ifdef F_COMMANDS
void f_commands (void)
{
push_refed_array(commands(current_object));
}
#endif
#ifdef F_DISABLE_COMMANDS
void f_disable_commands (void)
{
enable_commands(0);
}
#endif
#ifdef F_ENABLE_COMMANDS
void f_enable_commands (void)
{
enable_commands(1);
}
#endif
#ifdef F_FIND_LIVING
void f_find_living (void)
{
object_t *ob;
ob = find_living_object(sp->u.string, 0);
free_string_svalue(sp);
/* safe b/c destructed objects have had their living names removed */
if (ob) {
put_unrefed_undested_object(ob, "find_living");
} else {
*sp = const0;
}
}
#endif
#ifdef F_FIND_PLAYER
void f_find_player (void)
{
object_t *ob;
ob = find_living_object(sp->u.string, 1);
free_string_svalue(sp);
/* safe b/c destructed objects have had their living names removed */
if (ob) {
put_unrefed_undested_object(ob, "find_living");
} else {
*sp = const0;
}
}
#endif
#ifdef F_LIVING
void f_living (void)
{
if (sp->u.ob->flags & O_ENABLE_COMMANDS) {
free_object(&sp->u.ob, "f_living:1");
*sp = const1;
} else {
free_object(&sp->u.ob, "f_living:2");
*sp = const0;
}
}
#endif
#ifdef F_LIVINGS
void f_livings (void)
{
push_refed_array(livings());
}
#endif
#ifdef F_NOTIFY_FAIL
void f_notify_fail (void)
{
if (command_giver && command_giver->interactive) {
clear_notify(command_giver);
if (sp->type == T_STRING) {
command_giver->interactive->default_err_message.s = make_shared_string(sp->u.string);
} else {
command_giver->interactive->iflags |= NOTIFY_FAIL_FUNC;
command_giver->interactive->default_err_message.f = sp->u.fp;
sp->u.fp->hdr.ref++;
}
}
pop_stack();
}
#endif
#ifdef F_QUERY_VERB
void f_query_verb (void)
{
if (!last_verb) {
push_number(0);
return;
}
share_and_push_string(last_verb);
}
#endif
#ifdef F_REMOVE_ACTION
void f_remove_action (void)
{
long success;
success = remove_action((sp - 1)->u.string, sp->u.string);
free_string_svalue(sp--);
free_string_svalue(sp);
put_number(success);
}
#endif
#ifdef F_SET_LIVING_NAME
void f_set_living_name (void)
{
set_living_name(current_object, sp->u.string);
free_string_svalue(sp--);
}
#endif
#endif /* ! NO_ADD_ACTION */

View File

@ -0,0 +1,26 @@
#ifndef ADD_ACTION_H
#define ADD_ACTION_H 1
#ifndef NO_ADD_ACTION
extern object_t *hashed_living[CFG_LIVING_HASH_SIZE];
int parse_command (char *, object_t *);
void clear_notify (object_t *);
void stat_living_objects (outbuffer_t *);
void remove_living_name (object_t *);
object_t * find_living_object (const char *, int);
void setup_new_commands (object_t *, object_t *);
#ifndef NO_ENVIRONMENT
void remove_sent (object_t *, object_t *);
#endif
#else
/* STUBS */
#define parse_command(x, y) do{}while(0)
#define clear_notify(x) do{}while(0)
#define stat_living_objects(x) do{}while(0)
#define remove_living_name(x) do{}while(0)
#define remove_sent(x, y) do{}while(0)
#define setup_new_commands(x, y) do{}while(0)
#endif
#endif /* ADD_ACTION_H */

View File

@ -0,0 +1,682 @@
/*
* addr_server.c -- socket-based ip address server.
* 8-92 : Dwayne Fontenot : original coding
*/
#include "std.h"
#include "addr_server.h"
#include "socket_ctrl.h"
#include "file_incl.h"
#include "port.h"
#ifdef MINGW
#include <ws2tcpip.h>
#endif
#ifdef DEBUG_MACRO
int debug_level = DBG_addr_server;
#endif /* DEBUG_MACRO */
#define DBG(x) debug(addr_server, x)
/*
* private local variables.
*/
static connection all_conns[MAX_CONNS];
static int total_conns = 0;
static queue_element_ptr queue_head = NULL;
static queue_element_ptr queue_tail = NULL;
static queue_element_ptr stack_head = NULL;
static int queue_length = 0;
static int conn_fd;
fd_set readmask;
int name_by_ip (int, char *);
int ip_by_name (int, char *);
INLINE_STATIC void process_queue (void);
void init_conns (void);
void init_conn_sock (int, char *);
#ifdef SIGNAL_FUNC_TAKES_INT
void sigpipe_handler (int);
#else
void sigpipe_handler (void);
#endif
INLINE void aserv_process_io (int);
void enqueue_datapending (int, int);
void handle_top_event (void);
void dequeue_top_event (void);
void pop_queue_element (queue_element_ptr *);
void push_queue_element (queue_element_ptr);
void new_conn_handler (void);
void conn_data_handler (int);
int index_by_fd (int);
void terminate (int);
void debug_perror (const char *, const char *);
void debug_perror (const char * what, const char * file) {
if (file)
fprintf(stderr, "System Error: %s:%s:%s\n", what, file, port_strerror(errno));
else
fprintf(stderr, "System Error: %s:%s\n", what, port_strerror(errno));
}
void init_conns()
{
int i;
for (i = 0; i < MAX_CONNS; i++) {
all_conns[i].fd = -1;
all_conns[i].state = CONN_CLOSED;
all_conns[i].sname[0] = '\0';
/* ensure 'leftover' buffer is _always_ null terminated */
all_conns[i].buf[0] = '\0';
all_conns[i].buf[IN_BUF_SIZE - 1] = '\0';
all_conns[i].leftover = 0;
}
}
/*
* Initialize connection socket.
*/
void init_conn_sock (int port_num, char * ipaddress)
{
#ifdef IPV6
struct sockaddr_in6 sin;
#else
struct sockaddr_in sin;
#endif
socklen_t sin_len;
int optval;
#ifdef WINSOCK
WSADATA WSAData;
WSAStartup(MAKEWORD(1,1), &WSAData);
atexit(cleanup_sockets);
#endif
/*
* create socket of proper type.
*/
#ifdef IPV6
if ((conn_fd = socket(AF_INET6, SOCK_STREAM, 0)) == INVALID_SOCKET) {
#else
if ((conn_fd = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
#endif
socket_perror("init_conn_sock: socket", 0);
exit(1);
}
/*
* enable local address reuse.
*/
optval = 1;
if (setsockopt(conn_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &optval,
sizeof(optval)) == -1) {
socket_perror("init_conn_sock: setsockopt", 0);
exit(2);
}
/*
* fill in socket address information.
*/
#ifdef IPV6
sin.sin6_family = AF_INET6;
if(ipaddress)
inet_pton(AF_INET6, ipaddress, &(sin.sin6_addr));
else
sin.sin6_addr = in6addr_any;
sin.sin6_port = htons((u_short) port_num);
#else
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = (ipaddress ? inet_addr(ipaddress) : INADDR_ANY);
sin.sin_port = htons((u_short) port_num);
#endif
/*
* bind name to socket.
*/
if (bind(conn_fd, (struct sockaddr *) & sin, sizeof(sin)) == -1) {
socket_perror("init_conn_sock: bind", 0);
exit(3);
}
/*
* get socket name.
*/
sin_len = sizeof(sin);
if (getsockname(conn_fd, (struct sockaddr *) & sin, &sin_len) == -1) {
socket_perror("init_conn_sock: getsockname", 0);
exit(4);
}
/*
* register signal handler for SIGPIPE.
*/
#if defined(SIGPIPE) && defined(SIGNAL_ERROR)/* windows has no SIGPIPE */
if (signal(SIGPIPE, sigpipe_handler) == SIGNAL_ERROR) {
socket_perror("init_conn_sock: signal SIGPIPE", 0);
exit(5);
}
#endif
/*
* set socket non-blocking
*/
if (set_socket_nonblocking(conn_fd, 1) == -1) {
socket_perror("init_conn_sock: set_socket_nonblocking 1", 0);
exit(8);
}
/*
* listen on socket for connections.
*/
if (listen(conn_fd, 128) == -1) {
socket_perror("init_conn_sock: listen", 0);
exit(10);
}
DBG(("listening for connections on port %d", port_num));
}
/*
* SIGPIPE handler -- does very little for now.
*/
#ifdef SIGNAL_FUNC_TAKES_INT
void sigpipe_handler (int sig)
{
#else
void sigpipe_handler()
{
#endif
fprintf(stderr, "SIGPIPE received.\n");
}
/*
* I/O handler.
*/
INLINE void aserv_process_io (int nb)
{
int i;
switch (nb) {
case -1:
debug_perror("sigio_handler: select", 0);
break;
case 0:
break;
default:
/*
* check for new connection.
*/
if (FD_ISSET(conn_fd, &readmask)) {
DBG(("sigio_handler: NEW_CONN"));
enqueue_datapending(conn_fd, NEW_CONN);
}
/*
* check for data pending on established connections.
*/
for (i = 0; i < MAX_CONNS; i++) {
if (FD_ISSET(all_conns[i].fd, &readmask)) {
DBG(("sigio_handler: CONN"));
enqueue_datapending(all_conns[i].fd, CONN);
}
}
break;
}
}
INLINE_STATIC void process_queue()
{
int i;
for (i = 0; queue_head && (i < MAX_EVENTS_TO_PROCESS); i++) {
handle_top_event();
dequeue_top_event();
}
}
void enqueue_datapending (int fd, int fd_type)
{
queue_element_ptr new_queue_element;
pop_queue_element(&new_queue_element);
new_queue_element->event_type = fd_type;
new_queue_element->fd = fd;
new_queue_element->next = NULL;
if (queue_head) {
queue_tail->next = new_queue_element;
} else {
queue_head = new_queue_element;
}
queue_tail = new_queue_element;
}
void dequeue_top_event()
{
queue_element_ptr top_queue_element;
if (queue_head) {
top_queue_element = queue_head;
queue_head = queue_head->next;
push_queue_element(top_queue_element);
} else {
fprintf(stderr, "dequeue_top_event: tried to dequeue from empty queue!\n");
}
}
void pop_queue_element (queue_element_ptr * the_queue_element)
{
if ((*the_queue_element = stack_head))
stack_head = stack_head->next;
else
*the_queue_element = (queue_element_ptr) malloc(sizeof(queue_element));
queue_length++;
}
void push_queue_element (queue_element_ptr the_queue_element)
{
the_queue_element->next = stack_head;
stack_head = the_queue_element;
queue_length--;
}
void handle_top_event()
{
switch (queue_head->event_type) {
case NEW_CONN:
DBG(("handle_top_event: NEW_CONN"));
new_conn_handler();
break;
case CONN:
DBG(("handle_top_event: CONN data on fd %d", queue_head->fd));
conn_data_handler(queue_head->fd);
break;
default:
fprintf(stderr, "handle_top_event: unknown event type %d\n",
queue_head->event_type);
break;
}
}
/*
* This is the new connection handler. This function is called by the
* event handler when data is pending on the listening socket (conn_fd).
* If space is available, an interactive data structure is initialized and
* the connected is established.
*/
void new_conn_handler()
{
#ifdef IPV6
struct sockaddr_in6 client;
#else
struct sockaddr_in client;
#endif
socklen_t client_len;
struct hostent *c_hostent;
int new_fd;
int conn_index;
client_len = sizeof(client);
new_fd = accept(conn_fd, (struct sockaddr *) & client, &client_len);
if (new_fd == -1) {
socket_perror("new_conn_handler: accept", 0);
return;
}
if (set_socket_nonblocking(new_fd, 1) == -1) {
socket_perror("new_conn_handler: set_socket_nonblocking 1", 0);
OS_socket_close(new_fd);
return;
}
if (total_conns >= MAX_CONNS) {
char *message = "no available slots -- closing connection.\n";
fprintf(stderr, "new_conn_handler: no available connection slots.\n");
OS_socket_write(new_fd, message, strlen(message));
if (OS_socket_close(new_fd) == -1)
socket_perror("new_conn_handler: close", 0);
return;
}
/* get some information about new connection */
for (conn_index = 0; conn_index < MAX_CONNS; conn_index++) {
if (all_conns[conn_index].state == CONN_CLOSED) {
DBG(("new_conn_handler: opening conn index %d", conn_index));
/* update global data for new fd */
all_conns[conn_index].fd = new_fd;
all_conns[conn_index].state = CONN_OPEN;
all_conns[conn_index].addr = client;
char portname[256];
if(getnameinfo((struct sockaddr *)&client, sizeof(client), all_conns[conn_index].sname, SNAME_LEN, portname, 255, NI_NAMEREQD|NI_NUMERICHOST))
strcpy(all_conns[conn_index].sname, "<unknown>");
total_conns++;
return;
}
}
fprintf(stderr, "new_conn_handler: sanity check failed!\n");
}
void conn_data_handler (int fd)
{
int conn_index;
int buf_index;
int num_bytes;
int msgtype;
int leftover;
char *buf;
int res, msglen, expecting;
long unread_bytes;
if ((conn_index = index_by_fd(fd)) == -1) {
fprintf(stderr, "conn_data_handler: invalid fd.\n");
return;
}
DBG(("conn_data_handler: read on fd %d", fd));
/* append new data to end of leftover data (if any) */
leftover = all_conns[conn_index].leftover;
buf = (char *) &all_conns[conn_index].buf[0];
num_bytes = OS_socket_read(fd, buf + leftover, (IN_BUF_SIZE - 1) - leftover);
switch (num_bytes) {
case -1:
switch (socket_errno) {
case EWOULDBLOCK:
DBG(("conn_data_handler: read on fd %d: Operation would block.",
fd));
break;
default:
socket_perror("conn_data_handler: read", 0);
terminate(conn_index);
break;
}
break;
case 0:
if (all_conns[conn_index].state == CONN_CLOSED)
fprintf(stderr, "get_user_data: tried to read from closed fd.\n");
terminate(conn_index);
break;
default:
DBG(("conn_data_handler: read %d bytes on fd %d", num_bytes, fd));
num_bytes += leftover;
buf_index = 0;
expecting = 0;
while (num_bytes > sizeof(int) && buf_index < (IN_BUF_SIZE - 1)) {
/* get message type */
memcpy((char *) &msgtype, (char *) &buf[buf_index], sizeof(int));
DBG(("conn_data_handler: message type: %d", msgtype));
if (msgtype == NAMEBYIP) {
if (buf[buf_index + sizeof(int)] == '\0') {
/* no data here...resync */
buf_index++;
num_bytes--;
continue;
}
if (expecting && num_bytes < expecting) {
/*
* message truncated...back up to DATALEN message; exit
* loop...and try again later
*/
buf_index -= (sizeof(int) + sizeof(int));
num_bytes += (sizeof(int) + sizeof(int));
break;
}
res = name_by_ip(conn_index, &buf[buf_index]);
} else if (msgtype == IPBYNAME) {
if (buf[buf_index + sizeof(int)] == '\0') {
/* no data here...resync */
buf_index++;
num_bytes--;
continue;
}
if (expecting && num_bytes < expecting) {
/*
* message truncated...back up to DATALEN message; exit
* loop...and try again later
*/
buf_index -= (sizeof(int) + sizeof(int));
num_bytes += (sizeof(int) + sizeof(int));
break;
}
res = ip_by_name(conn_index, &buf[buf_index]);
} else if (msgtype == DATALEN) {
if (num_bytes > (sizeof(int) + sizeof(int))) {
memcpy((char *) &expecting, (char *) &buf[buf_index + sizeof(int)], sizeof(int));
/*
* advance to next message
*/
buf_index += (sizeof(int) + sizeof(int));
num_bytes -= (sizeof(int) + sizeof(int));
if (expecting > IN_BUF_SIZE || expecting <= 0) {
fprintf(stderr, "conn_data_handler: bad data length %d\n", expecting);
expecting = 0;
}
continue;
} else {
/*
* not enough bytes...assume truncated; exit loop...we'll
* handle this message later
*/
break;
}
} else {
fprintf(stderr, "conn_data_handler: unknown message type %08x\n", msgtype);
/* advance through buffer */
buf_index++;
num_bytes--;
continue;
}
msglen = (int) (sizeof(int) + strlen(&buf[buf_index + sizeof(int)]) +1);
if (res) {
/*
* ok...advance to next message
*/
buf_index += msglen;
num_bytes -= msglen;
} else if (msglen < num_bytes || (expecting && expecting == msglen)) {
/*
* failed...
*/
/*
* this was a complete message...advance to the next one
*/
msglen = (int) (sizeof(int) + strlen(&buf[buf_index + sizeof(int)]) +1);
buf_index += msglen;
num_bytes -= msglen;
expecting = 0;
}
else if (!OS_socket_ioctl(fd, FIONREAD, &unread_bytes) &&
unread_bytes > 0) {
/*
* msglen == num_bytes could be a complete message... if
* there's unread data we'll assume it was truncated
*/
break;
} else {
/*
* nothing more? then discard message (it was the last one)
*/
buf_index = 0;
num_bytes = 0;
break;
}
}
/* keep track of leftover buffer contents */
if (num_bytes && buf_index)
memmove(buf, &buf[buf_index], num_bytes);
buf[num_bytes] = '\0';
all_conns[conn_index].leftover = num_bytes;
break;
}
}
#define OUT_BUF_SIZE 80
int ip_by_name (int conn_index, char * buf)
{
struct hostent *hp;
struct in_addr my_in_addr;
static char out_buf[OUT_BUF_SIZE];
hp = gethostbyname(&buf[sizeof(int)]);
if (hp == NULL) {
/* Failed :( */
sprintf(out_buf, "%s 0\n", &buf[sizeof(int)]);
DBG(("%s", out_buf));
OS_socket_write(all_conns[conn_index].fd, out_buf, strlen(out_buf));
return 0;
} else {
/* Success! */
memcpy(&my_in_addr, hp->h_addr, sizeof(struct in_addr));
sprintf(out_buf, "%s %s\n", &buf[sizeof(int)],
inet_ntoa(my_in_addr));
DBG(("%s", out_buf));
OS_socket_write(all_conns[conn_index].fd, out_buf, strlen(out_buf));
return 1;
}
} /* ip_by_name() */
int name_by_ip (int conn_index, char * buf)
{
struct addrinfo hints, *res;
int ret;
hints.ai_family = AF_INET6;
hints.ai_socktype = 0;
hints.ai_protocol = 0;
#if defined(AI_V4MAPPED)
hints.ai_flags = AI_CANONNAME| AI_V4MAPPED;
#else
hints.ai_flags = AI_CANONNAME;
#endif
static char out_buf[OUT_BUF_SIZE];
if((ret = getaddrinfo(&buf[sizeof(int)], NULL, &hints, &res))){
//failed
sprintf(out_buf, "%s 0\n", &buf[sizeof(int)]);
DBG(("name_by_ip: malformed address request (%d).", ret));
OS_socket_write(all_conns[conn_index].fd, out_buf, strlen(out_buf));
return 0;
}
char tmpbuf[80], tmpp[80];
if(ret = getnameinfo(res->ai_addr, res->ai_addrlen, tmpbuf, 79, tmpp, 79, NI_NAMEREQD|NI_NUMERICSERV)){
sprintf(out_buf, "%s 0\n", &buf[sizeof(int)]);
DBG(("%s", out_buf));
OS_socket_write(all_conns[conn_index].fd, out_buf, strlen(out_buf));
DBG(("name_by_ip: unable to resolve address."));
freeaddrinfo(res);
return 0;
}
sprintf(out_buf, "%s %s\n", &buf[sizeof(int)], tmpbuf);
DBG(("%s", out_buf));
OS_socket_write(all_conns[conn_index].fd, out_buf, strlen(out_buf));
freeaddrinfo(res);
return 1;
}
int index_by_fd (int fd)
{
int i;
for (i = 0; i < MAX_CONNS; i++) {
if ((all_conns[i].state == CONN_OPEN) && (all_conns[i].fd == fd))
return (i);
}
return (-1);
}
void terminate (int conn_index)
{
if (conn_index < 0 || conn_index >= MAX_CONNS) {
fprintf(stderr, "terminate: conn_index %d out of range.\n", conn_index);
return;
}
if (all_conns[conn_index].state == CONN_CLOSED) {
fprintf(stderr, "terminate: connection %d already closed.\n", conn_index);
return;
}
DBG(("terminating connection %d", conn_index));
if (OS_socket_close(all_conns[conn_index].fd) == -1) {
socket_perror("terminate: close", 0);
return;
}
all_conns[conn_index].state = CONN_CLOSED;
total_conns--;
}
int main (int argc, char ** argv)
{
int addr_server_port;
struct timeval timeout;
int i;
int nb;
char *ipaddress = 0;
if (argc > 1) {
if ((addr_server_port = atoi(argv[1])) == 0) {
fprintf(stderr, "addr_server: malformed port number.\n");
exit(2);
}
if (argc > 2) {
if (inet_addr((ipaddress = argv[2])) == INADDR_NONE) {
fprintf(stderr, "addr_server: malformed ip address.\n");
exit(3);
}
}
} else {
fprintf(stderr, "addr_server: first arg must be port number.\n");
exit(1);
}
init_conn_sock(addr_server_port, ipaddress);
while (1) {
/*
* use finite timeout for robustness.
*/
timeout.tv_sec = 2;
timeout.tv_usec = 0;
/*
* clear selectmasks.
*/
FD_ZERO(&readmask);
/*
* set new connection accept fd in readmask.
*/
FD_SET(conn_fd, &readmask);
/*
* set active fds in readmask.
*/
for (i = 0; i < MAX_CONNS; i++) {
if (all_conns[i].state == CONN_OPEN)
FD_SET(all_conns[i].fd, &readmask);
}
#ifndef hpux
nb = select(FD_SETSIZE, &readmask, (fd_set *) 0, (fd_set *) 0, &timeout);
#else
nb = select(FD_SETSIZE, (int *) &readmask, (int *) 0, (int *) 0, &timeout);
#endif
if (nb != 0)
aserv_process_io(nb);
process_queue();
}
/* the following is to shut lint up */
/*NOTREACHED*/
return 0; /* never reached */
}
#ifdef WIN32
void debug_message(char *fmt, ...)
{
static char deb_buf[1024];
static char *deb = deb_buf;
va_list args;
V_START(args, fmt);
V_VAR(char *, fmt, args);
vfprintf(stderr, fmt, args);
fflush(stderr);
va_end(args);
}
#endif

View File

@ -0,0 +1,53 @@
/*
* addr_server.h -- definitions and prototypes for addr_server.c
* 8-92 : Dwayne Fontenot : original coding.
*/
#ifndef ADDR_SERVER_H
#define ADDR_SERVER_H
#include "network_incl.h"
#define DFAULT_PROTO 0 /* use the appropriate protocol */
#define MAX_CONNS 4 /* max number of connections */
#define SNAME_LEN 64 /* length of symbolic name string */
#define MAX_EVENTS_IN_QUEUE 100
#define MAX_EVENTS_TO_PROCESS 100
#define IN_BUF_SIZE 100
enum conn_states {
CONN_CLOSED, CONN_OPEN
};
enum ev_type {
NEW_CONN, CONN
};
enum msgtypes {
NAMEBYIP = 0, IPBYNAME, DATALEN
};
typedef struct conn *conn_ptr;
typedef struct conn {
int fd; /* file descriptor */
int state; /* connection state */
#ifndef IPV6
struct sockaddr_in addr; /* address struct for connected */
#else
struct sockaddr_in6 addr;
#endif
char sname[SNAME_LEN]; /* symbolic name of connected host */
int leftover; /* unprocessed bytes in data queue */
char buf[IN_BUF_SIZE];
} connection;
typedef struct queue_elem *queue_element_ptr;
typedef struct queue_elem {
short event_type; /* event type */
int fd; /* file descriptor on which data is pending */
queue_element_ptr next;
} queue_element;
#endif /* _ADDR_SERVER_H_ */

74
fluffos-2.23-ds03/applies Normal file
View File

@ -0,0 +1,74 @@
__INIT:#global_init#
ADJECTIVE:parse_command_adjectiv_id_list
CATCH_TELL
CLEAN_UP
CREATE
DESTRUCTOR
ID
INIT
LOGON
MOVE:move_or_destruct
NET_DEAD
NOUN:parse_command_id_list
PLURAL:parse_command_plural_id_list
PROCESS_INPUT
QGET_ADJID:parse_command_adjective_id_list
QGET_ID:parse_command_id_list
QGET_PLURID:parse_command_plural_id_list
RECEIVE_MESSAGE
RECEIVE_SNOOP
RECEIVE_ED
RESET
TELNET_SUBOPTION
TERMINAL_TYPE
TERMINAL_COLOUR_REPLACE
WINDOW_SIZE
WRITE_PROMPT
MXP_ENABLE
MXP_TAG
ZMP:zmp_command
GMCP_ENABLE
GMCP
RECEIVE_ENVIRON
# master applies
AUTHOR_FILE
COMPILE_OBJECT
CONNECT
CRASH
CREATOR_FILE
DOMAIN_FILE
EPILOG
ERROR_HANDLER
GET_BACKBONE_UID:get_bb_uid
GET_ED_BUFFER_SAVE_FILE_NAME:get_save_file_name
GET_ROOT_UID
LOG_ERROR
MAKE_PATH_ABSOLUTE
FLAG
OBJECT_NAME
PARSER_ERROR_MESSAGE
PRELOAD
PRIVS_FILE
RETRIEVE_ED_SETUP
SAVE_ED_SETUP
SLOW_SHUTDOWN
USERS:parse_command_users
VALID_ASM
VALID_BIND
VALID_DATABASE
VALID_HIDE
VALID_LINK
LITERALS:parse_command_prepos_list
VALID_OBJECT
VALID_OVERRIDE
QGET_ALLWORD:parse_command_all_word
QGET_PREPOS:parse_command_prepos_list
VALID_READ
VALID_SETEUID
VALID_SHADOW
VALID_SOCKET
VALID_WRITE
PARSE_FIRST_INVENTORY:parse_get_first_inventory
PARSE_NEXT_INVENTORY:parse_get_next_inventory
PARSE_ENVIRONMENT:parse_get_environment
GET_MUD_STATS

159
fluffos-2.23-ds03/arch.h Normal file
View File

@ -0,0 +1,159 @@
/* arch.h: __ARCH__ - a predefined macro exported to all LPC objects */
#ifndef _ARCH_H_
#define _ARCH_H_
#ifdef sequent
#define ARCH "Sequent DYNIX"
#endif
/*
* Note - Cygwin runs under windows and automatically
* defines a number of windows related things. These
* must be undef'd so that the 'normal' windows port code
* in MudOS is not used.
*/
#ifdef __CYGWIN__
#undef WINNT
#undef WIN95
#undef WIN98
#undef WINSOCK
#undef WIN32
#define ARCH "Cygwin-32"
#endif
#ifdef WINNT
#define ARCH "Microsoft Windows NT"
#endif
#ifdef WIN95
#define ARCH "Microsoft Windows 95"
#endif
#ifdef _SEQUENT_
#define ARCH "Sequent DYNIX/ptx"
#endif
#ifdef __FreeBSD__
#define ARCH "FreeBSD"
#endif
#ifdef __NetBSD__
#ifdef sparc
#define ARCH "NetBSD/sparc"
#else
#define ARCH "NetBSD"
#endif
#endif
#ifdef NeXT
#ifdef m68k
#define ARCH "NeXT/68k"
#else
#define ARCH "NeXT"
#endif
#endif
#ifdef _AIX
#define ARCH "AIX"
#endif
#ifdef accel
#define ARCH "Accel"
#endif
/* Attempt to guess whether we are running Solaris or not */
#if defined(sun) && !defined(SunOS_5)
# if defined(__svr4__) || defined(__sol__) || defined(SVR4)
# define SunOS_5
# else
# ifdef sun4
# define ARCH "Sun4"
# else
# ifdef sun3
# define ARCH "Sun3"
# else
# define ARCH "Sun"
# endif
# endif
# endif
#endif
#if defined(SunOS_5)
# ifdef sparc
# define ARCH "Solaris SPARC"
# else
# define ARCH "Solaris x86"
# endif
#endif
#ifdef _AUX_SOURCE
#define ARCH "A/UX"
#endif
#ifdef linux
# ifdef __mc68000
# define ARCH "Linux/m68k"
# else
# ifdef __alpha
# define ARCH "Linux/alpha"
# else
# define ARCH "Linux"
# endif
# endif
#endif
#ifdef hp68k
#define ARCH "HP/68k"
#endif
#ifdef hppa
#define ARCH "HP/PA-RISC"
#endif
#ifdef cray
#define ARCH "Cray"
#endif
#if !defined(ARCH) && defined(__alpha)
#define ARCH "Alpha"
#endif
#if !defined(ARCH) && defined(__bsdi__)
#define ARCH "BSDI"
#endif
#if !defined(ARCH) && defined(__386BSD__)
#define ARCH "386bsd"
#endif
#if !defined(ARCH) && defined(ultrix)
#define ARCH "Ultrix"
#endif
#if !defined(ARCH) && defined(hpux)
#define ARCH "HP/UX"
#endif
#if !defined(ARCH) && defined(sgi)
#define ARCH "IRIX"
#endif
#if (!defined(ARCH) && defined(SVR4))
#define ARCH "SVR4"
#endif
#if !defined(ARCH) && defined(OSF)
#define ARCH "OSF/1"
#endif
#if !defined(ARCH) && defined(__APPLE__) && defined(__GNUC__)
#define ARCH "Mac OS X"
#endif
#ifndef ARCH
#define ARCH "unknown architecture"
#endif
#endif

2344
fluffos-2.23-ds03/array.c Normal file

File diff suppressed because it is too large Load Diff

76
fluffos-2.23-ds03/array.h Normal file
View File

@ -0,0 +1,76 @@
#ifndef ARRAY_H
#define ARRAY_H
/* It is usually better to include "lpc_incl.h" instead of including this
directly */
typedef struct array_s {
unsigned short ref;
#ifdef DEBUG
int extra_ref;
#endif
int size;
#ifdef PACKAGE_MUDLIB_STATS
statgroup_t stats; /* creator of the array */
#endif
svalue_t item[1];
} array_t;
extern array_t the_null_array;
/*
* array.c
*/
#ifdef ARRAY_STATS
extern int num_arrays;
extern int total_array_size;
#endif
int sameval (svalue_t *, svalue_t *);
array_t *allocate_array2 (int, svalue_t *);
array_t *allocate_array (int);
array_t *allocate_empty_array (int);
void free_array (array_t *);
void free_empty_array (array_t *);
array_t *add_array (array_t *, array_t *);
void implode_array (funptr_t *, array_t *, svalue_t *, int);
array_t *subtract_array (array_t *, array_t *);
array_t *slice_array (array_t *, int, int);
array_t *explode_string (const char *, int, const char *, int);
char *implode_string (array_t *, const char *, int);
array_t *users (void);
array_t *commands (object_t *);
void filter_array (svalue_t *, int);
void filter_string (svalue_t *, int);
array_t *deep_inherit_list (object_t *);
array_t *inherit_list (object_t *);
array_t *children (const char *);
array_t *livings (void);
array_t *objects (funptr_t *);
array_t *all_inventory (object_t *, int);
array_t *deep_inventory (object_t *, int, funptr_t *);
array_t *deep_inventory_array (array_t *, int, funptr_t *);
array_t *filter (array_t *, funptr_t *, svalue_t *);
array_t *builtin_sort_array (array_t *, int);
array_t *fp_sort_array (array_t *, funptr_t *);
array_t *sort_array (array_t *, char *, object_t *);
array_t *make_unique (array_t *, char *, funptr_t *, svalue_t *);
void map_string (svalue_t *arg, int num_arg);
void map_array (svalue_t *arg, int num_arg);
array_t *intersect_array (array_t *, array_t *);
int match_single_regexp (const char *, const char *);
array_t *match_regexp (array_t *, const char *, int);
array_t *reg_assoc (svalue_t *, array_t *, array_t *, svalue_t *);
void dealloc_array (array_t *);
array_t *union_array (array_t *, array_t *);
array_t *copy_array (array_t * p);
array_t *resize_array (array_t * p, unsigned int n);
#define ALLOC_ARRAY(nelem) \
(array_t *)DXALLOC(sizeof (array_t) + \
sizeof(svalue_t) * (nelem - 1), TAG_ARRAY, "ALLOC_ARRAY")
#define RESIZE_ARRAY(vec, nelem) \
(array_t *)DREALLOC(vec, sizeof (array_t) + \
sizeof(svalue_t) * (nelem - 1), TAG_ARRAY, "RESIZE_ARRAY")
#endif

414
fluffos-2.23-ds03/avltree.c Normal file
View File

@ -0,0 +1,414 @@
/*
* avltree.c
*
* This program text was created by Paul Vixie using examples from the book:
* "Algorithms & Data Structures," Niklaus Wirth, Prentice-Hall, 1986, ISBN
* 0-13-022005-1. This code and associated documentation is hereby placed
* in the public domain.
*/
/********************************* README *********************************
AVL Trees V1.0
24-July-1987
Paul Vixie
This library and test program are useful for creating and using balanced
binary trees (AVL trees). The tree is held in memory, using malloc(3) to
allocate storage. A better version would allow file-based trees in
addition; once memory mapped files hit the UNIX(tm) community, this will
be much easier to do. In the meanwhile, these routines have been very
useful to be for symbol tables and the like. (Yes, I'm sure hashing is
better in some way, but I've used this for symbol tables, just the same.)
I cannot take credit for the algorithms. See "Algorithms & Data Structures,"
Niklaus Wirth, Prentice-Hall 1986, ISBN 0-13-022005-1. This is an update of
Wirth's previous book, titled "Algorythms + Data Structures = Programs,"
which used Pascal as the language for examples. This later book uses the
newer Modula-2 for it's examples; this tree code was created using the
Modula-2 examples as guidelines. At the time I typed this stuff in (about
a year ago, in July 1987), I understood how it all worked. Today, well...
This code is hereby placed in the public domain, unless restrictions apply
from Prentice-Hall on the algorithms themselves. If you use or redistribute
this code, please leave my name (and Wirth's) in the comments.
**************************************************************************/
#include "std.h"
#include "avltree.h"
/*
* Prototypes for local functions
*/
static void sprout (tree **, char *, int *, int (*) (void *, void *), int (*) (void *));
static int avldelete (tree **, int (*) (void *, void *), char *, int (*) (void *), int *, int *);
static void del (tree **, int *, tree **, int (*) (void *), int *);
static void balanceL (tree **, int *);
static void balanceR (tree **, int *);
void tree_init (tree ** ppr_tree)
{
*ppr_tree = NULL;
return;
}
char *tree_srch(tree *ppr_tree, int (*pfi_compare) (void *, void *), char *pc_user){
register int i_comp;
while (ppr_tree) {
i_comp = (*pfi_compare) (pc_user, ppr_tree->tree_p);
if (i_comp > 0) {
ppr_tree = ppr_tree->tree_r;
continue;
}
if (i_comp < 0) {
ppr_tree = ppr_tree->tree_l;
continue;
}
/*
* not higher, not lower... this must be the one.
*/
return ppr_tree->tree_p;
}
/*
* grounded. NOT found.
*/
return NULL;
}
void tree_add(tree **ppr_tree, int (*pfi_compare) (void *, void *), char *pc_user, int (*pfi_delete) (void *)){
int i_balance = 0;
sprout(ppr_tree, pc_user, &i_balance, pfi_compare, pfi_delete);
return;
}
static void sprout(tree **ppr, char *pc_data, int *pi_balance, int (*pfi_compare) (void *, void *), int (*pfi_delete) (void *)){
tree *p1, *p2;
int cmp;
/*
* are we grounded? if so, add the node "here" and set the rebalance
* flag, then exit.
*/
if (!*ppr) {
*ppr = ALLOCATE(tree, TAG_UID, "sprout");
(*ppr)->tree_l = NULL;
(*ppr)->tree_r = NULL;
(*ppr)->tree_b = 0;
(*ppr)->tree_p = pc_data;
*pi_balance = 1;
return;
}
/*
* compare the data using routine passed by caller.
*/
cmp = (*pfi_compare) (pc_data, (*ppr)->tree_p);
/*
* if LESS, prepare to move to the left.
*/
if (cmp < 0) {
sprout(&(*ppr)->tree_l, pc_data, pi_balance,
pfi_compare, pfi_delete);
if (*pi_balance) { /* left branch has grown longer */
switch ((*ppr)->tree_b) {
case 1: /* right branch WAS longer; balance is ok now */
(*ppr)->tree_b = 0;
*pi_balance = 0;
break;
case 0: /* balance WAS okay; now left branch longer */
(*ppr)->tree_b = -1;
break;
case -1:
/* left branch was already too long. rebalnce */
p1 = (*ppr)->tree_l;
if (p1->tree_b == -1) { /* LL */
(*ppr)->tree_l = p1->tree_r;
p1->tree_r = *ppr;
(*ppr)->tree_b = 0;
*ppr = p1;
} else { /* double LR */
p2 = p1->tree_r;
p1->tree_r = p2->tree_l;
p2->tree_l = p1;
(*ppr)->tree_l = p2->tree_r;
p2->tree_r = *ppr;
if (p2->tree_b == -1)
(*ppr)->tree_b = 1;
else
(*ppr)->tree_b = 0;
if (p2->tree_b == 1)
p1->tree_b = -1;
else
p1->tree_b = 0;
*ppr = p2;
} /* else */
(*ppr)->tree_b = 0;
*pi_balance = 0;
} /* switch */
} /* if */
return;
} /* if */
/*
* if MORE, prepare to move to the right.
*/
if (cmp > 0) {
sprout(&(*ppr)->tree_r, pc_data, pi_balance,
pfi_compare, pfi_delete);
if (*pi_balance) { /* right branch has grown longer */
switch ((*ppr)->tree_b) {
case -1:
(*ppr)->tree_b = 0;
*pi_balance = 0;
break;
case 0:
(*ppr)->tree_b = 1;
break;
case 1:
p1 = (*ppr)->tree_r;
if (p1->tree_b == 1) { /* RR */
(*ppr)->tree_r = p1->tree_l;
p1->tree_l = *ppr;
(*ppr)->tree_b = 0;
*ppr = p1;
} else { /* double RL */
p2 = p1->tree_l;
p1->tree_l = p2->tree_r;
p2->tree_r = p1;
(*ppr)->tree_r = p2->tree_l;
p2->tree_l = *ppr;
if (p2->tree_b == 1)
(*ppr)->tree_b = -1;
else
(*ppr)->tree_b = 0;
if (p2->tree_b == -1)
p1->tree_b = 1;
else
p1->tree_b = 0;
*ppr = p2;
} /* else */
(*ppr)->tree_b = 0;
*pi_balance = 0;
} /* switch */
} /* if */
return;
} /* if */
/*
* not less, not more: this is the same key! replace...
*/
*pi_balance = 0;
if (pfi_delete)
(*pfi_delete) ((*ppr)->tree_p);
(*ppr)->tree_p = pc_data;
return;
}
int tree_delete(tree **ppr_p, int (*pfi_compare) (void *, void *), char *pc_user, int (*pfi_uar) (void *)){
int i_balance = 0, i_uar_called = 0;
return avldelete(ppr_p, pfi_compare, pc_user, pfi_uar,
&i_balance, &i_uar_called);
}
static int avldelete(tree **ppr_p, int (*pfi_compare) (void *, void *), char *pc_user, int (*pfi_uar) (void *), int *pi_balance, int *pi_uar_called){
tree *pr_q;
int i_comp, i_ret;
if (*ppr_p == NULL) {
return 0;
}
i_comp = (*pfi_compare) ((*ppr_p)->tree_p, pc_user);
if (i_comp > 0) {
i_ret = avldelete(&(*ppr_p)->tree_l, pfi_compare, pc_user, pfi_uar,
pi_balance, pi_uar_called);
if (*pi_balance)
balanceL(ppr_p, pi_balance);
} else if (i_comp < 0) {
i_ret = avldelete(&(*ppr_p)->tree_r, pfi_compare, pc_user, pfi_uar,
pi_balance, pi_uar_called);
if (*pi_balance)
balanceR(ppr_p, pi_balance);
} else {
pr_q = *ppr_p;
if (pr_q->tree_r == NULL) {
*ppr_p = pr_q->tree_l;
*pi_balance = 1;
} else if (pr_q->tree_l == NULL) {
*ppr_p = pr_q->tree_r;
*pi_balance = 1;
} else {
del(&pr_q->tree_l, pi_balance, &pr_q, pfi_uar,
pi_uar_called);
if (*pi_balance)
balanceL(ppr_p, pi_balance);
}
FREE(pr_q);
if (!*pi_uar_called && pfi_uar)
(*pfi_uar) (pr_q->tree_p);
i_ret = 1;
}
return i_ret;
}
static void del(tree **ppr_r, int *pi_balance, tree **ppr_q, int (*pfi_uar) (void *), int *pi_uar_called){
if ((*ppr_r)->tree_r != NULL) {
del(&(*ppr_r)->tree_r, pi_balance, ppr_q, pfi_uar,
pi_uar_called);
if (*pi_balance)
balanceR(ppr_r, pi_balance);
} else {
if (pfi_uar)
(*pfi_uar) ((*ppr_q)->tree_p);
*pi_uar_called = 1;
(*ppr_q)->tree_p = (*ppr_r)->tree_p;
*ppr_q = *ppr_r;
*ppr_r = (*ppr_r)->tree_l;
*pi_balance = 1;
}
return;
}
static void balanceL (tree ** ppr_p, int * pi_balance){
tree *p1, *p2;
int b1, b2;
switch ((*ppr_p)->tree_b) {
case -1:
(*ppr_p)->tree_b = 0;
break;
case 0:
(*ppr_p)->tree_b = 1;
*pi_balance = 0;
break;
case 1:
p1 = (*ppr_p)->tree_r;
b1 = p1->tree_b;
if (b1 >= 0) {
(*ppr_p)->tree_r = p1->tree_l;
p1->tree_l = *ppr_p;
if (b1 == 0) {
(*ppr_p)->tree_b = 1;
p1->tree_b = -1;
*pi_balance = 0;
} else {
(*ppr_p)->tree_b = 0;
p1->tree_b = 0;
}
*ppr_p = p1;
} else {
p2 = p1->tree_l;
b2 = p2->tree_b;
p1->tree_l = p2->tree_r;
p2->tree_r = p1;
(*ppr_p)->tree_r = p2->tree_l;
p2->tree_l = *ppr_p;
if (b2 == 1)
(*ppr_p)->tree_b = -1;
else
(*ppr_p)->tree_b = 0;
if (b2 == -1)
p1->tree_b = 1;
else
p1->tree_b = 0;
*ppr_p = p2;
p2->tree_b = 0;
}
}
return;
}
static void balanceR (tree ** ppr_p, int * pi_balance){
tree *p1, *p2;
int b1, b2;
switch ((*ppr_p)->tree_b) {
case 1:
(*ppr_p)->tree_b = 0;
break;
case 0:
(*ppr_p)->tree_b = -1;
*pi_balance = 0;
break;
case -1:
p1 = (*ppr_p)->tree_l;
b1 = p1->tree_b;
if (b1 <= 0) {
(*ppr_p)->tree_l = p1->tree_r;
p1->tree_r = *ppr_p;
if (b1 == 0) {
(*ppr_p)->tree_b = -1;
p1->tree_b = 1;
*pi_balance = 0;
} else {
(*ppr_p)->tree_b = 0;
p1->tree_b = 0;
}
*ppr_p = p1;
} else {
p2 = p1->tree_r;
b2 = p2->tree_b;
p1->tree_r = p2->tree_l;
p2->tree_l = p1;
(*ppr_p)->tree_l = p2->tree_r;
p2->tree_r = *ppr_p;
if (b2 == -1)
(*ppr_p)->tree_b = 1;
else
(*ppr_p)->tree_b = 0;
if (b2 == 1)
p1->tree_b = -1;
else
p1->tree_b = 0;
*ppr_p = p2;
p2->tree_b = 0;
}
}
return;
}
int tree_trav(tree **ppr_tree, int (*pfi_uar) (void *)){
if (!*ppr_tree)
return 1;
if (!tree_trav(&(**ppr_tree).tree_l, pfi_uar))
return 0;
if (!(*pfi_uar) ((**ppr_tree).tree_p))
return 0;
if (!tree_trav(&(**ppr_tree).tree_r, pfi_uar))
return 0;
return 1;
}
void tree_mung(tree **ppr_tree, int (*pfi_uar) (void *)){
if (*ppr_tree) {
tree_mung(&(**ppr_tree).tree_l, pfi_uar);
tree_mung(&(**ppr_tree).tree_r, pfi_uar);
if (pfi_uar)
(*pfi_uar) ((**ppr_tree).tree_p);
FREE(*ppr_tree);
*ppr_tree = NULL;
}
return;
}

View File

@ -0,0 +1,23 @@
/*
* avltree.h
*
* Written by Paul Vixie
*/
#ifndef _AVLTREE_H_
#define _AVLTREE_H_
typedef struct tree_s {
struct tree_s *tree_l, *tree_r; /* left & right branches */
char *tree_p; /* data */
short tree_b; /* balance information */
} tree;
void tree_init (tree **);
char *tree_srch (tree *, int (*) (void *, void *), char *);
void tree_add (tree **, int (*) (void *, void *), char *, int (*) (void *));
int tree_delete (tree **, int (*) (void *, void *), char *, int (*) (void *));
int tree_trav (tree **, int (*) (void *));
void tree_mung (tree **, int (*) (void *));
#endif /* _AVLTREE_H_ */

669
fluffos-2.23-ds03/backend.c Normal file
View File

@ -0,0 +1,669 @@
/* 92/04/18 - cleaned up stylistically by Sulam@TMI */
#include "std.h"
#include "lpc_incl.h"
#include "backend.h"
#include "comm.h"
#include "replace_program.h"
#include "socket_efuns.h"
#include "call_out.h"
#include "port.h"
#include "master.h"
#include "eval.h"
#ifdef PACKAGE_ASYNC
#include "packages/async.h"
#endif
#ifdef WIN32
#include <process.h>
void CDECL alarm_loop (void *);
#endif
error_context_t *current_error_context = 0;
/*
* The 'current_time' is updated in the call_out cycles
*/
long current_time;
object_t *current_heart_beat;
static void look_for_objects_to_swap (void);
void call_heart_beat (void);
#if 0
static void report_holes (void);
#endif
/*
* There are global variables that must be zeroed before any execution.
* In case of errors, there will be a LONGJMP(), and the variables will
* have to be cleared explicitely. They are normally maintained by the
* code that use them.
*
* This routine must only be called from top level, not from inside
* stack machine execution (as stack will be cleared).
*/
void clear_state()
{
current_object = 0;
set_command_giver(0);
current_interactive = 0;
previous_ob = 0;
current_prog = 0;
caller_type = 0;
reset_machine(0); /* Pop down the stack. */
} /* clear_state() */
#if 0
static void report_holes() {
if (current_object && current_object->name)
debug_message("current_object is /%s\n", current_object->name);
if (command_giver && command_giver->name)
debug_message("command_giver is /%s\n", command_giver->name);
if (current_interactive && current_interactive->name)
debug_message("current_interactive is /%s\n", current_interactive->name);
if (previous_ob && previous_ob->name)
debug_message("previous_ob is /%s\n", previous_ob->name);
if (current_prog && current_prog->name)
debug_message("current_prog is /%s\n", current_prog->name);
if (caller_type)
debug_message("caller_type is %s\n", caller_type);
}
#endif
void logon (object_t * ob)
{
if(ob->flags & O_DESTRUCTED){
return;
}
/* current_object no longer set */
apply(APPLY_LOGON, ob, 0, ORIGIN_DRIVER);
/* function not existing is no longer fatal */
}
/*
* This is the backend. We will stay here for ever (almost).
*/
extern int max_fd;
void backend()
{
struct timeval timeout;
int i, nb;
volatile int first_call = 1;
int there_is_a_port = 0;
error_context_t econ;
debug_message("Initializations complete.\n\n");
for (i = 0; i < 5; i++) {
if (external_port[i].port) {
debug_message("Accepting connections on port %d.\n",
external_port[i].port);
there_is_a_port = 1;
}
}
if (!there_is_a_port)
debug_message("No external ports specified.\n");
init_user_conn(); /* initialize user connection socket */
#ifdef SIGHUP
signal(SIGHUP, startshutdownMudOS);
#endif
clear_state();
save_context(&econ);
if (SETJMP(econ.context))
restore_context(&econ);
clear_state();
if (!t_flag && first_call) {
first_call = 0;
call_heart_beat();
}
while (1) {
/* Has to be cleared if we jumped out of process_user_command() */
current_interactive = 0;
set_eval(max_cost);
if (obj_list_replace || obj_list_destruct)
remove_destructed_objects();
/*
* shut down MudOS if MudOS_is_being_shut_down is set.
*/
if (MudOS_is_being_shut_down)
shutdownMudOS(0);
if (slow_shut_down_to_do) {
int tmp = slow_shut_down_to_do;
slow_shut_down_to_do = 0;
slow_shut_down(tmp);
}
/*
* select
*/
make_selectmasks();
timeout.tv_sec = 1;
timeout.tv_usec = 0;
#ifndef hpux
nb = select(max_fd + 1, &readmask, &writemask, (fd_set *) 0, &timeout);
#else
nb = select(max_fd + 1, (int *) &readmask, (int *) &writemask,
(int *) 0, &timeout);
#endif
/*
* process I/O if necessary.
*/
if (nb > 0) {
process_io();
}
/*
* process user commands.
*/
for (i = 0; process_user_command() && i < max_users; i++)
;
/*
* call outs
*/
call_out();
#ifdef PACKAGE_ASYNC
check_reqs();
#endif
}
} /* backend() */
/*
* Despite the name, this routine takes care of several things.
* It will run once every 15 minutes.
*
* . It will attempt to reconnect to the address server if the connection has
* been lost.
* . It will loop through all objects.
*
* . If an object is found in a state of not having done reset, and the
* delay to next reset has passed, then reset() will be done.
*
* . If the object has a existed more than the time limit given for swapping,
* then 'clean_up' will first be called in the object
*
* There are some problems if the object self-destructs in clean_up, so
* special care has to be taken of how the linked list is used.
*/
static void look_for_objects_to_swap()
{
static int next_time;
#ifndef NO_IP_DEMON
extern int no_ip_demon;
static int next_server_time;
#endif
object_t *ob;
VOLATILE object_t *next_ob, *last_good_ob;
error_context_t econ;
#ifndef NO_IP_DEMON
if (current_time >= next_server_time) {
/* initialize the address server. if it is already initialized, then
* this is a nop. this will cause the driver to reattempt connecting
* to the address server once every 15 minutes in the event that it
* has gone down.
*/
if (!no_ip_demon && next_server_time)
init_addr_server(ADDR_SERVER_IP, ADDR_SERVER_PORT);
next_server_time = current_time + 15 * 60;
}
#endif
if (current_time < next_time)
return; /* Not time to look yet */
next_time = current_time + 5 * 60; /* Next time is in 5 minutes */
/*
* Objects object can be destructed, which means that next object to
* investigate is saved in next_ob. If very unlucky, that object can be
* destructed too. In that case, the loop is simply restarted.
*/
next_ob = obj_list;
last_good_ob = obj_list;
save_context(&econ);
if (SETJMP(econ.context))
restore_context(&econ);
while ((ob = (object_t *)next_ob)) {
int ready_for_clean_up = 0;
if (ob->flags & O_DESTRUCTED){
if(last_good_ob->flags & O_DESTRUCTED)
ob = obj_list; /* restart */
else
ob = (object_t *)last_good_ob;
}
next_ob = ob->next_all;
/*
* Check reference time before reset() is called.
*/
if (current_time - ob->time_of_ref > time_to_clean_up)
ready_for_clean_up = 1;
#if !defined(NO_RESETS) && !defined(LAZY_RESETS)
/*
* Should this object have reset(1) called ?
*/
if ((ob->flags & O_WILL_RESET) && (ob->next_reset < current_time)
&& !(ob->flags & O_RESET_STATE)) {
debug(d_flag, ("RESET /%s\n", ob->obname));
set_eval(max_cost);
reset_object(ob);
if(ob->flags & O_DESTRUCTED)
continue;
}
#endif
if (time_to_clean_up > 0) {
/*
* Has enough time passed, to give the object a chance to
* self-destruct ? Save the O_RESET_STATE, which will be cleared.
*
* Only call clean_up in objects that has defined such a function.
*
* Only if the clean_up returns a non-zero value, will it be called
* again.
*/
if (ready_for_clean_up && (ob->flags & O_WILL_CLEAN_UP)) {
int save_reset_state = ob->flags & O_RESET_STATE;
svalue_t *svp;
debug(d_flag, ("clean up /%s\n", ob->obname));
/*
* Supply a flag to the object that says if this program is
* inherited by other objects. Cloned objects might as well
* believe they are not inherited. Swapped objects will not
* have a ref count > 1 (and will have an invalid ob->prog
* pointer).
*
* Note that if it is in the apply_low cache, it will also
* get a flag of 1, which may cause the mudlib not to clean
* up the object. This isn't bad because:
* (1) one expects it is rare for objects that have untouched
* long enough to clean_up to still be in the cache, especially
* on busy MUDs.
* (2) the ones that are are the more heavily used ones, so
* keeping them around seems justified.
*/
push_number(ob->flags & (O_CLONE) ? 0 : ob->prog->ref);
set_eval(max_cost);
svp = apply(APPLY_CLEAN_UP, ob, 1, ORIGIN_DRIVER);
if (ob->flags & O_DESTRUCTED)
continue;
if (!svp || (svp->type == T_NUMBER && svp->u.number == 0))
ob->flags &= ~O_WILL_CLEAN_UP;
ob->flags |= save_reset_state;
}
}
last_good_ob = ob;
}
pop_context(&econ);
} /* look_for_objects_to_swap() */
/* Call all heart_beat() functions in all objects. Also call the next reset,
* and the call out.
* We do heart beats by moving each object done to the end of the heart beat
* list before we call its function, and always using the item at the head
* of the list as our function to call. We keep calling heart beats until
* a timeout or we have done num_heart_objs calls. It is done this way so
* that objects can delete heart beating objects from the list from within
* their heart beat without truncating the current round of heart beats.
*
* Set command_giver to current_object if it is a living object. If the object
* is shadowed, check the shadowed object if living. There is no need to save
* the value of the command_giver, as the caller resets it to 0 anyway. */
typedef struct {
object_t *ob;
short heart_beat_ticks;
short time_to_heart_beat;
} heart_beat_t;
static heart_beat_t *heart_beats = 0;
static int max_heart_beats = 0;
static int heart_beat_index = 0;
static int num_hb_objs = 0;
static int num_hb_to_do = 0;
static int num_hb_calls = 0; /* starts */
static float perc_hb_probes = 100.0; /* decaying avge of how many complete */
void call_heart_beat()
{
object_t *ob;
heart_beat_t *curr_hb;
error_context_t econ;
current_interactive = 0;
if ((num_hb_to_do = num_hb_objs)) {
num_hb_calls++;
heart_beat_index = 0;
save_context(&econ);
while (1) {
ob = (curr_hb = &heart_beats[heart_beat_index])->ob;
DEBUG_CHECK(!(ob->flags & O_HEART_BEAT),
"Heartbeat not set in object on heartbeat list!");
/* is it time to do a heart beat ? */
curr_hb->heart_beat_ticks--;
if (ob->prog->heart_beat != 0) {
if (curr_hb->heart_beat_ticks < 1) {
object_t *new_command_giver;
curr_hb->heart_beat_ticks = curr_hb->time_to_heart_beat;
current_heart_beat = ob;
new_command_giver = ob;
#ifndef NO_SHADOWS
while (new_command_giver->shadowing)
new_command_giver = new_command_giver->shadowing;
#endif
#ifndef NO_ADD_ACTION
if (!(new_command_giver->flags & O_ENABLE_COMMANDS))
new_command_giver = 0;
#endif
#ifdef PACKAGE_MUDLIB_STATS
add_heart_beats(&ob->stats, 1);
#endif
set_eval(max_cost);
if (SETJMP(econ.context)) {
restore_context(&econ);
} else {
save_command_giver(new_command_giver);
call_direct(ob, ob->prog->heart_beat - 1,
ORIGIN_DRIVER, 0);
pop_stack(); /* pop the return value */
restore_command_giver();
}
current_object = 0;
}
}
if (++heart_beat_index == num_hb_to_do)
break;
}
pop_context(&econ);
if (heart_beat_index < num_hb_to_do)
perc_hb_probes = 100 * (float) heart_beat_index / num_hb_to_do;
else
perc_hb_probes = 100.0;
heart_beat_index = num_hb_to_do = 0;
}
current_prog = 0;
current_heart_beat = 0;
look_for_objects_to_swap();
#ifdef PACKAGE_MUDLIB_STATS
mudlib_stats_decay();
#endif
} /* call_heart_beat() */
int
query_heart_beat (object_t * ob)
{
int index;
if (!(ob->flags & O_HEART_BEAT)) return 0;
index = num_hb_objs;
while (index--) {
if (heart_beats[index].ob == ob)
return heart_beats[index].time_to_heart_beat;
}
return 0;
} /* query_heart_beat() */
/* add or remove an object from the heart beat list; does the major check...
* If an object removes something from the list from within a heart beat,
* various pointers in call_heart_beat could be stuffed, so we must
* check current_heart_beat and adjust pointers. */
int set_heart_beat (object_t * ob, int to)
{
int index;
if (ob->flags & O_DESTRUCTED) return 0;
if (!to) {
int num;
index = num_hb_objs;
while (index--) {
if (heart_beats[index].ob == ob) break;
}
if (index < 0) return 0;
if (num_hb_to_do) {
if (index <= heart_beat_index)
heart_beat_index--;
if (index < num_hb_to_do)
num_hb_to_do--;
}
if ((num = (num_hb_objs - (index + 1))))
memmove(heart_beats + index, heart_beats + (index + 1), num * sizeof(heart_beat_t));
num_hb_objs--;
ob->flags &= ~O_HEART_BEAT;
return 1;
}
if (ob->flags & O_HEART_BEAT) {
if (to < 0) return 0;
index = num_hb_objs;
while (index--) {
if (heart_beats[index].ob == ob) {
heart_beats[index].time_to_heart_beat = heart_beats[index].heart_beat_ticks = to;
break;
}
}
DEBUG_CHECK(index < 0, "Couldn't find enabled object in heart_beat list!\n");
} else {
heart_beat_t *hb;
if (!max_heart_beats)
heart_beats = CALLOCATE(max_heart_beats = HEART_BEAT_CHUNK,
heart_beat_t, TAG_HEART_BEAT,
"set_heart_beat: 1");
else if (num_hb_objs == max_heart_beats) {
max_heart_beats += HEART_BEAT_CHUNK;
heart_beats = RESIZE(heart_beats, max_heart_beats,
heart_beat_t, TAG_HEART_BEAT,
"set_heart_beat: 1");
}
hb = &heart_beats[num_hb_objs++];
hb->ob = ob;
if (to < 0) to = 1;
hb->time_to_heart_beat = to;
hb->heart_beat_ticks = to;
ob->flags |= O_HEART_BEAT;
}
return 1;
}
int heart_beat_status (outbuffer_t * ob, int verbose)
{
char buf[20];
if (verbose == 1) {
outbuf_add(ob, "Heart beat information:\n");
outbuf_add(ob, "-----------------------\n");
outbuf_addv(ob, "Number of objects with heart beat: %d, starts: %d\n",
num_hb_objs, num_hb_calls);
/* passing floats to varargs isn't highly portable so let sprintf
handle it */
sprintf(buf, "%.2f", perc_hb_probes);
outbuf_addv(ob, "Percentage of HB calls completed last time: %s\n", buf);
}
return (0);
} /* heart_beat_status() */
/* New version used when not in -o mode. The epilog() in master.c is
* supposed to return an array of files (castles in 2.4.5) to load. The array
* returned by apply() will be freed at next call of apply(), which means that
* the ref count has to be incremented to protect against deallocation.
*
* The master object is asked to do the actual loading.
*/
void preload_objects (int eflag)
{
VOLATILE array_t *prefiles;
svalue_t *ret;
VOLATILE int ix;
error_context_t econ;
save_context(&econ);
if (SETJMP(econ.context)) {
restore_context(&econ);
pop_context(&econ);
return;
}
push_number(eflag);
ret = apply_master_ob(APPLY_EPILOG, 1);
pop_context(&econ);
if ((ret == 0) || (ret == (svalue_t *)-1) || (ret->type != T_ARRAY))
return;
else
prefiles = ret->u.arr;
if ((prefiles == 0) || (prefiles->size < 1))
return;
debug_message("\nLoading preloaded files ...\n");
prefiles->ref++;
ix = 0;
/* in case of an error, effectively do a 'continue' */
save_context(&econ);
if (SETJMP(econ.context)) {
restore_context(&econ);
ix++;
}
for ( ; ix < prefiles->size; ix++) {
if (prefiles->item[ix].type != T_STRING)
continue;
set_eval(max_cost);
push_svalue(((array_t *)prefiles)->item + ix);
(void) apply_master_ob(APPLY_PRELOAD, 1);
}
free_array((array_t *)prefiles);
pop_context(&econ);
} /* preload_objects() */
/* All destructed objects are moved into a sperate linked list,
* and deallocated after program execution. */
INLINE void remove_destructed_objects()
{
object_t *ob, *next;
if (obj_list_replace)
replace_programs();
for (ob = obj_list_destruct; ob; ob = next) {
next = ob->next_all;
destruct2(ob);
}
obj_list_destruct = 0;
} /* remove_destructed_objects() */
static double load_av = 0.0;
void update_load_av()
{
static int last_time;
int n;
double c;
static int acc = 0;
acc++;
if (current_time == last_time)
return;
n = current_time - last_time;
if (n < NUM_CONSTS)
c = consts[n];
else
c = exp(-n / 900.0);
load_av = c * load_av + acc * (1 - c) / n;
last_time = current_time;
acc = 0;
} /* update_load_av() */
static double compile_av = 0.0;
void
update_compile_av (int lines)
{
static int last_time;
int n;
double c;
static int acc = 0;
acc += lines;
if (current_time == last_time)
return;
n = current_time - last_time;
if (n < NUM_CONSTS)
c = consts[n];
else
c = exp(-n / 900.0);
compile_av = c * compile_av + acc * (1 - c) / n;
last_time = current_time;
acc = 0;
} /* update_compile_av() */
char *query_load_av()
{
static char buff[100];
sprintf(buff, "%.2f cmds/s, %.2f comp lines/s", load_av, compile_av);
return (buff);
} /* query_load_av() */
#ifdef F_HEART_BEATS
array_t *get_heart_beats() {
int nob = 0, n = num_hb_objs;
heart_beat_t *hb = heart_beats;
object_t **obtab;
array_t *arr;
#ifdef F_SET_HIDE
int apply_valid_hide = 1, display_hidden = 0;
#endif
if(n)
obtab = CALLOCATE(n, object_t *, TAG_TEMPORARY, "heart_beats");
else
obtab = NULL;
while (n--) {
#ifdef F_SET_HIDE
if (hb->ob->flags & O_HIDDEN) {
if (apply_valid_hide) {
apply_valid_hide = 0;
display_hidden = valid_hide(current_object);
}
if (!display_hidden)
continue;
}
#endif
obtab[nob++] = (hb++)->ob;
}
arr = allocate_empty_array(nob);
while (nob--) {
arr->item[nob].type = T_OBJECT;
arr->item[nob].u.ob = obtab[nob];
add_ref(arr->item[nob].u.ob, "get_heart_beats");
}
if(obtab)
FREE(obtab);
return arr;
}
#endif

View File

@ -0,0 +1,35 @@
#ifndef BACKEND_H
#define BACKEND_H
#include "interpret.h"
#include "object.h"
#define NULL_ERROR_CONTEXT 0
#define NORMAL_ERROR_CONTEXT 1
#define CATCH_ERROR_CONTEXT 2
#define SAFE_APPLY_ERROR_CONTEXT 4
/*
* backend.c
*/
extern long current_time;
extern object_t *current_heart_beat;
extern error_context_t *current_error_context;
void backend (void);
void clear_state (void);
void logon (object_t *);
int parse_command (char *, object_t *);
int set_heart_beat (object_t *, int);
int query_heart_beat (object_t *);
int heart_beat_status (outbuffer_t *, int);
void preload_objects (int);
INLINE void remove_destructed_objects (void);
void update_load_av (void);
void update_compile_av (int);
char *query_load_av (void);
array_t *get_heart_beats (void);
int query_time_used (void);
void call_heart_beat (void);
#endif

View File

@ -0,0 +1,437 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)malloc.c 5.11 (Berkeley) 2/23/91";
#endif /* LIBC_SCCS and not lint */
/*
* malloc.c (Caltech) 2/21/82
* Chris Kingsley, kingsley@cit-20.
*
* This is a very fast storage allocator. It allocates blocks of a small
* number of different sizes, and keeps free lists of each size. Blocks that
* don't exactly fit are passed up to the next larger size. In this
* implementation, the available sizes are 2^n-4 (or 2^n-10) bytes long.
* This is designed for use in a virtual memory environment.
*/
#define IN_MALLOC_WRAPPER
#define NO_OPCODES
#include "std.h"
#include "main.h"
#undef NULL
#define NULL 0
#ifdef _SEQUENT_
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
#endif
/*
* The overhead on a block is at least 4 bytes. When free, this space
* contains a pointer to the next free block, and the bottom two bits must
* be zero. When in use, the first byte is set to MAGIC, and the second
* byte is the size index. The remaining bytes are for alignment.
* If range checking is enabled then a second word holds the size of the
* requested block, less 1, rounded up to a multiple of sizeof(RMAGIC).
* The order of elements is critical: ov_magic must overlay the low order
* bits of ov_next, and ov_magic can not be a valid ov_next bit pattern.
*/
union overhead {
union overhead *ov_next; /* when free */
struct {
u_char ovu_magic; /* magic number */
u_char ovu_index; /* bucket # */
#ifdef RCHECK
u_short ovu_rmagic; /* range magic number */
u_int ovu_size; /* actual block size */
#endif
} ovu;
#define ov_magic ovu.ovu_magic
#define ov_index ovu.ovu_index
#define ov_rmagic ovu.ovu_rmagic
#define ov_size ovu.ovu_size
};
#define MAGIC 0xef /* magic # on accounting info */
#define RMAGIC 0x5555 /* magic # on range info */
#ifdef RCHECK
#define RSLOP sizeof (u_short)
#else
#define RSLOP 0
#endif
/*
* nextf[i] is the pointer to the next free block of size 2^(i+3). The
* smallest allocatable block is 8 bytes. The overhead information
* precedes the data area returned to the user.
*/
#define NBUCKETS 30
static union overhead *nextf[NBUCKETS];
static int pagesz; /* page size */
static int pagebucket; /* page size bucket */
static void morecore (int);
static int findbucket (union overhead *, int);
void *sbrkx(long);
#ifdef DO_MSTATS
/*
* nmalloc[i] is the difference between the number of mallocs and frees
* for a given block size.
*/
static u_int nmalloc[NBUCKETS];
#endif
#if defined(DEBUG) || defined(RCHECK)
#ifdef __STDC__
#define ASSERT(p) if (!(p)) botch(#p)
#else
#define ASSERT(p) if (!(p)) botch("?")
#endif
static int botch (char * s)
{
debug_message("\r\nassertion botched: %s\r\n", s);
(void) fflush(stderr); /* just in case user buffered it */
abort();
return 0;
}
#else
#define ASSERT(p)
#endif
#ifdef malloc
/* linux */
#undef malloc
#endif
void *bsdmalloc_malloc (size_t nbytes)
{
register union overhead *op;
register long bucket, n;
register unsigned amt;
/*
* First time malloc is called, setup page size and align break pointer
* so all data will be page aligned.
*/
if (pagesz == 0) {
#ifdef MEMPAGESIZE
pagesz = n = MEMPAGESIZE;
#else
pagesz = n = getpagesize();
#endif
op = (union overhead *) sbrkx(0);
n = n - sizeof(*op) - ((long) op & (n - 1));
if (n < 0)
n += pagesz;
if (n) {
if ((char *)sbrkx(n) == (char *) -1)
return (NULL);
}
bucket = 0;
amt = 8;
while (pagesz > amt) {
amt <<= 1;
bucket++;
}
pagebucket = bucket;
}
/*
* Convert amount of memory requested into closest block size stored in
* hash buckets which satisfies request. Account for space used per block
* for accounting.
*/
if (nbytes <= (n = pagesz - sizeof(*op) - RSLOP)) {
#ifndef RCHECK
amt = 8; /* size of first bucket */
bucket = 0;
#else
amt = 16; /* size of first bucket */
bucket = 1;
#endif
n = -(sizeof(*op) + RSLOP);
} else {
amt = pagesz;
bucket = pagebucket;
}
while (nbytes > amt + n) {
amt <<= 1;
if (amt == 0)
return (NULL);
bucket++;
}
/*
* If nothing in hash bucket right now, request more memory from the
* system.
*/
if ((op = nextf[bucket]) == NULL) {
morecore(bucket);
if ((op = nextf[bucket]) == NULL)
return (NULL);
}
/* remove from linked list */
nextf[bucket] = op->ov_next;
op->ov_magic = MAGIC;
op->ov_index = bucket;
#ifdef DO_MSTATS
nmalloc[bucket]++;
#endif
#ifdef RCHECK
/*
* Record allocated size of block and bound space with magic numbers.
*/
op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
op->ov_rmagic = RMAGIC;
*(u_short *) ((caddr_t) (op + 1) + op->ov_size) = RMAGIC;
#endif
return ((char *) (op + 1));
}
/*
* Allocate more memory to the indicated bucket.
*/
static void
morecore (int bucket)
{
register union overhead *op;
register int sz; /* size of desired block */
int amt; /* amount to allocate */
int nblks; /* how many blocks we get */
/*
* sbrk_size <= 0 only for big, FLUFFY, requests (about 2^30 bytes on a
* VAX, I think) or for a negative arg.
*/
sz = 1 << (bucket + 3);
#ifdef DEBUG
ASSERT(sz > 0);
#else
if (sz <= 0)
return;
#endif
if (sz < pagesz) {
amt = pagesz;
nblks = amt / sz;
} else {
amt = sz + pagesz;
nblks = 1;
}
op = (union overhead *) sbrkx(amt);
/* no more room! */
if ((long) op == -1)
return;
/*
* Add new memory allocated to that on free list for this hash bucket.
*/
nextf[bucket] = op;
while (--nblks > 0) {
op->ov_next = (union overhead *) ((caddr_t) op + sz);
op = (union overhead *) ((caddr_t) op + sz);
}
}
INLINE void
bsdmalloc_free (void * cp)
{
register int size;
register union overhead *op;
if (cp == NULL)
return;
op = (union overhead *) ((caddr_t) cp - sizeof(union overhead));
#ifdef DEBUG
ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */
#else
if (op->ov_magic != MAGIC)
return; /* sanity */
#endif
#ifdef RCHECK
ASSERT(op->ov_rmagic == RMAGIC);
ASSERT(*(u_short *) ((caddr_t) (op + 1) + op->ov_size) == RMAGIC);
#endif
size = op->ov_index;
ASSERT(size < NBUCKETS);
op->ov_next = nextf[size]; /* also clobbers ov_magic */
nextf[size] = op;
#ifdef DO_MSTATS
nmalloc[size]--;
#endif
}
/*
* When a program attempts "storage compaction" as mentioned in the
* old malloc man page, it realloc's an already freed block. Usually
* this is the last block it freed; occasionally it might be farther
* back. We have to search all the free lists for the block in order
* to determine its bucket: 1st we make one pass thru the lists
* checking only the first block in each; if that fails we search
* ``realloc_srchlen'' blocks in each list for a match (the variable
* is extern so the caller can modify it). If that fails we just copy
* however many bytes was given to realloc() and hope it's not huge.
*/
int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
void *bsdmalloc_realloc (void * cp, size_t nbytes)
{
register u_int onb;
register int i;
union overhead *op;
char *res;
int was_alloced = 0;
if (cp == NULL)
return (bsdmalloc_malloc(nbytes));
op = (union overhead *) ((caddr_t) cp - sizeof(union overhead));
if (op->ov_magic == MAGIC) {
was_alloced++;
i = op->ov_index;
} else {
/*
* Already free, doing "compaction".
*
* Search for the old block of memory on the free list. First, check
* the most common case (last element free'd), then (this failing)
* the last ``realloc_srchlen'' items free'd. If all lookups fail,
* then assume the size of the memory block being realloc'd is the
* largest possible (so that all "nbytes" of new memory are copied
* into). Note that this could cause a memory fault if the old area
* was tiny, and the moon is gibbous. However, that is very
* unlikely.
*/
if ((i = findbucket(op, 1)) < 0 &&
(i = findbucket(op, realloc_srchlen)) < 0)
i = NBUCKETS;
}
onb = 1 << (i + 3);
if (onb < pagesz)
onb -= sizeof(*op) + RSLOP;
else
onb += pagesz - sizeof(*op) - RSLOP;
/* avoid the copy if same size block */
if (was_alloced) {
if (i) {
i = 1 << (i + 2);
if (i < pagesz)
i -= sizeof(*op) + RSLOP;
else
i += pagesz - sizeof(*op) - RSLOP;
}
if (nbytes <= onb && nbytes > i) {
#ifdef RCHECK
op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
*(u_short *) ((caddr_t) (op + 1) + op->ov_size) = RMAGIC;
#endif
return (cp);
} else
bsdmalloc_free(cp);
}
if ((res = bsdmalloc_malloc(nbytes)) == NULL)
return (NULL);
if (cp != res) /* common optimization if "compacting" */
memcpy(res, cp, (nbytes < onb) ? nbytes : onb);
return (res);
}
/*
* Search ``srchlen'' elements of each free list for a block whose
* header starts at ``freep''. If srchlen is -1 search the whole list.
* Return bucket number, or -1 if not found.
*/
static int
findbucket (union overhead * freep, int srchlen)
{
register union overhead *p;
register int i, j;
for (i = 0; i < NBUCKETS; i++) {
j = 0;
for (p = nextf[i]; p && j != srchlen; p = p->ov_next) {
if (p == freep)
return (i);
j++;
}
}
return (-1);
}
#ifdef DO_MSTATS
/*
* mstats - print out statistics about malloc
*
* Prints two lines of numbers, one showing the length of the free list
* for each size category, the second showing the number of mallocs -
* frees for each size category.
*/
void
show_mstats (outbuffer_t * ob, char * s)
{
register int i, j;
register union overhead *p;
int totfree = 0, totused = 0;
outbuf_addv(ob, "Memory allocation statistics %s\nfree:\t", s);
for (i = 0; i < NBUCKETS; i++) {
for (j = 0, p = nextf[i]; p; p = p->ov_next, j++);
outbuf_addv(ob, " %d", j);
totfree += j * (1 << (i + 3));
}
outbuf_add(ob, "\nused:\t");
for (i = 0; i < NBUCKETS; i++) {
outbuf_addv(ob, " %d", nmalloc[i]);
totused += nmalloc[i] * (1 << (i + 3));
}
outbuf_addv(ob, "\n\tTotal in use: %d, total free: %d\n",
totused, totfree);
}
#endif
/* calloc was originally in its own source file */
#ifdef calloc
/* linux */
#undef calloc
#endif
INLINE void *bsdmalloc_calloc (size_t num, register size_t size)
{
register void *p;
size *= num;
if ((p = bsdmalloc_malloc(size)))
memset(p, 0, size);
return (p);
}

View File

@ -0,0 +1,14 @@
#ifndef BSDMALLOC_H
#define BSDMALLOC_H
#ifdef BSDMALLOC
void *bsdmalloc_malloc (size_t);
void *bsdmalloc_calloc (size_t, size_t);
void *bsdmalloc_realloc (void *, size_t);
void bsdmalloc_free (void *);
#ifdef DO_MSTATS
void show_mstats (outbuffer_t *, char *);
#endif
#endif
#endif

113
fluffos-2.23-ds03/buffer.c Normal file
View File

@ -0,0 +1,113 @@
/* buffer.c for MudOS 0.9.x by John Garnett, 1993/11/07 */
#include "std.h"
#ifndef NO_BUFFER_TYPE
#include "crctab.h"
#include "lpc_incl.h"
#include "stralloc.h"
buffer_t null_buf =
{
1, /* Ref count, which will ensure that it will
* never be deallocated */
0 /* size */
};
INLINE buffer_t *
null_buffer()
{
null_buf.ref++;
return &null_buf;
} /* null_buffer() */
INLINE void
free_buffer (buffer_t * b)
{
b->ref--;
/* don't try to free the null_buffer (ref count might overflow) */
if ((b->ref > 0) || (b == &null_buf)) {
return;
}
FREE((char *) b);
} /* free_buffer() */
buffer_t *
allocate_buffer (int size)
{
buffer_t *buf;
#ifndef NO_BUFFER_TYPE
if ((size < 0) || (size > max_buffer_size)) {
error("Illegal buffer size.\n");
}
if (size == 0) {
return null_buffer();
}
/* using calloc() so that memory will be zero'd out when allocated */
buf = (buffer_t *) DCALLOC(sizeof(buffer_t) + size - 1, 1,
TAG_BUFFER, "allocate_buffer");
buf->size = size;
buf->ref = 1;
return buf;
#else
return NULL;
#endif
}
int write_buffer (buffer_t * buf, int start, const char * str, int theLength)
{
int size;
size = buf->size;
if (start < 0) {
start = size + start;
if (start < 0) {
return 0;
}
}
/*
* can't write past the end of the buffer since we can't reallocate the
* buffer here (no easy way to propagate back the changes to the caller
*/
if ((start + theLength) > size) {
return 0;
}
memcpy(buf->item + start, str, theLength);
return 1;
} /* write_buffer() */
char *
read_buffer (buffer_t * b, int start, int len, int * rlen)
{
char *str;
unsigned int size;
if (len < 0)
return 0;
size = b->size;
if (start < 0) {
start = size + start;
if (start < 0) {
return 0;
}
}
if (len == 0) {
len = size;
}
if (start >= size) {
return 0;
}
if ((start + len) > size) {
len = (size - start);
}
for (str = (char *)b->item + start, size = 0; *str && size < len; str++, size++)
;
str = new_string(size, "read_buffer: str");
memcpy(str, b->item + start, size);
str[*rlen = size] = '\0';
return str;
} /* read_buffer() */
#endif

View File

@ -0,0 +1,32 @@
/* buffer.h by John Garnett, 1993/11/07 */
/* It is usually better to include "lpc_incl.h" instead of including this
directly */
#ifndef _BUFFER_H_
#define _BUFFER_H_
#ifndef NO_BUFFER_TYPE
typedef struct buffer_s {
/* first two elements of struct must be 'ref' followed by 'size' */
unsigned short ref;
unsigned int size;
#ifdef DEBUG
unsigned short extra_ref;
#endif
unsigned char item[1];
} buffer_t;
/*
* buffer.c
*/
extern buffer_t null_buf;
INLINE buffer_t *null_buffer (void);
INLINE void free_buffer (buffer_t *);
buffer_t *allocate_buffer (int);
int write_buffer (buffer_t *, int, const char *, int);
char *read_buffer (buffer_t *, int, int, int *);
#endif
#endif

View File

@ -0,0 +1,478 @@
#!/bin/sh
ENABLE_M64=0
export ENABLE_M64
if test $# -ne 0; then
case $1 in
develop)
echo Preparing to build developmental version of MudOS driver ...
OPTIMIZE="-O0 -Wall -Wundef -DPEDANTIC -pedantic -Wmissing-declarations"
DEBUG="-g -DDEBUG -DDEBUG_MACRO"
;;
debug)
echo Preparing to build debugging version of MudOS driver ...
OPTIMIZE="-O0"
DEBUG="-g -DDEBUG"
;;
*)
echo Unknown build type
exit 1
;;
esac
else
echo Preparing to build standard MudOS driver ...
fi
# If this is uncommented, the specified 'make' is used instead of looking for
# one
#MAKE=make
# define this to be where you want the temporary compiled files to go
# (only used with GNU make)
OBJDIR=obj
# change this if you wish the driver binary to be named something else
DRIVER_BIN=driver
# uncomment PROOF if using CenterLine's TestCenter to debug the driver.
#PROOF=proof
# Set INSTALL_DIR to the directory where you want to install the executables.
INSTALL_DIR="../bin"
#Enable warnings from the compiler (gcc), if wanted.
#WARN=-Wall
#PIPE=-pipe
# define profiling if you want it
# note: the gmon.out file will likely be written in the mudlib dir.
# PROFILE_ON controls whether or not monitoring is active at driver
# startup. Comment PROFILE_ON to make profiling not active at startup.
# Use moncontrol(1) efun to enable profiling and moncontrol(0) to turn
# it off.
#PROFILE_ON="-DPROFILE_ON"
# Uncomment this if you want to enable profiling of the driver (gcc)
#PROFIL="-pg -DPROFILING $(PROFILE_ON)"
# Enable run time debugging
#DEBUG="-g"
# With extra driver debug code
#DEBUG="-g -DDEBUG"
# For DEC Alpha: to have optimization and debugging
#DEBUG="-g3 -DDEBUG"
# Prevent -DDEBUG from aborting the driver (when in -DDEBUG mode)
#DEBUG_NON_FATAL="-DDEBUG_NON_FATAL"
# Compile in debug() macro code
#DEBUG_MACRO="-DDEBUG_MACRO"
# define this if you want to specify (compiler) optimization.
#
# if nothing is defined here, and DEBUG is not defined, something appropriate
# to the compiler in question is used.
#
# *WARNING* using high levels of optimization (e.g. -O3) can cause some
# compilers to produce incorrect code. If the driver is behaving
# inexplicably, try using a lower level of optimization (or none).
#
# Uncomment one or none of the following optimization lines.
#
# -O is usually a safe level of optimization for most compilers
#OPTIMIZE="-O"
# high optimization for gcc:
#OPTIMIZE="-O2 -fstrength-reduce"
# uncomment below for RS/6000(AIX) xlc compiler only.
# remove the -Q if xlc complains.
#OPTIMIZE="-O -Q"
# might need this one with newer versions of AIX (ie 3.2.4)
#OPTIMIZE="-O -Q -qMAXMEM=16000"
# high optimization for HP-UX 7.x/8.x's cc (don't use with 9.x)
#OPTIMIZE="+O3 +Obb3000"
# MIPS R3000 running EP/IX Version 1.4.3. Compiler is RISCompiler C 2.11 (cc).
#OPTIMIZE="-Olimit 1802"
# DEC Alpha's cc's highest optimization: -O5
#OPTIMIZE="-O -Olimit 2000"
# DEC Ultrix's cc's highest optimization:
#OPTIMIZE="-O2 -Olimit 5000"
# high optimization for cc on SGI
#OPTIMIZE="-O2 -Olimit 2500"
# System V Release 4 (386/486 or if using Sun's cc under Solaris 2.x)
# ARCH: need a way to detect this
#OSFLAGS=-DSVR4
# MIPS R3000 running EP/IX Version 1.4.3. Compiler is RISCompiler C 2.11 (cc).
# ARCH: this one too
#OSFLAGS=-I/usr/include/bsd
# Solaris (SunOS 5): for BSD compatible ioctl()
# If using CC=cc, you can also add:
# -w to turn off warnings, in order to get a cleaner compile
# For 5.4, also add the following:
# -I/usr/bsdinclude
# ARCH: anyone figured a good hack to detect this one yet?
#OSFLAGS="-DBSD_COMP -DSunOS_5"
# SCO 3.2v4.2
# ARCH: *sigh* and this one ...
#OSFLAGS=-DSCO
#Static for compiling Discworld on MINGW
#OSFLAGS=-static
# try uncommenting this if you are using gcc and at runtime you see socket
# errors saying that the "set socket nonblocking" operation is not supported.
# That error is caused by old-style macros (that gcc doesn't normally grok)
# used by ioctl on some systems.
#NEED_OLD_CPP=-traditional-cpp
# Location of libmsgql.a, if you are using PACKAGE_DB
#EXTRALIBS=-L/usr/local/lib -lmsql
####### END OF USER CONFIGURABLE OPTIONS
echo "Trying out some stuff to see what works; ignore errors ..."
# Mac OS X needs this in order to build properly with gcc < 3
if test "`uname`" = "Darwin"; then
GCC_MAJOR="`gcc -v 2>&1 | grep "gcc version" | cut -d ' ' -f 3 | cut -d '.' -f 1`"
GCC_MINOR="`gcc -v 2>&1 | grep "gcc version" | cut -d ' ' -f 3 | cut -d '.' -f 2`"
if test "$GCC_MAJOR" -eq "2"; then
NEED_OLD_CPP=-traditional-cpp
fi
fi
#
# Figure out what make is, and how to invoke it
#
if test "${MAKE-x}" = "x"; then
gmake nothing
if test $? -eq 0; then
MAKE=gmake
MAKEFILE=GNUmakefile
else
make nothing
if test $? -eq 0; then
MAKE=make
tmp=`make which_makefile 2>./2.out | grep -v echo`
if test "x$tmp" = "xMakeIsGNU"; then
MAKEFILE=GNUmakefile
else
MAKEFILE=Makefile
OBJDIR=
fi
else
echo 'FATAL ERROR: Cannot find make or gmake'
exit
fi
fi
else
tmp=`make which_makefile 2>./2.out | grep -v echo`
if test "x$tmp" = "xMakeIsGNU"; then
MAKEFILE=GNUmakefile
else
MAKEFILE=Makefile
OBJDIR=
fi
fi
echo MAKE=$MAKE >Makefile.tmp
#
# Determine if running under Cygwin-32 and use a.exe instead
# of a.out if so
#
if test $CYGWIN; then
A_OUT=a.exe
echo Using a.exe for Cygwin GNU compiler default executable
else
A_OUT=a.out
echo Using standard a.out for compiler default executable
fi
#
# Figure out what to use for CC
#
cat >comptest.c <<END
int main() {
}
END
xlc comptest.c
if test $? -eq 0; then
CC=xlc
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O2 -Q -qMAXMEM=16000"}
fi
else
gcc comptest.c
if test $? -eq 0; then
CC="gcc"
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O2"}
fi
if (test $? -eq 0); then
if (test $ENABLE_M64 -eq 1); then
CC="gcc -m64"
OPTIMIZE=$OPTIMIZE" -DM64"
fi
fi
echo "CC: "$CC
GNUC=1
CCFLAGS=-D__USE_FIXED_PROTOTYPES__
else
clcc comptest.c
if test $? -eq 0; then
CC=clcc
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O"}
fi
else
cc comptest.c
if test $? -eq 0; then
CC=cc
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O"}
cat >comptest.c <<END
#ifndef __GNUC__
Oh darn it's not gcc
#endif
END
cc comptest.c
if test $? -eq 0; then
OPTIMIZE=${OPTIMIZE-"-O2"}
GNUC=1
fi
fi
else
echo "FATAL ERROR: Cannot find a C compiler"
exit
fi
fi
fi
fi
#
# are we using gcc on a 486?
#
if test $GNUC; then
tmp=`uname -m`
if test "x$tmp" = "xi486" -o "x$tmp" = "xi586"; then
OPTIMIZE="$OPTIMIZE -m486"
fi
fi
#
# Figure out how to run CPP
#
cat >comptest.c <<END
#define foo
Make this fail if we actually get compiled
END
$CC -E comptest.c >./1.out
if test $? -eq 0; then
CPP="$CC -E $NEED_OLD_CPP"
else
cpp comptest.c >./1.out
if test $? -eq 0; then
CPP="cpp"
else
$CC -E -traditional-cpp comptest.c >./1.out
if test $? -eq 0; then
CPP="$CC -E -traditional-cpp"
else
echo "FATAL ERROR: Can't figure out how to run the C preprocessor"
exit
fi
fi
fi
#
# Figure out what to use for install
#
mkdir tmp
cat >insttest <<END
whatever
END
rm tmp/insttest
install -f insttest tmp
if test $? -eq 0 && test -f tmp/insttest; then
INSTALL="install -f"
else
rm tmp/insttest
install -c insttest tmp
if test $? -eq 0 && test -f tmp/insttest; then
INSTALL="install -c"
else
INSTALL="cp"
fi
fi
cat >comptest.c <<END
void foo() { }
END
$CC -c comptest.c -o comptest.o
#
# Check if ranlib exists/is needed. Also check ar.
#
cat >comptest.c <<END
int if_you_are_reading_this_you_must_be_bored() { return 1; }
END
$CC -c comptest.c
ar rcu comptest.a comptest.o
if test $? -ne 0; then
echo "FATAL ERROR: Could not find ar."
exit
fi
ranlib comptest.a
if test $? -eq 0; then
RANLIB=ranlib
else
RANLIB=/bin/true
fi
#
# Find yacc/bison/byacc
#
cat >comptest.y <<END
%token FOO
%%
all: FOO
END
bison comptest.y
if test $? -eq 0 && test "$CC" != "xlc"; then
YACC="bison -d -y"
else
byacc comptest.y
if test $? -eq 0; then
YACC="byacc -d"
else
yacc comptest.y
if test $? -eq 0; then
YACC="yacc -d"
else
echo "FATAL ERROR: Could not find bison or yacc."
exit
fi
fi
fi
# Some of these are probably unnecessary
CFLAGS="$CCFLAGS $OSFLAGS $WARN $PROFIL $DEBUG $DEBUG_MACRO $DEBUG_NON_FATAL $STR $PIPE $NEED_OLD_CPP $EXPORT_DYNAMIC"
#
# Determine system type
#
cat >comptest.c <<END
#include <stdio.h>
#include "arch.h"
int main() {
printf("%s\n", ARCH);
}
END
$CC $CFLAGS comptest.c
ARCH=`./$A_OUT`
cat >comptest.c <<END
int main(int argc, char **argv) { return 0; }
END
case $ARCH in
AIX)
OSFLAGS="$OSFLAGS -D_BSD -D_ALL_SOURCE"
CFLAGS="$CFLAGS -D_BSD -D_ALL_SOURCE"
;;
Solaris)
OSFLAGS="$OSFLAGS -DSunOS_5"
CFLAGS="$CFLAGS -DSunOS_5"
;;
esac
#don't use dynamic at the moment
# Linux*)
# EXPORT_DYNAMIC=-rdynamic
# ;;
# FreeBSD)
# cc -export-dynamic comptest.c
# if test $? -eq 0; then
# EXPORT_DYNAMIC=-export-dynamic
# else
# cc -rdynamic comptest.c
# if test $? -eq 0; then
# EXPORT_DYNAMIC=-rdynamic
# fi
# fi
# ;;
#esac
rm $A_OUT
CFLAGS="$CCFLAGS $OSFLAGS $WARN $PROFIL $DEBUG $DEBUG_MACRO $DEBUG_NON_FATAL $STR $PIPE $NEED_OLD_CPP $INCLUDE $EXPORT_DYNAMIC"
if test ! "$OBJDIR" = ""; then
mkdir $OBJDIR
fi
echo SHELL=/bin/sh >>Makefile.tmp
echo OBJDIR=$OBJDIR >>Makefile.tmp
echo DRIVER_BIN=$DRIVER_BIN >>Makefile.tmp
echo PROOF=$PROOF >>Makefile.tmp
echo STRFUNCS=$STRFUNCS >>Makefile.tmp
echo INSTALL=$INSTALL >>Makefile.tmp
echo INSTALL_DIR=$INSTALL_DIR >>Makefile.tmp
echo OPTIMIZE=$OPTIMIZE >>Makefile.tmp
echo CPP=$CPP >>Makefile.tmp
echo CFLAGS=$CFLAGS >>Makefile.tmp
echo CC=$CC >>Makefile.tmp
echo YACC=$YACC >>Makefile.tmp
echo RANLIB=$RANLIB >>Makefile.tmp
echo A=a >>Makefile.tmp
echo O=o >>Makefile.tmp
echo A_OUT=$A_OUT >>Makefile.tmp
echo "***************** Configuration completed **************"
echo "Installing MudOS on $ARCH"
echo
echo "Using $INSTALL to install binaries in $INSTALL_DIR."
echo "Using $CPP for preprocessing."
echo "Using $CC $CFLAGS $OPTIMIZE to compile."
echo "Using $YACC $YFLAGS to make the compiler."
echo "Edit $MAKEFILE if this is not what you want"
echo
echo "Otherwise, type '$MAKE' to build MudOS, then '$MAKE install'."
cat Makefile.tmp ${MAKEFILE}.in >$MAKEFILE
rm Makefile.tmp
if test $MAKEFILE = Makefile; then
cat >GNUmakefile <<END
all:
@echo MudOS is currently configured to use 'Makefile'. Edit 'build.MudOS'
@echo if this is not what you want.
.DEFAULT:
@echo MudOS is currently configured to use 'Makefile'. Edit 'build.MudOS'
@echo if this is not what you want.
nothing:
which_makefile:
echo MakeIsGNU
END
else
cat >Makefile <<END
all:
@echo MudOS is currently configured to use 'GNUmakefile'. Edit 'build.MudOS'
@echo if this is not what you want.
.DEFAULT:
@echo MudOS is currently configured to use 'GNUmakefile'. Edit 'build.MudOS'
@echo if this is not what you want.
nothing:
which_makefile:
echo MakeIsMake
END
fi

View File

@ -0,0 +1,74 @@
@echo off
if "%1" == "develop" echo Preparing to build developmental version of MudOS driver ...
if "%1" == "develop" set OPTIMIZE=-Od
if "%1" == "develop" set DEBUG=-Zi -DDEBUG -W4
if "%1" == "debug" echo Preparing to build debugging version of MudOS driver ...
if "%1" == "debug" set OPTIMIZE=-Od
if "%1" == "debug" set DEBUG=-Zi -DDEBUG -W2
if "%1x" == "x" echo Preparing to build standard MudOS driver ...
if "%1x" == "x" set OPTIMIZE=-Ox
rem define this to be where you want the temporary compiled files to go
rem (use only backslashes here)
set OBJDIR=.\obj
rem change this if you wish the driver binary to be named something else
set DRIVER_BIN=driver
rem Set INSTALL_DIR to the directory where you want to install the executables.
rem (use only backslashes here)
set INSTALL_DIR=..\bin
rem Some of these are probably unnecessary
set CFLAGS=-nologo -MT %DEBUG%
rem Determine system type
set ARCH=Windows 95
if "%OS%" == "Windows_NT" set ARCH=Windows NT
if "%OS%" == "Windows_NT" set CFLAGS=%CFLAGS% -DWINNT
if "%OS%" == "" set CFLAGS=%CFLAGS% -DWIN95
mkdir %OBJDIR%
echo MAKE=NMake >Makefile.tmp
echo SHELL=command.com >>Makefile.tmp
echo OBJDIR=%OBJDIR% >>Makefile.tmp
echo DRIVER_BIN=%DRIVER_BIN% >>Makefile.tmp
echo INSTALL=copy >>Makefile.tmp
echo INSTALL_DIR=%INSTALL_DIR% >>Makefile.tmp
echo OPTIMIZE=%OPTIMIZE% >>Makefile.tmp
echo CPP=cl -E >>Makefile.tmp
echo CFLAGS=%CFLAGS% >>Makefile.tmp
echo CC=cl >>Makefile.tmp
echo YACC=bison -d -y >>Makefile.tmp
echo RANLIB=echo >>Makefile.tmp
echo O=obj >>Makefile.tmp
echo A=lib >>Makefile.tmp
echo EDIT_SOURCE=.\edit_source >>Makefile.tmp
echo EXE=.exe >>Makefile.tmp
echo TAB_EXT=_tab >> Makefile.tmp
echo ***************** Configuration completed **************
echo Installing MudOS on %ARCH%
echo.
echo Using copy to install binaries in %INSTALL_DIR%.
echo Using cl -E for preprocessing.
echo Using cl %CFLAGS% %OPTIMIZE% to compile.
echo Using bison -d -y to make the compiler.
echo Edit Makefile if this is not what you want
echo.
echo Otherwise, type 'nmake' to build MudOS, then 'nmake install'.
type Makefile.tmp > Makefile
type NMakefile.in >> Makefile
del Makefile.tmp
echo wsock32.lib > system_libs
set CFLAGS=
set OBJDIR=
set DRIVER_BIN=
set INSTALL_DIR=
set OPTIMIZE=
set DEBUG=
set ARCH=

View File

@ -0,0 +1,569 @@
#include "std.h"
#include "call_out.h"
#include "backend.h"
#include "comm.h"
#include "port.h"
#include "eoperators.h"
#include "sprintf.h"
#include "eval.h"
#define DBG(x) debug(call_out, x)
/*
* This file implements delayed calls of functions.
* Static functions can not be called this way.
*
* Allocate the structures several in one chunk, to get rid of malloc
* overhead.
*/
#define CHUNK_SIZE 20
typedef struct pending_call_s {
int delta;
union string_or_func function;
object_t *ob;
array_t *vs;
struct pending_call_s *next;
#ifdef THIS_PLAYER_IN_CALL_OUT
object_t *command_giver;
#endif
#ifdef CALLOUT_HANDLES
int handle;
#endif
} pending_call_t;
static pending_call_t *call_list[CALLOUT_CYCLE_SIZE];
static pending_call_t *call_list_free;
static int num_call;
#ifdef CALLOUT_HANDLES
static int unique = 0;
#endif
static void free_call (pending_call_t *);
static void free_called_call (pending_call_t *);
void remove_all_call_out (object_t *);
/*
* Free a call out structure.
*/
static void free_called_call (pending_call_t * cop)
{
cop->next = call_list_free;
if (cop->ob) {
free_string(cop->function.s);
free_object(&cop->ob, "free_call");
} else {
free_funp(cop->function.f);
}
cop->function.s = 0;
#ifdef THIS_PLAYER_IN_CALL_OUT
if (cop->command_giver){
free_object(&cop->command_giver, "free_call");
cop->command_giver = 0;
}
#endif
cop->ob = 0;
call_list_free = cop;
}
INLINE_STATIC void free_call (pending_call_t * cop)
{
if (cop->vs)
free_array(cop->vs);
free_called_call(cop);
}
/*
* Setup a new call out.
*/
#ifdef CALLOUT_HANDLES
int
#else
void
#endif
new_call_out (object_t * ob, svalue_t * fun, int delay,
int num_args, svalue_t * arg)
{
pending_call_t *cop, **copp;
int tm;
if (delay < 0)
delay = 0;
DBG(("new_call_out: /%s delay %i", ob->obname, delay));
if (!call_list_free) {
int i;
call_list_free = CALLOCATE(CHUNK_SIZE, pending_call_t,
TAG_CALL_OUT, "new_call_out: call_list_free");
for (i = 0; i < CHUNK_SIZE - 1; i++)
call_list_free[i].next = &call_list_free[i + 1];
call_list_free[CHUNK_SIZE - 1].next = 0;
num_call += CHUNK_SIZE;
}
cop = call_list_free;
call_list_free = call_list_free->next;
if (fun->type == T_STRING) {
DBG((" function: %s", fun->u.string));
cop->function.s = make_shared_string(fun->u.string);
cop->ob = ob;
add_ref(ob, "call_out");
} else {
DBG((" function: <function>"));
cop->function.f = fun->u.fp;
fun->u.fp->hdr.ref++;
cop->ob = 0;
}
#ifdef THIS_PLAYER_IN_CALL_OUT
cop->command_giver = command_giver; /* save current user context */
if (command_giver)
add_ref(command_giver, "new_call_out"); /* Bump its ref */
#endif
if (num_args > 0) {
cop->vs = allocate_empty_array(num_args);
memcpy(cop->vs->item, arg, sizeof(svalue_t) * num_args);
} else
cop->vs = 0;
/* Find out which slot this one fits in */
tm = (delay + current_time) & (CALLOUT_CYCLE_SIZE - 1);
/* number of cycles */
delay = delay / CALLOUT_CYCLE_SIZE;
DBG(("Current time: %i Executes at: %i Slot: %i Delay: %i",
current_time, current_time + delay, tm, delay));
for (copp = &call_list[tm]; *copp; copp = &(*copp)->next) {
if ((*copp)->delta > delay) {
(*copp)->delta -= delay;
cop->delta = delay;
cop->next = *copp;
*copp = cop;
#ifdef CALLOUT_HANDLES
tm += CALLOUT_CYCLE_SIZE * ++unique;
cop->handle = tm;
return tm;
#else
return;
#endif
}
delay -= (*copp)->delta;
}
*copp = cop;
cop->delta = delay;
cop->next = 0;
#ifdef CALLOUT_HANDLES
tm += CALLOUT_CYCLE_SIZE * ++unique;
cop->handle = tm;
return tm;
#endif
}
/*
* See if there are any call outs to be called. Set the 'command_giver'
* if it is a living object. Check for shadowing objects, which may also
* be living objects.
*/
void call_out()
{
int extra, real_time;
static pending_call_t *cop = 0;
error_context_t econ;
VOLATILE int tm;
current_interactive = 0;
/* could be still allocated if an error occured during a call_out */
if (cop) {
free_called_call(cop);
cop = 0;
}
real_time = get_current_time();
DBG(("Calling call_outs: current_time: %i real_time: %i difference: %i",
current_time, real_time, real_time - current_time));
/* Slowly advance the clock forward towards real_time, doing call_outs
* as we go.
*/
save_context(&econ);
while (1) {
tm = current_time & (CALLOUT_CYCLE_SIZE - 1);
DBG((" slot %i", tm));
while (call_list[tm] && call_list[tm]->delta == 0) {
object_t *ob, *new_command_giver;
/*
* Move the first call_out out of the chain.
*/
cop = call_list[tm];
call_list[tm] = call_list[tm]->next;
ob = (cop->ob ? cop->ob : cop->function.f->hdr.owner);
DBG((" /%s", (ob ? ob->obname : "(null)")));
if (!ob || (ob->flags & O_DESTRUCTED)) {
DBG((" (destructed)"));
free_call(cop);
cop = 0;
} else {
if (SETJMP(econ.context)) {
restore_context(&econ);
if (max_eval_error) {
debug_message("Maximum evaluation cost reached while trying to process call_outs\n");
pop_context(&econ);
return;
}
} else {
object_t *ob;
ob = cop->ob;
#ifndef NO_SHADOWS
if (ob)
while (ob->shadowing)
ob = ob->shadowing;
#endif
new_command_giver = 0;
#ifdef THIS_PLAYER_IN_CALL_OUT
if (cop->command_giver &&
!(cop->command_giver->flags & O_DESTRUCTED)) {
new_command_giver = cop->command_giver;
} else if (ob && (ob->flags & O_LISTENER)) {
new_command_giver = ob;
}
if (new_command_giver)
DBG((" command_giver: /%s", new_command_giver->obname));
#endif
save_command_giver(new_command_giver);
/* current object no longer set */
if (cop->vs) {
array_t *vec = cop->vs;
svalue_t *svp = vec->item + vec->size;
while (svp-- > vec->item) {
if (svp->type == T_OBJECT &&
(svp->u.ob->flags & O_DESTRUCTED)) {
free_object(&svp->u.ob, "call_out");
*svp = const0u;
}
}
/* cop->vs is ref one */
extra = cop->vs->size;
transfer_push_some_svalues(cop->vs->item, extra);
free_empty_array(cop->vs);
} else
extra = 0;
//reset_eval_cost();
set_eval(max_cost);
if (cop->ob) {
if (cop->function.s[0] == APPLY___INIT_SPECIAL_CHAR)
error("Illegal function name\n");
(void) apply(cop->function.s, cop->ob, extra,
ORIGIN_INTERNAL);
} else {
(void) call_function_pointer(cop->function.f, extra);
}
restore_command_giver();
}
free_called_call(cop);
cop = 0;
}
}
/* Ok, no more scheduled call_outs for current_time */
if (current_time < real_time) {
/* Time marches onward! */
if (call_list[tm])
call_list[tm]->delta--;
current_time++;
DBG((" current_time = %i", current_time));
if(!(current_time%HEARTBEAT_INTERVAL))
call_heart_beat();
} else {
/* We're done! */
break;
}
}
DBG(("Done."));
pop_context(&econ);
}
static int time_left (int slot, int delay) {
int current_slot = current_time & (CALLOUT_CYCLE_SIZE - 1);
if (slot >= current_slot) {
return (slot - current_slot) + delay * CALLOUT_CYCLE_SIZE;
} else {
return (slot - current_slot) + (delay + 1) * CALLOUT_CYCLE_SIZE;
}
}
/*
* Throw away a call out. First call to this function is discarded.
* The time left until execution is returned.
* -1 is returned if no call out pending.
*/
int remove_call_out (object_t * ob, const char * fun)
{
pending_call_t **copp, *cop;
int delay;
int i;
if (!ob) return -1;
DBG(("remove_call_out: /%s \"%s\"", ob->obname, fun));
for (i = 0; i < CALLOUT_CYCLE_SIZE; i++) {
delay = 0;
for (copp = &call_list[i]; *copp; copp = &(*copp)->next) {
DBG((" Slot: %i\n", i));
delay += (*copp)->delta;
if ((*copp)->ob == ob && strcmp((*copp)->function.s, fun) == 0) {
cop = *copp;
if (cop->next)
cop->next->delta += cop->delta;
*copp = cop->next;
free_call(cop);
DBG((" found."));
return time_left(i, delay);
}
}
}
DBG((" not found."));
return -1;
}
#ifdef CALLOUT_HANDLES
int remove_call_out_by_handle (int handle)
{
pending_call_t **copp, *cop;
int delay = 0;
DBG(("remove_call_out_by_handle: handle: %i slot: %i",
handle, handle & (CALLOUT_CYCLE_SIZE - 1)));
for (copp = &call_list[handle & (CALLOUT_CYCLE_SIZE - 1)]; *copp; copp = &(*copp)->next) {
delay += (*copp)->delta;
if ((*copp)->handle == handle) {
cop = *copp;
if (cop->next)
cop->next->delta += cop->delta;
*copp = cop->next;
free_call(cop);
return time_left(handle & (CALLOUT_CYCLE_SIZE - 1), delay);
}
}
return -1;
}
int find_call_out_by_handle (int handle)
{
pending_call_t *cop;
int delay = 0;
DBG(("find_call_out_by_handle: handle: %i slot: %i",
handle, handle & (CALLOUT_CYCLE_SIZE - 1)));
for (cop = call_list[handle & (CALLOUT_CYCLE_SIZE - 1)]; cop; cop = cop->next) {
delay += cop->delta;
if (cop->handle == handle)
return time_left(handle & (CALLOUT_CYCLE_SIZE - 1), delay);
}
return -1;
}
#endif
int find_call_out (object_t * ob, const char * fun)
{
pending_call_t *cop;
int delay;
int i;
if (!ob) return -1;
DBG(("find_call_out: /%s \"%s\"", ob->obname, fun));
for (i = 0; i < CALLOUT_CYCLE_SIZE; i++) {
delay = 0;
DBG((" Slot: %i", i));
for (cop = call_list[i]; cop; cop = cop->next) {
delay += cop->delta;
if (cop->ob == ob && strcmp(cop->function.s, fun) == 0)
return time_left(i, delay);
}
}
return -1;
}
int print_call_out_usage (outbuffer_t * ob, int verbose)
{
int i, j;
pending_call_t *cop;
for (i = 0, j = 0; j < CALLOUT_CYCLE_SIZE; j++)
for (cop = call_list[j]; cop; cop = cop->next)
i++;
if (verbose == 1) {
outbuf_add(ob, "Call out information:\n");
outbuf_add(ob, "---------------------\n");
outbuf_addv(ob, "Number of allocated call outs: %8d, %8d bytes\n",
num_call, num_call * sizeof(pending_call_t));
outbuf_addv(ob, "Current length: %d\n", i);
} else {
if (verbose != -1)
outbuf_addv(ob, "call out:\t\t\t%8d %8d (current length %d)\n", num_call,
num_call * sizeof(pending_call_t), i);
}
return num_call * sizeof(pending_call_t);
}
#ifdef DEBUGMALLOC_EXTENSIONS
#ifdef DEBUG
void mark_call_outs()
{
pending_call_t *cop;
int i;
for (i = 0; i < CALLOUT_CYCLE_SIZE; i++) {
for (cop = call_list[i]; cop; cop = cop->next) {
if (cop->vs)
cop->vs->extra_ref++;
if (cop->ob) {
cop->ob->extra_ref++;
EXTRA_REF(BLOCK(cop->function.s))++;
} else {
cop->function.f->hdr.extra_ref++;
}
#ifdef THIS_PLAYER_IN_CALL_OUT
if (cop->command_giver)
cop->command_giver->extra_ref++;
#endif
}
}
}
#endif
#endif
/*
* Construct an array of all pending call_outs. Every item in the array
* consists of 3 items (but only if the object not is destructed):
* 0: The object.
* 1: The function (string).
* 2: The delay.
*/
array_t *get_all_call_outs()
{
int i, j, delay, tm;
pending_call_t *cop;
array_t *v;
for (i = 0, j = 0; j < CALLOUT_CYCLE_SIZE; j++)
for (cop = call_list[j]; cop; cop = cop->next) {
object_t *ob = (cop->ob ? cop->ob : cop->function.f->hdr.owner);
if (ob && !(ob->flags & O_DESTRUCTED))
i++;
}
v = allocate_empty_array(i);
tm = current_time & (CALLOUT_CYCLE_SIZE-1);
for (i = 0, j = 0; j < CALLOUT_CYCLE_SIZE; j++) {
delay = 0;
for (cop = call_list[j]; cop; cop = cop->next) {
array_t *vv;
object_t *ob;
delay += cop->delta;
ob = (cop->ob ? cop->ob : cop->function.f->hdr.owner);
if (!ob || (ob->flags & O_DESTRUCTED))
continue;
vv = allocate_empty_array(3);
if (cop->ob) {
vv->item[0].type = T_OBJECT;
vv->item[0].u.ob = cop->ob;
add_ref(cop->ob, "get_all_call_outs");
vv->item[1].type = T_STRING;
vv->item[1].subtype = STRING_SHARED;
vv->item[1].u.string = make_shared_string(cop->function.s);
} else {
outbuffer_t tmpbuf;
svalue_t tmpval;
tmpbuf.real_size = 0;
tmpbuf.buffer = 0;
tmpval.type = T_FUNCTION;
tmpval.u.fp = cop->function.f;
svalue_to_string(&tmpval, &tmpbuf, 0, 0, 0);
vv->item[0].type = T_OBJECT;
vv->item[0].u.ob = cop->function.f->hdr.owner;
add_ref(cop->function.f->hdr.owner, "get_all_call_outs");
vv->item[1].type = T_STRING;
vv->item[1].subtype = STRING_SHARED;
vv->item[1].u.string = make_shared_string(tmpbuf.buffer);
FREE_MSTR(tmpbuf.buffer);
}
vv->item[2].type = T_NUMBER;
vv->item[2].u.number = time_left(j, delay);
v->item[i].type = T_ARRAY;
v->item[i++].u.arr = vv; /* Ref count is already 1 */
}
}
return v;
}
void
remove_all_call_out (object_t * obj)
{
pending_call_t **copp, *cop;
int i;
for (i = 0; i < CALLOUT_CYCLE_SIZE; i++) {
copp = &call_list[i];
while (*copp) {
if ( ((*copp)->ob &&
(((*copp)->ob == obj) || ((*copp)->ob->flags & O_DESTRUCTED))) ||
(!(*copp)->ob &&
((*copp)->function.f->hdr.owner == obj ||
!(*copp)->function.f->hdr.owner ||
(*copp)->function.f->hdr.owner->flags & O_DESTRUCTED)) )
{
cop = *copp;
if (cop->next)
cop->next->delta += cop->delta;
*copp = cop->next;
free_call(cop);
} else
copp = &(*copp)->next;
}
}
}
void reclaim_call_outs() {
pending_call_t *cop;
int i;
remove_all_call_out(0); /* removes call_outs to destructed objects */
#ifdef THIS_PLAYER_IN_CALL_OUT
for (i = 0; i < CALLOUT_CYCLE_SIZE; i++) {
cop = call_list[i];
while (cop) {
if (cop->command_giver && (cop->command_giver->flags & O_DESTRUCTED)) {
free_object(&cop->command_giver, "reclaim_call_outs");
cop->command_giver = 0;
}
cop = cop->next;
}
}
#endif
}

View File

@ -0,0 +1,26 @@
#ifndef CALL_OUT_H
#define CALL_OUT_H
#include "lpc_incl.h"
/*
* call_out.c
*/
void call_out (void);
void reclaim_call_outs (void);
#ifdef CALLOUT_HANDLES
int find_call_out_by_handle (int);
int remove_call_out_by_handle (int);
int new_call_out (object_t *, svalue_t *, int, int, svalue_t *);
#else
void new_call_out (object_t *, svalue_t *, int, int, svalue_t *);
#endif
int remove_call_out (object_t *, const char *);
void remove_all_call_out (object_t *);
int find_call_out (object_t *, const char *);
array_t *get_all_call_outs (void);
int print_call_out_usage (outbuffer_t *, int);
void mark_call_outs (void);
void reclaim_call_outs (void);
#endif

84
fluffos-2.23-ds03/class.c Normal file
View File

@ -0,0 +1,84 @@
#include "std.h"
#include "lpc_incl.h"
#ifdef CLASS_STATS
int num_classes;
int total_class_size;
#endif
void dealloc_class (array_t * p) {
int i;
#ifdef CLASS_STATS
num_classes--;
total_class_size -= sizeof(array_t) + sizeof(svalue_t) * (p->size - 1);
#endif
for (i = p->size; i--;)
free_svalue(&p->item[i], "dealloc_class");
FREE((char *) p);
}
void free_class (array_t * p)
{
if (--(p->ref) > 0)
return;
dealloc_class(p);
}
array_t *allocate_class (class_def_t * cld, int has_values) {
array_t *p;
int n = cld->size;
if(!n)
n++;
#ifdef CLASS_STATS
num_classes++;
total_class_size += sizeof(array_t) + sizeof(svalue_t) * (n - 1);
#endif
p = (array_t *)DXALLOC(sizeof(array_t) + sizeof(svalue_t) * (n - 1), TAG_CLASS, "allocate_class");
n = cld->size;
p->ref = 1;
p->size = n;
if (has_values) {
while (n--)
p->item[n] = *sp--;
} else {
while (n--)
p->item[n] = const0;
}
return p;
}
array_t *allocate_class_by_size (int size) {
array_t *p;
#ifdef CLASS_STATS
num_classes++;
total_class_size += sizeof(array_t) + sizeof(svalue_t) * (size - 1);
#endif
p = (array_t *)DXALLOC(sizeof(array_t) + sizeof(svalue_t) * (size - 1), TAG_CLASS, "allocate_class");
p->ref = 1;
p->size = size;
while (size--)
p->item[size] = const0;
return p;
}
array_t *allocate_empty_class_by_size (int size) {
array_t *p;
#ifdef CLASS_STATS
num_classes++;
total_class_size += sizeof(array_t) + sizeof(svalue_t) * (size - 1);
#endif
p = (array_t *)DXALLOC(sizeof(array_t) + sizeof(svalue_t) * (size - 1), TAG_CLASS, "allocate_class");
p->ref = 1;
p->size = size;
return p;
}

19
fluffos-2.23-ds03/class.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef CLASS_H
#define CLASS_H
/* It is usually better to include "lpc_incl.h" instead of including this
directly */
#ifdef CLASS_STATS
extern int num_classes;
extern int total_class_size;
#endif
void dealloc_class (array_t *);
void free_class (array_t *);
array_t *allocate_class (class_def_t *, int);
array_t *allocate_class_by_size (int);
array_t *allocate_empty_class_by_size (int);
#endif

3347
fluffos-2.23-ds03/comm.c Normal file

File diff suppressed because it is too large Load Diff

226
fluffos-2.23-ds03/comm.h Normal file
View File

@ -0,0 +1,226 @@
/*
* comm.h -- definitions and prototypes for comm.c
*
*/
#ifndef COMM_H
#define COMM_H
#ifdef HAVE_ZLIB
#include <zlib.h>
#endif
#include "lpc_incl.h"
#include "network_incl.h"
#include "fliconv.h"
#define MAX_TEXT 2048
#define MAX_SOCKET_PACKET_SIZE 1024
#define DESIRED_SOCKET_PACKET_SIZE 800
#define MESSAGE_BUF_SIZE MESSAGE_BUFFER_SIZE /* from options.h */
#define OUT_BUF_SIZE 2048
#define DFAULT_PROTO 0 /* use the appropriate protocol */
#define I_NOECHO 0x1 /* input_to flag */
#define I_NOESC 0x2 /* input_to flag */
#define I_SINGLE_CHAR 0x4 /* get_char */
#define I_WAS_SINGLE_CHAR 0x8 /* was get_char */
#define SB_SIZE (NSLC * 3 + 3)
#ifdef MINGW
#define SIGPIPE 13
#endif
#ifdef HAVE_ZLIB
#define COMPRESS_BUF_SIZE MESSAGE_BUF_SIZE
#endif
enum msgtypes {
NAMEBYIP = 0, IPBYNAME, DATALEN
};
#define TS_DATA 0
#define TS_IAC 1
#define TS_WILL 2
#define TS_WONT 3
#define TS_DO 4
#define TS_DONT 5
#define TS_SB 6
#define TS_SB_IAC 7
/* The I_* flags are input_to flags */
#define NOECHO I_NOECHO /* don't echo lines */
#define NOESC I_NOESC /* don't allow shell out */
#define SINGLE_CHAR I_SINGLE_CHAR /* get_char */
#define WAS_SINGLE_CHAR I_WAS_SINGLE_CHAR
#define HAS_PROCESS_INPUT 0x0010 /* interactive object has process_input() */
#define HAS_WRITE_PROMPT 0x0020 /* interactive object has write_prompt() */
#define CLOSING 0x0040 /* true when closing this file descriptor */
#define CMD_IN_BUF 0x0080 /* there is a full command in input buffer */
#define NET_DEAD 0x0100
#define NOTIFY_FAIL_FUNC 0x0200 /* default_err_mesg is a function pointer */
#define USING_TELNET 0x0400 /* they're using telnet, or something that */
/* understands telnet codes */
#define SKIP_COMMAND 0x0800 /* skip current command */
#define SUPPRESS_GA 0x1000 /* suppress go ahead */
#define USING_LINEMODE 0x2000 /* we've negotiated linemode */
#define USING_MXP 0x4000 /* we've negotiated mxp */
#define USING_ZMP 0x8000 /* we've negotiated zmp */
#define USING_GMCP 0x10000 /* we've negotiated gmcp */
typedef struct interactive_s {
object_t *ob; /* points to the associated object */
#if defined(F_INPUT_TO) || defined(F_GET_CHAR)
sentence_t *input_to; /* to be called with next input line */
svalue_t *carryover; /* points to args for input_to */
int num_carry; /* number of args for input_to */
#endif
int connection_type; /* the type of connection this is */
int fd; /* file descriptor for interactive object */
#ifdef IPV6
struct sockaddr_in6 addr; /* socket address of interactive object */
#else
struct sockaddr_in addr; /* socket address of interactive object */
#endif
#ifdef F_QUERY_IP_PORT
int local_port; /* which of our ports they connected to */
#endif
#ifdef F_NETWORK_STATS
int external_port; /* external port index for connection */
#endif
const char *prompt; /* prompt string for interactive object */
char text[MAX_TEXT]; /* input buffer for interactive object */
int text_end; /* first free char in buffer */
int text_start; /* where we are up to in user command buffer */
int last_time; /* time of last command executed */
#ifndef NO_SNOOP
object_t *snooped_by;
#endif
#ifndef NO_ADD_ACTION
/* this or What ? is printed when error */
union string_or_func default_err_message;
#endif
#ifdef TRACE
int trace_level; /* debug flags -- 0 means no debugging */
char *trace_prefix; /* trace only object which has this as name */
#endif
#ifdef OLD_ED
struct ed_buffer_s *ed_buffer; /* local ed */
#endif
#ifdef HAVE_ZLIB
struct z_stream_s* compressed_stream; /* Is the data stream
compressed or not */
unsigned char compress_buf[COMPRESS_BUF_SIZE]; /* compress message buffer*/
#endif
int message_producer; /* message buffer producer index */
int message_consumer; /* message buffer consumer index */
int message_length; /* message buffer length */
char message_buf[MESSAGE_BUF_SIZE]; /* message buffer */
int iflags; /* interactive flags */
char out_of_band; /* Send a telnet sync operation */
int state; /* Current telnet state. Bingly wop */
int sb_pos; /* Telnet suboption negotiation stuff */
struct translation *trans;
char *sb_buf;
int sb_size;
char slc[NSLC][2];
} interactive_t;
/*
* This macro is for testing whether ip is still valid, since many
* functions call LPC code, which could otherwise use
* enable_commands(), set_this_player(), or destruct() to cause
* all hell to break loose by changing or dangling command_giver
* or command_giver->interactive. It also saves us a few dereferences
* since we know we can trust ip, and also increases code readability.
*
* Basically, this should be used as follows:
*
* (1) when using command_giver:
* set a variable named ip to command_giver->interactive at a point
* when you know it is valid. Then, after a call that might have
* called LPC code, check IP_VALID(command_giver), or use
* VALIDATE_IP.
* (2) some other object:
* set a variable named ip to ob->interactive, and save ob somewhere;
* or if you are just dealing with an ip as input, save ip->ob somewhere.
* After calling LPC code, check IP_VALID(ob), or use VALIDATE_IP.
*
* Yes, I know VALIDATE_IP uses a goto. It's due to C's lack of proper
* exception handling. Only use it in subroutines that are set up
* for it (i.e. define a failure label, and are set up to deal with
* branching to it from arbitrary points).
*/
#define IP_VALID(ip, ob) (ob && ip && ob->interactive == ip)
#define VALIDATE_IP(ip, ob) if (!IP_VALID(ip, ob)) goto failure
/*
* comm.c
*/
extern fd_set readmask;
extern fd_set writemask;
extern int inet_packets;
extern int inet_volume;
#ifdef F_NETWORK_STATS
extern int inet_out_packets;
extern int inet_out_volume;
extern int inet_in_packets;
extern int inet_in_volume;
#ifdef PACKAGE_SOCKETS
extern int inet_socket_in_packets;
extern int inet_socket_in_volume;
extern int inet_socket_out_packets;
extern int inet_socket_out_volume;
#endif
#endif
extern int num_user;
#ifdef F_SET_HIDE
extern int num_hidden_users;
#endif
extern int add_message_calls;
extern interactive_t **all_users;
extern int max_users;
#ifdef HAS_CONSOLE
extern int has_console;
extern void restore_sigttin(void);
#endif
void CDECL add_vmessage (object_t *, const char *, ...);
void add_message (object_t *, const char *, int);
void add_binary_message (object_t *, const unsigned char *, int);
#ifdef SIGNAL_FUNC_TAKES_INT
void sigalrm_handler (int);
#else
void sigalrm_handler (void);
#endif
void update_ref_counts_for_users (void);
INLINE void make_selectmasks (void);
void init_user_conn (void);
void init_addr_server (char *, int);
void ipc_remove (void);
void set_prompt (const char *);
INLINE void process_io (void);
int process_user_command (void);
int replace_interactive (object_t *, object_t *);
int set_call (object_t *, sentence_t *, int);
void remove_interactive (object_t *, int);
int flush_message (interactive_t *);
int query_addr_number (const char *, svalue_t *);
char *query_ip_name (object_t *);
const char *query_ip_number (object_t *);
char *query_host_name (void);
int query_idle (object_t *);
#ifndef NO_SNOOP
int new_set_snoop (object_t *, object_t *);
object_t *query_snoop (object_t *);
object_t *query_snooping (object_t *);
#endif
#ifdef DEBUGMALLOC_EXTENSIONS
void mark_iptable (void);
#endif
#endif /* COMM_H */

View File

@ -0,0 +1,50 @@
#!/usr/local/bin/perl -pi
# Beek - 970910
# Perl, as a language, is far from my favorite. However, this task is
# a good example of the kind of thing it is great at. It would be hard
# to express this anywhere nearly as concisely in any other language.
# Note: This script isn't guaranteed to get things 100% correct, but it
# does do a pretty good job of guessing what is meant, and the remaining
# cases shouldn't be hard to fix by hand.
#
# As an example, it gets every instance of 'static' in the Lima mudlib
# correct (all 513 of them!).
#
# Example usage:
#
# find mudlib -name "*.c" -print | xargs /path/to/this/script
# Note that there is no checking whether things appear in quotes, which is
# probably the most likely way this can mess up.
#
# if it contains an open (, which is not part of a ({, ([, or (:, then it
# is a function prototype or definition
#
# Note: this is wrong for initializers that contain (. For example
# static object this = this_object(); Perhaps we should handle =
# first ...
if (/\([^{[:]/) {
s/static/protected/;
}
# commas and assignments are pretty clear indictations of variables. Note
# that we don't have to worry about commas in argument lists since we have
# already handled lines with (, which must appear between static and any comma.
elsif (/,/ || /=/) {
s/static/nosave/;
}
# static with a ; on the same line implies the entire line is here. If it
# was a prototype, it had a (. Must be a variable.
elsif (/;/) {
s/static/nosave/;
}
# This handles the common practice of doing things like:
#
# static
# void create() {
#
# which is more common than most other uses of static alone on a line
else {
s/static/protected/;
}

View File

@ -0,0 +1,60 @@
string parser_error_message(int kind, object ob, mixed arg, int flag) {
string ret;
if (ob)
ret = ob->short() + ": ";
else
ret = "";
switch (kind) {
case 1:
if (flag)
return ret + "There is no such " + arg + " here.\n";
else
return ret + "There is no " + arg + " here.\n";
break;
case 2:
if (flag)
return ret + "None of the " + pluralize(arg) + " are alive.\n";
else
return ret + "The " + arg + " isn't alive.\n";
break;
case 3:
if (flag)
return ret + "You can't reach them.\n";
else
return ret + "You can't reach it.\n";
break;
case 4:
{
array descs = unique_array(arg, (: $1->the_short() :));
string str;
if (sizeof(descs) == 1)
return ret + "Which " + descs[0][0]->short() + " do you mean?\n";
str = ret + "Do you mean ";
for (int i = 0; i < sizeof(descs); i++) {
if (sizeof(descs[i]) > 1)
str += "one of ";
str += descs[i][0]->the_short();
if (i == sizeof(descs) - 1)
str += " or ";
else
str += ", ";
}
return str + "?\n";
}
break;
case 5:
if (arg > 1)
return ret + "There are only " + arg + " of them.\n";
else
return ret + "There is only one of them.\n";
break;
case 6:
return ret + arg;
case 7:
return ret + "There is no " + arg + " here.\n";
case 8:
return ret + "You can't use more than one object at a time with that verb.\n";
}
}

View File

@ -0,0 +1,9 @@
/* Like evaluate(), but expand out an array of arguments. No longer necessary
because of the ... syntax */
mixed apply(mixed f, mixed *arr...) {
if (sizeof(arr) && arrayp(arr[<1]))
arr = arr[0..<2] + arr[<1];
return evaluate(f, arr...);
}

View File

@ -0,0 +1,21 @@
void break_string(string str, int width, mixed indent) {
int indlen;
if (!stringp(str)) return 0;
if (intp(indent)) {
if (ident < 0) indent = 0;
indlen = indent;
indent = sprintf("%-*' 's", indlen, "");
} else if (stringp(indent)) {
indlen = strlen(ident);
} else return str;
if (width < indlen + 1) width = indlen + 1;
str = sprintf("%*-=s", width - indlen, str);
if (!indlen) return str;
if (str[<1] == '\n')
return indent + replace_string(str[0..<2], "\n", "\n" + indent) + "\n";
else
return indent + replace_string(str, "\n", "\n" + indent);
}

View File

@ -0,0 +1,12 @@
string dump_socket_status() {
string ret = @END
Fd State Mode Local Address Remote Address
-- --------- -------- --------------------- ---------------------
END;
foreach (array item in socket_status()) {
ret += sprintf("%2d %|9s %|8s %-21s %-21s\n", item[0], item[1], item[2], item[3], item[4]);
}
return ret;
}

View File

@ -0,0 +1,699 @@
private mixed *ret;
private mixed value;
private void
load_lpc_info(int ix, object ob)
{
mixed *tmp, *sing;
value ret;
int il, make_plural = 0;
string str;
if (!ob)
return;
if (pluid_list &&
sizeof(pluid_list) > ix &&
pluid_list[ix] == 0) {
ret = ob->parse_command_plural_id_list();
if (arrayp(ret))
pluid_list[ix] = ret;
else {
make_plural = 1;
pluid_list[ix] = 1;
}
}
if (id_list &&
sizeof(id_list) > ix &&
id_list[ix] == 0 &&
ob) {
ret = ob->parse_command_id_list();
if (arrayp(ret)) {
id_list[ix] = ret;
if (make_plural)
pluid_list[ix] = map(ret, (: stringp($1) ? pluralize($1) : 0 :));
} else {
id_list[ix] = 1;
}
}
if (adjid_list &&
sizeof(adjid_list) > ix &&
adjid_list[ix] == 0 &&
ob) {
ret = ob->parse_command_adjectiv_id_list();
if (arrayp(ret))
adjid_list[ix] = ret;
else
adjid_list[ix] = 1;
}
}
mixed *parse_command(string cmd, mixed obarr, string pattern) {
mixed *saved_ret = ret, *cret;
ret = ({ });
/* pattern and command cannot be empty */
if (cmd == "" || pattern = "") return ({ });
if (!stringp(cmd)) error("Bad argument 1 to parse_command().\n");
if (!stringp(pattern)) error("Bad argument 3 to parse_command().\n");
/* array of words in command */
parse_warr = explode(cmd, " ");
/* array of pattern elements */
parse_patarr = explode(pattern, " ");
#ifndef __NO_ENVIRONMENT__
if (objectp(obarr))
obarr = ({ obarr }) + deep_inventory(obarr);
#endif
if (!arrayp(obarr)) error("Bad argument 2 to parse_command().\n");
id_list = allocate(sizeof(obarr));
pluid_list = allocate(sizeof(obarr));
adjid_list = allocate(sizeof(obarr));
id_list_d = master()->parse_command_id_list();
pluid_list_d = master()->parse_command_plural_id_list();
adjid_list_d = master()->parse_command_adjectiv_id_list();
prepos_list = master()->parse_command_prepos_list();
allword = master()->parse_command_all_word();
/*
* Loop through the pattern. Handle %s but not '/'
*/
for (six = 0, cix = 0, pix = 0; pix < sizeof(parse_patarr); pix++) {
value = 0;
fail = 0;
if (parse_patarr[pix] == "%s") {
/*
* We are at end of pattern, scrap up the remaining words and put
* them in the fill-in value.
*/
if (pix == sizeof(parse_patarr - 1)) {
store_words_slice(six++, parse_warr, cix, sizeof(parse_warr) - 1);
cix = sizeof(parse_warr);
} else {
/*
* There is something after %s, try to parse with the next
* pattern. Begin with the current word and step one word for
* each fail, until match or end of words.
*/
ocix = fword = cix; /* current word */
fpix = ++pix; /* pix == next pattern */
do {
/*
* Parse the following pattern, fill-in values:
* stack_args[six] = result of %s stack_args[six + 1] =
* result of following pattern, if it is a fill-in
* pattern
*/
fail = sub_parse(obarr, parse_patarr, ref pix,
parse_warr, ref cix);
if (fail) {
cix = ++ocix;
pix = fpix;
}
} while (fail && (cix < sizeof(parse_warr)));
/*
* We found something mathing the pattern after %s. First
* stack_args[six + 1] = result of match Then stack_args[six]
* = the skipped words before match
*/
if (!fail) {
if (value) { /* A match with a value fill in param */
store_value(six + 1, value);
store_words_slice(six, parse_warr, fword, ocix - 1);
six += 2;
} else { /* A match with a non value ie 'word' */
store_words_slice(six++, parse_warr, fword, ocix - 1);
}
value = 0;
}
}
}
/*
* The pattern was not %s, parse the pattern if it is not '/', a '/'
* here is skipped. If match, put in fill-in value.
*/
else if (parse_patarr[pix] != "/") {
fail = sub_parse(obarr, parse_patarr, ref pix,
parse_warr, ref cix, ref fail);
if (!fail && value)
store_value(six++, value);
}
/*
* Terminate parsing if no match
*/
if (fail)
break;
}
/*
* Also fail when there is words left to parse and pattern exhausted
*/
if (fail || cix < sizeof(parse_warr))
return 0;
cret = ret;
ret = saved_ret;
return cret;
}
private void
store_value(int pos, mixed what) {
if (sizeof(ret) <= pos)
ret += allocate(ret + 1 - pos);
ret[pos] = what;
}
static void
store_words_slice(int pos, mixed *warr, int from, int to) {
mixed *slice = warr[from..to];
store_value(pos, implode(slice, " "));
}
private static int
sub_parse(mixed *obarr, mixed *patarr, int ref pix_in,
mixed *warr, int ref cix_in)
{
int cix, pix;
int fail;
/*
* Fail if we have a pattern left but no words to parse
*/
if (*cix_in == sizeof(warr))
return 1;
cix = *cix_in;
pix = *pix_in;
fail = one_parse(obarr, patarr[pix], warr, ref cix);
while (fail) {
pix++;
cix = *cix_in;
/*
* Find the next alternative pattern, consecutive '/' are skipped
*/
while (pix < sizeof(patarr) && patarr[pix] == "/") {
pix++;
fail = 0;
}
if (!fail && pix < sizeof(patarr)) {
fail = one_parse(obarr, patarr[pix], warr, ref cix);
} else {
*pix_in = pix - 1;
return 1;
}
}
/*
* If there is alternatives left after the mathing pattern, skip them
*/
if (pix + 1 < sizeof(patarr) && patarr[pix+1] == "/") {
while (pix + 1 < sizeof(patarr) && patarr[pix+1] == "/") {
pix += 2;
}
if (pix >= sizeof(patarr))
pix = sizeof(patarr->size);
}
*cix_in = cix;
*pix_in = pix;
return fail;
}
private int
one_parse(mixed *obarr, string pat, mixed *warr, int ref cix_in)
{
int ch, fail;
string str1, str2;
/*
* Fail if we have a pattern left but no words to parse
*/
if (*cix_in >= sizeof(warr))
return 1;
ch = pat[0];
if (ch == '%')
ch = pat[1];
switch (ch) {
case 'i':
case 'I':
fail = item_parse(obarr, warr, cix_in);
break;
#ifndef __NO_ADD_ACTION__
case 'l':
case 'L':
fail = living_parse(obarr, warr, cix_in);
break;
#endif
case 's':
case 'S':
value = 0;
fail = 0;
break;
case 'w':
case 'W':
value = warr[*cix_in];
(*cix_in)++;
fail = 0;
break;
case 'o':
case 'O':
fail = single_parse(obarr, warr, cix_in);
break;
case 'p':
case 'P':
fail = prepos_parse(warr, cix_in);
break;
case 'd':
case 'D':
fail = number_parse(obarr, warr, cix_in);
break;
case '\'':
str1 = pat[1..<2];
str2 = warr[*cix_in];
if (pat[<1] == '\'' && str1 == str2) {
fail = 0;
(*cix_in)++;
} else
fail = 1;
break;
case '[':
str1 = pat[1..<2];
str2 = warr[*cix_in];
if (str1 == str2)
(*cix_in)++;
fail = 0;
break;
default:
fail = 0; /* Skip invalid patterns */
}
return fail;
}
string *ord1 = ({"", "first", "second", "third", "fourth", "fifth",
"sixth", "seventh", "eighth", "nineth", "tenth",
"eleventh", "twelfth", "thirteenth", "fourteenth",
"fifteenth", "sixteenth", "seventeenth",
"eighteenth", "nineteenth" });
string *ord10 = ({"", "", "twenty", "thirty", "forty", "fifty", "sixty",
"seventy", "eighty", "ninety"});
string *sord10 = ({"", "", "twentieth", "thirtieth", "fortieth",
"fiftieth", "sixtieth", "seventieth", "eightieth",
"ninetieth"});
string *num1 = ({"", "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"});
string *num10 = ({"", "", "twenty", "thirty", "forty", "fifty", "sixty",
"seventy", "eighty", "ninety"});
private int
number_parse(mixed *obarr, mixed *warr, int ref cix_in) {
int cix, ten, ones, num;
string buf;
cix = *cix_in;
if (sscanf(warr[cix], "%d", num)) {
if (num >= 0) {
(*cix_in)++;
value = num;
return 0;
}
return 1; /* only nonnegative numbers */
}
if (warr[cix] == allword) {
(*cix_in)++;
value = 0;
return 0;
}
/* This next double loop is incredibly stupid. -Beek */
for (ten = 0; ten < 10; ten++)
for (ones = 0; ones < 10; ones++) {
buf = num10[ten] + (ten > 1 ? num1[ones] : num1[ten * 10 + ones]);
if (buf == warr[cix]) {
(*cix_in)++;
value = ten * 10 + ones;
return 0;
}
}
/* this one too */
for (ten = 0; ten < 10; ten++)
for (ones = 0; ones < 10; ones++) {
buf = (ones ? ord10[ten] : sord10[ten]) + (ten > 1 ? ord1[ones] : ord1[ten*10 + ones]);
if (buf == warr[cix]) {
(*cix_in)++;
value = -(ten * 10 + ones);
return 0;
}
}
return 1;
}
private int
item_parse(mixed *obarr, mixed *warr, int ref cix_in) {
mixed *tmp, *ret;
int cix, tix, obix, plur_flag, max_cix, match_all;
tmp = allocate(sizeof(obarr) + 1);
if (!number_parse(obarr, warr, cix_in)) {
tmp[0] = value;
match_all = (value == 0);
plur_flag = (match_all || value > 1);
have_number = 1;
value = 0;
} else {
plur_flag = 0;
match_all = 0;
}
for (max_cix = *cix_in, tix = 1, obix = 0; obix < sizeof(obarr); obix++) {
cix = *cix_in;
if (!objectp(obarr[obix]))
continue;
if (cix == sizeof(warr) && match_all) {
tmp[tix++] = obarr[obix];
continue;
}
load_lpc_info(obix, obarr[obix]);
if (match_object(obix, warr, ref cix, ref plur_flag)) {
tmp[tix++] = obarr[obix];
max_cix = (max_cix < cix) ? cix : max_cix;
}
}
if (tix < 2) {
if (have_number)
(*cix_in)--;
return 1;
} else {
if (*cix_in < sizeof(warr))
*cix_in = max_cix + 1;
if (!have_number)
tmp[0] = !plur_flag;
value = tmp[0..tix-1];
return 0;
}
}
#ifndef __NO_ADD_ACTION__
private int
living_parse(mixed *obarr, array warr, int ref cix_in, int ref fail)
{
mixed *live;
object ob;
int obix, tix;
live = allocate(sizeof(obarr));
tix = 0;
for (obix = 0; obix < sizeof(obarr); obix++)
if (living(obarr[obix]))
live[tix++] = obarr[obix];
if (tix && !item_parse(live, warr, cix_in))
return 0;
ob = find_player(warr[*cix_in]);
if (!ob)
ob = find_living(warr[*cix_in]);
if (ob) {
value = ob;
(*cix_in)++;
return 0;
}
return 1;
}
#endif
private int
single_parse(mixed *obarr, mixed *warr, int ref cix_in)
{
int cix, obix, plur_flag;
for (obix = 0; obix < sizeof(obarr); obix++) {
cix = *cix_in;
if (objectp(obarr[obix]))
load_lpc_info(obix, obarr[obix]);
plur_flag = 0;
if (match_object(obix, warr, ref cix, ref plur_flag)) {
*cix_in = cix + 1;
value = obarr[obix];
return 0;
}
}
return 1;
}
private int
prepos_parse(mixed *warr, int ref cix_in, mixed prepos) {
mixed *tarr;
string tmp;
int pix, tix;
if (!prepos || !arrayp(prepos))
prepos = prepos_list;
for (pix = 0; pix < sizeof(prepos); pix++) {
if (!stringp(prepos[pix]))
continue;
tmp = prepos[pix];
if (member_array(' ', tmp) == -1) {
if (tmp == warr[*cix_in]) {
(*cix_in)++;
break;
}
} else {
tarr = explode(tmp, " ");
if (*cix_in + sizeof(tarr) <= sizeof(warr)) {
for (tix = 0; tix < sizeof(tarr); tix++) {
if (*cix_in + tix >= sizeof(warr) ||
warr[*cix_in + tix] != tarr[tix])
break;
}
if (tix == sizeof(tarr)) {
(*cix_in) += sizeof(tarr);
break;
}
}
}
}
if (pix == sizeof(prepos)) {
value = 0;
return 1;
} else {
value = prepos[pix];
return 0;
}
}
private int
match_object(int obix, mixed *warr, int ref cix_in, int ref plur) {
mixed *ids;
int il, pos, cplur, old_cix;
string str;
for (cplur = (*plur * 2); cplur < 4; cplur++) {
switch (cplur) {
case 0:
if (!id_list_d)
continue;
ids = id_list_d;
break;
case 1:
if (!d_list ||
sizeof(id_list) <= obix ||
!arrayp(id_list[obix]))
continue;
ids = id_list[obix];
break;
case 2:
if (!pluid_list_d)
continue;
ids = pluid_list_d;
break;
case 3:
if (!pluid_list ||
sizeof(gpluid_list) <= obix ||
!arrayp(gpluid_list[obix]))
continue;
ids = pluid_list[obix];
break;
default:
ids = 0;
}
for (il = 0; il < sizeof(ids); il++) {
if (stringp(ids[il])) {
str = ids[il]; /* A given id of the object */
old_cix = *cix_in;
if ((pos = find_string(str, warr, cix_in)) >= 0) {
if (pos == old_cix) {
if (cplur > 1)
*plur = 1;
return 1;
} else if (check_adjectiv(obix, warr, old_cix, pos - 1)) {
if (cplur > 1)
*plur = 1;
return 1;
}
}
*cix_in = old_cix;
}
}
}
return 0;
}
static int
find_string(string str, mixed *warr, int ref cix_in)
{
int fpos;
string p1;
mixed *split;
for (; *cix_in < warr->size; (*cix_in)++) {
p1 = warr[*cix_in];
if (p1 == str) /* str was one word and we found it */
return *cix_in;
if (member_array(' ', str) == -1)
continue;
/*
* If str was multi word we need to make some special checks
*/
if (*cix_in == sizeof(warr->size) - 1)
continue;
split = explode(str, " ");
/*
* warr->size - *cix_in ==
* 2: One extra word
* 3: Two extra words
*/
if (sizeof(split) > sizeof(warr) - *cix_in)
continue;
fpos = *cix_in;
for (; (*cix_in - fpos) < sizeof(split); (*cix_in)++) {
if (split[*cix_in - fpos] == warr[*cix_in])
break;
}
if ((*cix_in - fpos) == sizeof(split))
return fpos;
*cix_in = fpos;
}
return -1;
}
private int
check_adjectiv(int obix, mixed *warr, int from, int to)
{
int il, back, fail;
string adstr;
mixed *ids;
if (arrayp(adjid_list[obix]))
ids = adjid_list[obix];
else
ids = 0;
for (fail = 0, il = from; il <= to; il++) {
if ((member_array(warr[il], ids) < 0) &&
(member_array(warr[il], adjid_list_d) < 0))
fail = 1;
}
/*
* Simple case: all adjs were single word
*/
if (!fail)
return 1;
if (from == to)
return 0;
/*
* If we now have: "adj1 adj2 adj3 ... adjN"
* We must test in order: "adj1 adj2 adj3 .... adjN-1 adjN"
"adj1 adj2 adj3 .... adjN-1"
"adj1 adj2 adj3 ...."
....
* if match for adj1 .. adj3 continue with:
* "adj4 adj5 .... adjN-1 adjN"
* "adj4 adj5 .... adjN-1"
* "adj4 adj5 ...."
* .....
*/
for (il = from; il <= to;) { /* adj1 .. adjN */
for (back = to; back >= il; back--) { /* back from adjN to adj[il] */
/*
* Create teststring with "adj[il] .. adj[back]"
*/
adstr = "";
for (sum = il; sum <= back; sum++) { /* test "adj[il] ..
* adj[back]" */
if (sum > il)
adstr += " ";
adstr += warr[sum];
}
if ((member_array(adstr, ids) < 0) &&
(member_array(adstr, adjid_list_d) < 0))
continue;
else {
il = back + 1; /* Match "adj[il] adj[il+1] .. adj[back]" */
back = to;
break;
}
}
if (back < to)
return 0;
}
return 1;
}

View File

@ -0,0 +1,40 @@
mixed process_value(string func) {
int tmp;
string arg;
object obj;
mixed ret;
if (!func || !stringp(func))
return 0;
if ((tmp = member_array('|', func)) != -1) {
arg = func[tmp+1..];
func = func[0..tmp-1];
}
if ((tmp = member_array(':', func)) != -1) {
obj = find_object(func[tmp+1..]);
func = func[0..tmp-1];
} else {
obj = previous_object();
}
if (!obj)
return 0;
return call_other(obj, func, explode(arg, "|")...);
}
string process_string(string str) {
int pr_start;
string array parts = explode(str, "@@");
pr_start = !(str[0..1]=="@@");
for (int il = pr_start; il < sizeof(parts); il += 2) {
string tmp = process_value(parts[il]);
if (stringp(tmp))
parts[il] = tmp;
}
return implode(parts, "");
}

View File

@ -0,0 +1,49 @@
#ifdef COMPAT_TAIL
/* This version is strictly compatible with the old version */
int tail(string fname) {
string str;
int offset = file_size(fname);
if (offset < 0)
return 0;
offset -= 54 * 20;
if (offset < 0) offset = 0;
str = read_bytes(fname, offset, 1080);
if (!str) return 0;
if (offset) str = str[strsrch(str, "\n")+1..];
write(str);
return 1;
}
#else
/* This version is slightly extended and compatible in spirit, but doesn't
* reproduce the oddities of the original tail() efun. Note that it also
* returns the string, so write(tail(fname)) is needed for strict
* compatibility.
*/
varargs string tail(string fname, int nlines) {
int chunk = nlines * 80;
int offset = file_size(fname);
int num_nl, p, skip;
string str = "";
while (offset > 0 && num_nl <= nlines) {
num_nl = 0;
offset -= chunk;
if (offset < 0) {
chunk += offset; /* negative */
offset = 0;
}
str = read_bytes(fname, offset, chunk) + str;
p = -1;
while (p < sizeof(str)-1 && p = member_array('\n', str, p+1))
num_nl++;
}
skip = num_nl - nlines;
p = -1;
while (skip--)
p = member_array('\n', str, p+1);
return str[p..];
}
#endif

2750
fluffos-2.23-ds03/compiler.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,295 @@
#ifndef COMPILER_H
#define COMPILER_H
#include "trees.h"
#include "lex.h"
#include "program.h"
#define _YACC_
#define YYMAXDEPTH 600
/*
* Information for allocating a block that can grow dynamically
* using realloc. That means that no pointers should be kept into such
* an area, as it might be moved.
*/
typedef struct {
char *block;
int current_size;
int max_size;
} mem_block_t;
#define START_BLOCK_SIZE 4096
/* NUMPAREAS ares are saved with the program code after compilation,
* the rest are only temporary.
*/
#define A_PROGRAM 0 /* executable code */
#define A_FUNCTIONS 1
#define A_STRINGS 2 /* table of strings */
#define A_VAR_NAME 3
#define A_VAR_TYPE 4
#define A_LINENUMBERS 5 /* linenumber information */
#define A_FILE_INFO 6 /* start of file line nos */
#define A_INHERITS 7 /* table of inherited progs */
#define A_CLASS_DEF 8
#define A_CLASS_MEMBER 9
#define A_ARGUMENT_TYPES 10 /* */
#define A_ARGUMENT_INDEX 11 /* */
#define NUMPAREAS 12
#define A_CASES 13 /* keep track of cases */
#define A_STRING_NEXT 14 /* next prog string in hash chain */
#define A_STRING_REFS 15 /* reference count of prog string */
#define A_INCLUDES 16 /* list of included files */
#define A_FUNCTIONALS 17
#define A_FUNCTION_DEFS 18
#define A_VAR_TEMP 19 /* table of variables */
#define NUMAREAS 20
#define TREE_MAIN 0
#define TREE_INIT 1
#define NUMTREES 2
#define CURRENT_PROGRAM_SIZE (prog_code - mem_block[A_PROGRAM].block)
#define UPDATE_PROGRAM_SIZE mem_block[A_PROGRAM].current_size = CURRENT_PROGRAM_SIZE
/*
* Types available. The number '0' is valid as any type. These types
* are only used by the compiler, when type checks are enabled. Compare with
* the run-time types, named T_ interpret.h.
*/
#define TYPE_UNKNOWN 0 /* This type must be casted */
#define TYPE_ANY 1 /* Will match any type */
#define TYPE_NOVALUE 2
#define TYPE_VOID 3
#define TYPE_NUMBER 4
#define TYPE_STRING 5
#define TYPE_OBJECT 6
#define TYPE_MAPPING 7
#define TYPE_FUNCTION 8
#define TYPE_REAL 9
#define TYPE_BUFFER 10
#define TYPE_MASK 0xf
typedef struct {
int runtime_index;
ident_hash_elem_t *ihe;
} local_info_t;
extern mem_block_t mem_block[NUMAREAS];
extern const char *compiler_type_names[];
#define LOOP_CONTEXT 0x1
#define SWITCH_CONTEXT 0x2
#define SWITCH_STRINGS 0x4
#define SWITCH_NUMBERS 0x8
#define SWITCH_DEFAULT 0x10
#define SWITCH_RANGES 0x20
#define SWITCH_NOT_EMPTY 0x40
#define LOOP_FOREACH 0x80
#define SPECIAL_CONTEXT 0x100
#define ARG_LIST 0x200
typedef struct function_context_s {
parse_node_t *values_list;
short bindable;
short num_parameters;
short num_locals;
struct function_context_s *parent;
} function_context_t;
extern function_context_t *current_function_context;
extern int var_defined;
extern parse_node_t *comp_trees[NUMTREES];
extern unsigned short *comp_def_index_map;
extern unsigned short *func_index_map;
typedef struct compiler_temp_t {
unsigned short flags;
unsigned short offset;
unsigned short function_index_offset;
struct program_s *prog; /* inherited if nonzero */
union {
function_t *func;
long index;
} u;
struct compiler_temp_t *next;
} compiler_temp_t;
/*
* Some good macros to have.
*/
#define IS_CLASS(t) ((t & (TYPE_MOD_ARRAY | TYPE_MOD_CLASS)) == TYPE_MOD_CLASS)
#define CLASS_IDX(t) (t & ~(DECL_MODS | TYPE_MOD_CLASS))
#define COMP_TYPE(e, t) (!(e & (TYPE_MOD_ARRAY | TYPE_MOD_CLASS)) \
&& (compatible[(e & ~DECL_MODS)] & (1 << (t))))
#define IS_TYPE(e, t) (!(e & (TYPE_MOD_ARRAY | TYPE_MOD_CLASS)) \
&& (is_type[(e & ~DECL_MODS)] & (1 << (t))))
#define FUNCTION_TEMP(n) ((compiler_temp_t *)mem_block[A_FUNCTION_DEFS].block + (n))
#define FUNCTION_NEXT(n) (FUNCTION_TEMP(n)->next)
/* function_t from A_FUNCTIONS index */
#define FUNC(n) ((function_t *)mem_block[A_FUNCTIONS].block + (n))
/* program for inherited entry from full function index */
#define FUNCTION_PROG(n) (FUNCTION_TEMP(n)->prog)
#define FUNCTION_ALIAS(n) (FUNCTION_TEMP(n)->alias_for)
/* function_t from full function index */
#define FUNCTION_DEF(n) (FUNCTION_PROG(n) ? FUNCTION_TEMP(n)->u.func : FUNC(FUNCTION_TEMP(n)->u.index))
/* flags from full function index */
#define FUNCTION_FLAGS(n) (FUNCTION_TEMP(n)->flags)
#define NUM_INHERITS (mem_block[A_INHERITS].current_size / sizeof(inherit_t))
#define INHERIT(n) ((inherit_t *)mem_block[A_INHERITS].block + (n))
#define VAR_TEMP(n) ((variable_t *)mem_block[A_VAR_TEMP].block + (n))
#define SIMUL(n) (simuls[n].func)
#define PROG_STRING(n) (((const char **)mem_block[A_STRINGS].block)[n])
#define CLASS(n) ((class_def_t *)mem_block[A_CLASS_DEF].block + (n))
#if !defined(__alpha) && !defined(cray) && !defined(__sparc__)
#define align(x) (((x) + 3) & ~3)
#else
#define align(x) (((x) + 7) & ~7)
#endif
#define SOME_NUMERIC_CASE_LABELS 0x40000
#define NO_STRING_CASE_LABELS 0x80000
#define ARG_IS_PROTO 1
#define ARG_IS_VARARGS 2
#define NOVALUE_USED_FLAG 1024
int validate_function_call (int, parse_node_t *);
parse_node_t *validate_efun_call (int, parse_node_t *);
extern mem_block_t mem_block[];
extern int exact_types, global_modifiers;
extern int current_type;
extern char *prog_code;
extern char *prog_code_max;
extern program_t NULL_program;
extern unsigned char string_tags[0x20];
extern short freed_string;
extern local_info_t *locals, *locals_ptr;
extern unsigned short *type_of_locals, *type_of_locals_ptr;
extern int current_number_of_locals;
extern int max_num_locals;
extern int current_tree;
extern int type_of_locals_size;
extern int locals_size;
extern int current_number_of_locals;
extern int max_num_locals;
extern short compatible[11];
extern short is_type[11];
extern int comp_last_inherited;
char *get_type_modifiers (char *, char *, int);
char *get_two_types (char *, char *, int, int);
char *get_type_name (char *, char *, int);
void init_locals (void);
void save_file_info (int, int);
int add_program_file (char *, int);
void yyerror (const char *);
void yywarn (const char *);
char *the_file_name (char *);
void free_all_local_names (int);
void pop_n_locals (int);
void reactivate_current_locals (void);
void clean_up_locals (void);
void deactivate_current_locals (void);
int add_local_name (const char *, int);
void reallocate_locals (void);
void initialize_locals (void);
int get_id_number (void);
program_t *compile_file (int, char *);
void reset_function_blocks (void);
void copy_variables (program_t *, int);
void copy_structures (program_t *);
int copy_functions (program_t *, int);
void type_error (const char *, int);
int compatible_types (int, int);
int compatible_types2 (int, int);
int arrange_call_inherited (char *, parse_node_t *);
void add_arg_type (unsigned short);
int define_new_function (const char *, int, int, int, int);
int define_variable (char *, int);
int define_new_variable (char *, int);
short store_prog_string (const char *);
void free_prog_string (short);
#ifdef DEBUG
int dump_function_table (void);
#endif
void prepare_cases (parse_node_t *, int);
void push_func_block (void);
void pop_func_block (void);
int decl_fix (int);
parse_node_t *check_refs (int, parse_node_t *, parse_node_t *);
int lookup_any_class_member (char *, unsigned char *);
int lookup_class_member (int, char *, unsigned char *);
parse_node_t *reorder_class_values (int, parse_node_t *);
parse_node_t *promote_to_float (parse_node_t *);
parse_node_t *promote_to_int (parse_node_t *);
int convert_type (int);
parse_node_t *add_type_check (parse_node_t *, int);
parse_node_t *do_promotions (parse_node_t *, int);
parse_node_t *throw_away_call (parse_node_t *);
parse_node_t *throw_away_mapping (parse_node_t *);
#define realloc_mem_block(m) do { \
mem_block_t *M = m; \
M->max_size <<= 1; \
M->block = (char *)DREALLOC(M->block, M->max_size, TAG_COMPILER, "realloc_mem_block"); \
} while (0)
#define add_to_mem_block(n, data, size) do { \
mem_block_t *mbp = &mem_block[n]; \
int Size = size; \
\
if (mbp->current_size + Size > mbp->max_size) { \
do { \
mbp->max_size <<= 1; \
} while (mbp->current_size + Size > mbp->max_size); \
\
mbp->block = (char *)DREALLOC(mbp->block, mbp->max_size, TAG_COMPILER, "insert_in_mem_block"); \
} \
memcpy(mbp->block + mbp->current_size, data, Size); \
mbp->current_size += Size; \
} while (0)
#ifndef SUPPRESS_COMPILER_INLINES
INLINE_STATIC
char *allocate_in_mem_block (int n, int size)
{
mem_block_t *mbp = &mem_block[n];
char *ret;
if (mbp->current_size + size > mbp->max_size) {
do {
mbp->max_size <<= 1;
} while (mbp->current_size + size > mbp->max_size);
mbp->block = (char *)DREALLOC(mbp->block, mbp->max_size, TAG_COMPILER, "insert_in_mem_block");
}
ret = mbp->block + mbp->current_size;
mbp->current_size += size;
return ret;
}
#endif
#endif

View File

@ -0,0 +1,76 @@
/*
config.h: do not change anything in this file. The user definable
options have been moved into the options.h file.
*/
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include "include/runtime_config.h"
/*
* runtime config strings. change these values in the runtime configuration
* file (config.example)
*/
#define CONFIG_STR(x) config_str[(x) - BASE_CONFIG_STR]
#define CONFIG_INT(x) config_int[(x) - BASE_CONFIG_INT]
#define MUD_NAME CONFIG_STR(__MUD_NAME__)
#define ADDR_SERVER_IP CONFIG_STR(__ADDR_SERVER_IP__)
#define MUD_LIB CONFIG_STR(__MUD_LIB_DIR__)
#define BIN_DIR CONFIG_STR(__BIN_DIR__)
#define LOG_DIR CONFIG_STR(__LOG_DIR__)
#define INCLUDE_DIRS CONFIG_STR(__INCLUDE_DIRS__)
#define MASTER_FILE CONFIG_STR(__MASTER_FILE__)
#define SIMUL_EFUN CONFIG_STR(__SIMUL_EFUN_FILE__)
#define SWAP_FILE CONFIG_STR(__SWAP_FILE__)
#define DEBUG_LOG_FILE CONFIG_STR(__DEBUG_LOG_FILE__)
#define DEFAULT_ERROR_MESSAGE CONFIG_STR(__DEFAULT_ERROR_MESSAGE__)
#define DEFAULT_FAIL_MESSAGE CONFIG_STR(__DEFAULT_FAIL_MESSAGE__)
#define GLOBAL_INCLUDE_FILE CONFIG_STR(__GLOBAL_INCLUDE_FILE__)
#define MUD_IP CONFIG_STR(__MUD_IP__)
/*
* runtime config ints
*/
#define PORTNO CONFIG_INT(__MUD_PORT__)
#define ADDR_SERVER_PORT CONFIG_INT(__ADDR_SERVER_PORT__)
#define TIME_TO_CLEAN_UP CONFIG_INT(__TIME_TO_CLEAN_UP__)
#define TIME_TO_RESET CONFIG_INT(__TIME_TO_RESET__)
#define TIME_TO_SWAP CONFIG_INT(__TIME_TO_SWAP__)
#define MAX_COST CONFIG_INT(__MAX_EVAL_COST__)
#define MAX_BITS CONFIG_INT(__MAX_BITFIELD_BITS__)
#define MAX_ARRAY_SIZE CONFIG_INT(__MAX_ARRAY_SIZE__)
#define MAX_BUFFER_SIZE CONFIG_INT(__MAX_BUFFER_SIZE__)
#define MAX_MAPPING_SIZE CONFIG_INT(__MAX_MAPPING_SIZE__)
#define MAX_STRING_LENGTH CONFIG_INT(__MAX_STRING_LENGTH__)
#define READ_FILE_MAX_SIZE CONFIG_INT(__MAX_READ_FILE_SIZE__)
#define MAX_BYTE_TRANSFER CONFIG_INT(__MAX_BYTE_TRANSFER__)
#define RESERVED_SIZE CONFIG_INT(__RESERVED_MEM_SIZE__)
#define HTABLE_SIZE CONFIG_INT(__SHARED_STRING_HASH_TABLE_SIZE__)
#define OTABLE_SIZE CONFIG_INT(__OBJECT_HASH_TABLE_SIZE__)
#define INHERIT_CHAIN_SIZE CONFIG_INT(__INHERIT_CHAIN_SIZE__)
#define FD6_PORT CONFIG_INT(__FD6_PORT__)
#define FD6_KIND CONFIG_INT(__FD6_KIND__)
#ifdef USE_POSIX_SIGNALS
#define sigblock(m) port_sigblock(m)
#define sigmask(s) port_sigmask(s)
#define signal(s,f) port_signal(s,f)
#define sigsetmask(m) port_sigsetmask(m)
#endif
#define SETJMP(x) setjmp(x)
#define LONGJMP(x,y) longjmp(x,y)
#define APPLY_CACHE_SIZE (1 << APPLY_CACHE_BITS)
#define NUM_CONSTS 5
#define NULL_MSG "0"
extern int config_int[NUM_CONFIG_INTS];
extern char *config_str[NUM_CONFIG_STRS];
#endif

112
fluffos-2.23-ds03/configure vendored Normal file
View File

@ -0,0 +1,112 @@
#!/bin/bash
#MINGW USERS:
#To make this script work under MinGW, change the
#top line to point to this: #!/bin/sh
#Make the non-argument config be Dead Souls
if ! [ $1 ]; then
ARG="ds"
else
ARG=$1
fi
if [ $ARG == "--help" ] || [ $ARG == "-h" ]; then
echo "Available options:"
echo "A generic build: ./configure generic"
echo "For Dead Souls 2: ./configure ds"
echo "For Sapidlib: ./configure sapid"
echo "For Discworld: ./configure dw"
echo "For Lima: ./configure lima"
echo "For Skylib: ./configure skylib"
echo "For TMI-2: ./configure tmi2"
echo "For Merentha: ./configure merentha"
echo "For Nightmare 3: ./configure nm3"
echo "For LPUniversity: ./configure lpuni"
echo "For Lil: ./configure lil"
echo "For Final Realms: ./configure fr"
echo "For Foundation I: ./configure foundation"
echo "For Foundation II:./configure foundation2"
echo "For Nightmare IV: ./configure nm4"
echo "----"
echo "With no options, this script defaults to Dead Souls."
exit
fi
echo "Option selected: $ARG $2"
sleep 1
./build.FluffOS $2
#if [ $ARG == "ds" ] || [ $ARG == "ds.debug" ]; then
#\cp -f ../extra/creremote/remote.c ../lib/lib/
#fi
if uname -a | grep -i "cygwin" | grep -v grep ; then
echo "Cygwin detected."
export WINDOWS='#define WINDOWS'
else
# Some stuff for Dead Souls not on Cygwin
echo "Moving around some DS specific files..."
if [ $ARG == "ds" ] || [ $ARG == "ds.debug" ]; then
if ! [ -f ../bin/mudos.bak ]; then
\rm -f ../bin/mudos.bak
\mv -f ../bin/mudos.cfg ../bin/mudos.bak
\cp -f ../bin/mudos.cfg.orig ../lib/secure/cfg/mudos.cfg
ln -s ../lib/secure/cfg/mudos.cfg ../bin/mudos.cfg
echo "File moves done"
fi
fi
fi
#start local_options check
if [ -f local_options.$ARG ]; then
if ! [ -f local_options ]; then
echo "Copying local_options.$ARG to local_options"
cp local_options.$ARG local_options
else
echo "local_options already exists. Not overwriting. Exiting."
echo "If you want to completely start over, type: make distclean"
exit
fi
else
echo "local_options.$ARG not found. Exiting."
fi
#end local_options check
if uname -a | grep "MINGW" | grep -v grep ; then
echo "MinGW detected. Adding appropriate config"
#echo " -lwsock32 -lws2_32 -lz" > system_libs
#\cp -f ../extra/mingw/configur* .
export WINDOWS='#define WINDOWS'
echo "#define MINGW" >> local_options
echo "#undef HAS_CONSOLE" >> local_options
else
echo "No MinGW config needed."
fi
if /sbin/ifconfig -a | grep "204\.209\.44" | grep -v grep ; then
echo "Wolfpaw detected."
echo "Running Wolfpaw-specific modification."
echo "When this is done, please enter the following command line:"
echo "*********"
echo " "
echo "make -j 1"
echo " "
echo "*********"
cp -f ../extra/wolfpaw/* .
echo "#include \"../extra/wolfpaw/configure.h\"" >> local_options
else
echo "No Wolfpaw config needed."
fi
#This will be blank if there is no Cygwin or MinGW:
echo $WINDOWS >> local_options
ulimit -n 2048
export ULIMIT=`ulimit -n`
echo "#define ULIMIT "$ULIMIT >> local_options
echo "Configuration script complete."

Some files were not shown because too many files have changed in this diff Show More