diff --git a/.gitignore b/.gitignore index 8a337b9..9489a22 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,14 @@ .cproject .project .idea +.vscode src/objects -!src/objects/.gitignore +!src/objects/.gitkeep compile_commands.json +cmake-build-debug/ +docker-compose.yml +Dockerfile +amnutsIdent +amnutsTalker +supervisord.pid +supervisord.log diff --git a/COPYRIGHT b/COPYRIGHT index 0080d80..8ffe075 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,6 +1,6 @@ +-----------------------------------------------------------------------------+ COPYRIGHT - COPYRIGHT - COPYRIGHT - COPYRIGHT - COPYRIGHT - COPYRIGHT - Copyright information for Amnuts + Copyright information for Amnuts +-----------------------------------------------------------------------------+ Preamble @@ -11,7 +11,7 @@ with ID 1027006837.1806.0.nnrp-07.c2de0bc0@news.demon.co.uk posted to newgroups alt.talkers, alt.talkers.nuts, and alt.talkers.programming that he was now allowing all versions of his NUTS codes to optionally be distributed under the General -Public License. For reference this mesage can be accessed at the URL: +Public License. For reference this message can be accessed at the URL: http://groups.google.com/groups?selm=1027006837.1806.0.nnrp-07.c2de0bc0%40news.demon.co.uk For further information on NUTS licensing see the file docs/nuts_copyright. @@ -19,7 +19,7 @@ For further information on NUTS licensing see the file docs/nuts_copyright. Copyright Information for Amnuts code ------------------------------------- -Amnuts 2.3.0 A Unix Talk Server via Telnet +Amnuts, A Unix Talk Server via Telnet Copyright (C) 1996-1996 Neil Robertson (Boltar) [NUTS] Copyright (C) 1997-2003 Andrew Collington (Andy) [Amnuts] Copyright (C) 1999-1999 Gordon Chiu (Ardant) [ident-daemon] @@ -68,7 +68,6 @@ associated files. This copyright pertains to ANY version of Amnuts, documents, or web site. If you have any problems with this copyright notice then you should not use the code at all. -Andrew Collington -September, 2001 - + Andrew Collington + February, 2023 +-----------------------------------------------------------------------------+ diff --git a/IMPORTANT b/IMPORTANT index 452b32e..36eed12 100644 --- a/IMPORTANT +++ b/IMPORTANT @@ -1,6 +1,6 @@ +-----------------------------------------------------------------------------+ - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - Information for the running of a talker based on Amnuts + IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT + Information for the running of a talker based on Amnuts +-----------------------------------------------------------------------------+ If you are installing this Amnuts version as a fresh talker, with no prior @@ -10,11 +10,11 @@ upgrade your existing talker, or are going to use this code as your base and add bits from your existing talker, then it is vital you read this document and the others before you make any changes. -First off, support is only given through the websites, and not through private -email. You can gain support through the main Amnuts website -(http://amnuts.talker.com/ or http://www.amnuts.org/), or if you are looking -to submit bugs or get the latest updated files, then you can gain that through -the developer's site (http://www.amnuts.net/). +First off, support is only given through the GitHub site, where you can get the +latest version, submit issues or request features, and so on. The address is: + + https://amnuts.net/ + or https://github.com/amnuts/Amnuts The main difference you will notice about this code and any of the previous releases is that Amnuts now comes in many different files. This means that if @@ -30,7 +30,11 @@ More information can be found in the 'compiling' document, found in the 'docs' directory. You should read the compiling document, and then have a look at the Makefile and familiarize yourself with it. -The ident deamon needs to be run separately. This is because it's a separate +If you don't have all the software installed that's required for compiling, +you can also compile and run via docker. More information can be found in the +'docs/docker' file. + +The ident daemon needs to be run separately. This is because it's a separate program to the talker, compiled as its own executable. Remember to login initially with the username 'test' and the password 'test'. @@ -43,12 +47,12 @@ name changing command. :) The *MOST* important thing to remember though is; RTFM!! Read the documents supplied with the distribution, look at the code, try something out.. Only then if that fails should you go asking questions on boards and -such. It also helps if you give an example of what you've tried too. +such. It also helps if you give an example of what you've tried, too. Bug reports I'm still up to receiving, but even then, don't be upset if you don't get a thorough response. - Andrew Collington - The Amnuts Development Team - August, 2003 + Andrew Collington + The Amnuts Development Team + February, 2023 +-----------------------------------------------------------------------------+ diff --git a/Makefile b/Makefile index 4de7f71..0ada2b8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # # General setup of GCC and compiler flags, base directories, etc. # -BINDIR = $(CURDIR) +BINDIR = $(CURDIR)/build INCDIR = $(CURDIR)/src/includes PERMS = 755 CC = gcc @@ -15,8 +15,8 @@ LD_FLAGS = # remove the '-DNETLINKS' - same for the others. # Possible flags are (each starting with '-D'): # GAMES - include games -# WIZPORT - Allow a seperate port just for WIZ levels to use -# IDENTD - Ident Deamon +# WIZPORT - Allow a separate port just for WIZ levels to use +# IDENTD - Ident Daemon # MANDNS - Manual DNS lookups # NETLINKS - The infamous Netlinks # @@ -25,7 +25,7 @@ TALKER_FLAGS = -DGAMES -DWIZPORT -DIDENTD -DMANDNS -DNETLINKS # # Locations and binary name for talker build # -TALKER_BIN = amnuts230 +TALKER_BIN = amnutsTalker TALKER_SRC_DIR = $(CURDIR)/src TALKER_OBJ_DIR = $(TALKER_SRC_DIR)/objects TALKER_SRC = $(wildcard $(TALKER_SRC_DIR)/*.c $(TALKER_SRC_DIR)/commands/*.c) @@ -84,7 +84,7 @@ distclean: clean rm -f $(INCDIR)/*.[ch]~ $(INCDIR)/*.[ch].bak clean: - @echo "Removing object and dependancy files" + @echo "Removing object and dependency files" rm -f $(TALKER_OBJS) $(TALKER_OBJS:.o=.d) rm -f $(IDENTD_OBJS) $(IDENTD_OBJS:.o=.d) rm -f $(VENDOR_SDS_OBJS) $(VENDOR_SDS_OBJS:.o=.d) @@ -102,6 +102,7 @@ vpath %.c $(TALKER_SRC_DIR) $(TALKER_SRC_DIR)/commands $(IDENTD_SRC_DIR) $(VENDO $(BINDIR)/$(TALKER_BIN) $(BINDIR)/$(IDENTD_BIN): $(BINDIR)/%: % @echo "Installing $< ..." chmod $(PERMS) $< + mv $< $(BINDIR) $(TALKER_BIN): $(TALKER_OBJS) $(VENDOR_SDS_OBJS) @echo "Linking $@ ..." diff --git a/README b/README index 26e0989..32192de 100644 --- a/README +++ b/README @@ -1,46 +1,38 @@ +-----------------------------------------------------------------------------+ - README - README - README - README - README - README - README - README - README - Introductory information for the Unix talker code Amnuts + README - README - README - README - README - README - README - README + Introductory information for the Amnuts talker code +-----------------------------------------------------------------------------+ -Welcome to the Amnuts talker code, version 2.3.0! Or, if you have already -used Amnuts, then welcome back! This is the latest version of Amnuts and MANY -things have changed. +Welcome to the Amnuts talker code! Or, if you have already used Amnuts, then +welcome back - it's good to still have you with us. :-) -Amnuts development slowed down for a (long) while, but thanks to two people -in particular, it managed to get back on track. These people go by the handles -'Ardant' and 'Uzume'. Ardant supplied a CVS repository and bug tracking -software for Amnuts, and Uzume and worked tirelessly in updating Amnuts and -making it more stable. Many thanks to both of them. +It has been 20 years - yup, two whole decades - since this README was last +updated, and, honestly, not much has changed in the world of Amnuts Talkers. +The Golden Age of talkers has long past, though it's still awesome to see some +die-hard fans still out there and keeping talkers alive (Marado's TalkerNode, +for example). -Because of the CVS and Bugzilla, a new website was set up for the development -of the Amnuts talker code. This can be found at: +As for Amnuts, as you're undoubtedly aware, it's now available from GitHub. +You can get there from: - http://www.amnuts.net/ + https://amnuts.net/ + or https://github.com/amnuts/Amnuts -Instructions can be found there on how to use CVS and Bugzilla. If you find -any bugs with this version of Amnuts then it would be appreciated if you use -Bugzilla to report them. From the CVS repository you can download the latest -files. +You can submit issues and post up on the discussion board there. Please feel +free to fork and submit pull requests. -The Amnuts code can be found, as always, at: +To get started with Amnuts you'll need either a linux environment or you can +use docker. For further details, see the docs/docker and and other related +files in the docs directory. - http://amnuts.talker.com/ +Lots of the documentation and files here haven't been updated for those same +two decades, but hopefully one day they will be revived and revamped. Until +then, just head towards the wind and push on as best you can. ;-) -or can now also be access via: +Thanks for using Amnuts, and as you're here you must be interested in talkers, +so thanks also for keeping those alive! Enjoy! - http://www.amnuts.org/ - -Please read the 'IMPORTANT' file, and the 'amnuts_changes' in the DOCs -directory for more information on what changes have been made since -version 2.2.1 (the previous release to this one) because there have been a -LOT of them! Even if you are a previous Amnuts user, programmer, owner, -whatever - you should STILL READ THE FILES! :) - -Thanks for using Amnuts! Enjoy! - - - Andrew Collington - The Amnuts Development Team - August, 2003 + Andrew Collington + The Amnuts Development Team + February, 2023 +-----------------------------------------------------------------------------+ diff --git a/dumpfiles/.gitignore b/build/.gitkeep similarity index 100% rename from dumpfiles/.gitignore rename to build/.gitkeep diff --git a/datafiles/car_park.R b/datafiles/car_park.R deleted file mode 100644 index e1f6430..0000000 --- a/datafiles/car_park.R +++ /dev/null @@ -1,4 +0,0 @@ -There is a wide expanse of concrete infront of you. Somewhere in the -distant, just on the end of your range of vision, you see... yes, it's a -car. You look up at the building beind you and wonder if it really needs -a carpark this big with the few people who actually work in there. diff --git a/datafiles/toilets.R b/datafiles/toilets.R deleted file mode 100644 index d29ce03..0000000 --- a/datafiles/toilets.R +++ /dev/null @@ -1 +0,0 @@ -Cold, damp and never flush. Need anymore be said? diff --git a/docker-setup.sh b/docker-setup.sh new file mode 100644 index 0000000..fbcedee --- /dev/null +++ b/docker-setup.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +MACHINE=$(uname -m) +if [ "$MACHINE" == "x86_64" ] || [ "$MACHINE" == "i686" ]; then + OS_ARCH="amd64" +elif [ "$MACHINE" == "aarch64" ] || [ "$MACHINE" == "arm64" ]; then + OS_ARCH="arm64v8" +else + OS_ARCH="amd64" + echo "Unknown platform - falling back to amd64" +fi + +CONFIG_FILE="$(pwd)/files/datafiles/config" +MAIN_PORT=$(grep "\bmainport\b" "$CONFIG_FILE" | awk '{ print $2 }') +WIZ_PORT=$(grep "\bwizport\b" "$CONFIG_FILE" | awk '{ print $2 }') +LINK_PORT=$(grep "\blinkport\b" "$CONFIG_FILE" | awk '{ print $2 }') + +cat << EOT > Dockerfile +FROM ${OS_ARCH}/alpine + +RUN apk add build-base supervisor bash busybox-extras gdb +COPY supervisord.conf /etc/supervisord.conf + +WORKDIR /amnuts +EXPOSE $MAIN_PORT +EXPOSE $WIZ_PORT +EXPOSE $LINK_PORT + +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] +EOT + +cat << EOT > docker-compose.yml +version: "3" +services: + amnuts: + build: ./ + image: amnuts-build + environment: + - "MAIN_PORT=$MAIN_PORT" + - "WIZ_PORT=$WIZ_PORT" + - "LINK_PORT=$LINK_PORT" + ports: + - "${MAIN_PORT}:${MAIN_PORT}" + - "${WIZ_PORT}:${WIZ_PORT}" + - "${LINK_PORT}:${LINK_PORT}" + volumes: + - .:/amnuts + security_opt: + - seccomp:unconfined + cap_add: + - SYS_PTRACE +EOT \ No newline at end of file diff --git a/docs/about_dirs b/docs/about_dirs index 43900e9..41d4aae 100644 --- a/docs/about_dirs +++ b/docs/about_dirs @@ -19,7 +19,7 @@ the form .map. Also the 2 ban files: sitebans and userbans are stored here which store banned sites and banned users. -There is another directory in here, 'old_datafiles', just incase any of you +There is another directory in here, 'old_datafiles', just in case any of you wanted the old rooms and config files. diff --git a/docs/docker b/docs/docker new file mode 100644 index 0000000..0e87435 --- /dev/null +++ b/docs/docker @@ -0,0 +1,56 @@ ++------------------------------------------------------------------------------+ + DOCKER - DOCKER - DOCKER - DOCKER - DOCKER - DOCKER - DOCKER - DOCKER - DOCKER + Information on spinning up Amnuts with Docker ++------------------------------------------------------------------------------+ + +The Docker setup for Amnuts is pretty new and probably doesn't cover all the +needs you could want, and if you have to change things then you're pretty much +on your own. However, it could provide you a way to compile and run an Amnuts +based talker without having all the GCC requirements installed... So long as +you have bash and docker, you should be able to get up and running pretty easily. + +To start with, you'll need to run: + + ./docker-startup.sh + +This will create the Dockerfile and docker-compose.yml files for your platform +(amd64 or arm64v8 are supported). If you make changes to the docker-startup.sh +file or the accompanying supervisord.conf file, you'll need to remove the +previously built image (assuming you have built one) and run the docker-setup +file again. + +To compile the code, use the command: + + docker-compose run --rm amnuts make install + +This will build the image if you haven't already, create a container, compile +the talker, then remove the container. Because all the files are mounted as a +volume, you'll not lose any files when the container is removed. + +In fact, you can run any of the Makefile commands this way, eg: + + docker-compose run --rm amnuts make distclean + +If you want to jump on the container itself, use: + + docker-compose run --rm amnuts /bin/bash + +Once you have run the "make install" command, you can then start the talker +with: + + docker-compose run -d --service-ports amnuts + +This will run a container in the background with the Amnuts talker running. +Supervisord is used to keep the process going. + +Alternatively, you can simply build the image with: + + docker-compose build + +And then run it with: + + docker-compose up + +The docker setup is in its early stages, so may well be adapted and changed +over time. Your mileage may vary. Use your best judgement. Try things out. +Raise an issue or a pull request if you know a better way! diff --git a/datafiles/andys_computer.R b/files/datafiles/andys_computer.R similarity index 100% rename from datafiles/andys_computer.R rename to files/datafiles/andys_computer.R diff --git a/datafiles/back_store.R b/files/datafiles/back_store.R similarity index 100% rename from datafiles/back_store.R rename to files/datafiles/back_store.R diff --git a/datafiles/box.R b/files/datafiles/box.R similarity index 58% rename from datafiles/box.R rename to files/datafiles/box.R index 7a67c53..1a04be6 100644 --- a/datafiles/box.R +++ b/files/datafiles/box.R @@ -1,2 +1,2 @@ This is a box. It does box things, like.. hold stuff. It's not big, it's -not clever and it's not worth describing in detail. +not clever, and it's not worth describing in detail. diff --git a/files/datafiles/car_park.R b/files/datafiles/car_park.R new file mode 100644 index 0000000..d762354 --- /dev/null +++ b/files/datafiles/car_park.R @@ -0,0 +1,4 @@ +There is a wide expanse of concrete in front of you. Somewhere in the +distant, just on the end of your range of vision, you see... yes, it's a +car. You look up at the building behind you and wonder if it really needs +a car-park this big with the few people who actually work in there. diff --git a/datafiles/conference.R b/files/datafiles/conference.R similarity index 90% rename from datafiles/conference.R rename to files/datafiles/conference.R index 1d885f4..2effc65 100644 --- a/datafiles/conference.R +++ b/files/datafiles/conference.R @@ -1,4 +1,4 @@ There is a musty smell here, and it is very cold. You correctly guess that not many people use this room. It's very plain, very boring. You give up even looking at the room and fall asleep - well why not? The boss -isn't here afterall! +isn't here after all! diff --git a/datafiles/config b/files/datafiles/config similarity index 100% rename from datafiles/config rename to files/datafiles/config diff --git a/datafiles/config2 b/files/datafiles/config2 similarity index 100% rename from datafiles/config2 rename to files/datafiles/config2 diff --git a/datafiles/crate.R b/files/datafiles/crate.R similarity index 100% rename from datafiles/crate.R rename to files/datafiles/crate.R diff --git a/datafiles/cupboard.R b/files/datafiles/cupboard.R similarity index 100% rename from datafiles/cupboard.R rename to files/datafiles/cupboard.R diff --git a/datafiles/directors.R b/files/datafiles/directors.R similarity index 100% rename from datafiles/directors.R rename to files/datafiles/directors.R diff --git a/datafiles/general.map b/files/datafiles/general.map similarity index 100% rename from datafiles/general.map rename to files/datafiles/general.map diff --git a/datafiles/library.R b/files/datafiles/library.R similarity index 100% rename from datafiles/library.R rename to files/datafiles/library.R diff --git a/datafiles/main_office.R b/files/datafiles/main_office.R similarity index 100% rename from datafiles/main_office.R rename to files/datafiles/main_office.R diff --git a/datafiles/reception.R b/files/datafiles/reception.R similarity index 100% rename from datafiles/reception.R rename to files/datafiles/reception.R diff --git a/datafiles/safe.R b/files/datafiles/safe.R similarity index 100% rename from datafiles/safe.R rename to files/datafiles/safe.R diff --git a/datafiles/store.map b/files/datafiles/store.map similarity index 100% rename from datafiles/store.map rename to files/datafiles/store.map diff --git a/datafiles/store_room.R b/files/datafiles/store_room.R similarity index 52% rename from datafiles/store_room.R rename to files/datafiles/store_room.R index d957688..28ff5a9 100644 --- a/datafiles/store_room.R +++ b/files/datafiles/store_room.R @@ -1,4 +1,4 @@ The icicles hang down and your breath turns to frost in the air. There is -much paper and booklets around here and the temptating to burn them and +much paper and booklets around here and the temptation to burn them and make a nice roaring fire is almost overwhelming... after all, the -air-conditioning is out of bounds so you have to stay warm somehow! +air-conditioning is out of bounds, so you have to stay warm somehow! diff --git a/files/datafiles/toilets.R b/files/datafiles/toilets.R new file mode 100644 index 0000000..574edd0 --- /dev/null +++ b/files/datafiles/toilets.R @@ -0,0 +1 @@ +Cold, damp, and never flush. Need anymore be said? diff --git a/datafiles/wizroom.R b/files/datafiles/wizroom.R similarity index 70% rename from datafiles/wizroom.R rename to files/datafiles/wizroom.R index bd35c45..b53e01a 100644 --- a/datafiles/wizroom.R +++ b/files/datafiles/wizroom.R @@ -1,8 +1,8 @@ The portal to the real world shimmers and vibrates. The dark blue oval shapes looks right at home here in the room, with it's strange containers on dusty shelves. On the heavy-set desk there are many weighty books -enscribed with a language not of this, or any earthly world. Occasionaly +inscribed with a language not of this, or any earthly world. Occasionally one of the mysterious items in the jars gurgles or winks at you -cocetishly. This makes you sick to your stomach, but you're glad for the +coquettishly. This makes you sick to your stomach, but you're glad for the attention - even if it is from a... splodge, swimming around in it's own mucus. diff --git a/files/dumpfiles/.gitignore b/files/dumpfiles/.gitignore new file mode 100644 index 0000000..2232829 --- /dev/null +++ b/files/dumpfiles/.gitignore @@ -0,0 +1 @@ +*.dump diff --git a/helpfiles/accreq b/files/helpfiles/accreq similarity index 100% rename from helpfiles/accreq rename to files/helpfiles/accreq diff --git a/helpfiles/addhistory b/files/helpfiles/addhistory similarity index 100% rename from helpfiles/addhistory rename to files/helpfiles/addhistory diff --git a/helpfiles/adminfiles b/files/helpfiles/adminfiles similarity index 100% rename from helpfiles/adminfiles rename to files/helpfiles/adminfiles diff --git a/helpfiles/afk b/files/helpfiles/afk similarity index 100% rename from helpfiles/afk rename to files/helpfiles/afk diff --git a/helpfiles/allclones b/files/helpfiles/allclones similarity index 100% rename from helpfiles/allclones rename to files/helpfiles/allclones diff --git a/helpfiles/arrest b/files/helpfiles/arrest similarity index 100% rename from helpfiles/arrest rename to files/helpfiles/arrest diff --git a/helpfiles/autopromo b/files/helpfiles/autopromo similarity index 100% rename from helpfiles/autopromo rename to files/helpfiles/autopromo diff --git a/helpfiles/ban b/files/helpfiles/ban similarity index 100% rename from helpfiles/ban rename to files/helpfiles/ban diff --git a/helpfiles/bank b/files/helpfiles/bank similarity index 100% rename from helpfiles/bank rename to files/helpfiles/bank diff --git a/helpfiles/bbcast b/files/helpfiles/bbcast similarity index 100% rename from helpfiles/bbcast rename to files/helpfiles/bbcast diff --git a/helpfiles/bcast b/files/helpfiles/bcast similarity index 100% rename from helpfiles/bcast rename to files/helpfiles/bcast diff --git a/helpfiles/beep b/files/helpfiles/beep similarity index 100% rename from helpfiles/beep rename to files/helpfiles/beep diff --git a/helpfiles/bfrom b/files/helpfiles/bfrom similarity index 100% rename from helpfiles/bfrom rename to files/helpfiles/bfrom diff --git a/helpfiles/bring b/files/helpfiles/bring similarity index 100% rename from helpfiles/bring rename to files/helpfiles/bring diff --git a/helpfiles/cafk b/files/helpfiles/cafk similarity index 100% rename from helpfiles/cafk rename to files/helpfiles/cafk diff --git a/helpfiles/calendar b/files/helpfiles/calendar similarity index 100% rename from helpfiles/calendar rename to files/helpfiles/calendar diff --git a/helpfiles/call b/files/helpfiles/call similarity index 100% rename from helpfiles/call rename to files/helpfiles/call diff --git a/helpfiles/cash b/files/helpfiles/cash similarity index 100% rename from helpfiles/cash rename to files/helpfiles/cash diff --git a/helpfiles/cbuff b/files/helpfiles/cbuff similarity index 100% rename from helpfiles/cbuff rename to files/helpfiles/cbuff diff --git a/helpfiles/cedit b/files/helpfiles/cedit similarity index 100% rename from helpfiles/cedit rename to files/helpfiles/cedit diff --git a/helpfiles/cemote b/files/helpfiles/cemote similarity index 100% rename from helpfiles/cemote rename to files/helpfiles/cemote diff --git a/helpfiles/charecho b/files/helpfiles/charecho similarity index 100% rename from helpfiles/charecho rename to files/helpfiles/charecho diff --git a/helpfiles/chear b/files/helpfiles/chear similarity index 100% rename from helpfiles/chear rename to files/helpfiles/chear diff --git a/helpfiles/clearline b/files/helpfiles/clearline similarity index 100% rename from helpfiles/clearline rename to files/helpfiles/clearline diff --git a/helpfiles/clone b/files/helpfiles/clone similarity index 100% rename from helpfiles/clone rename to files/helpfiles/clone diff --git a/helpfiles/cls b/files/helpfiles/cls similarity index 100% rename from helpfiles/cls rename to files/helpfiles/cls diff --git a/helpfiles/cmdcount b/files/helpfiles/cmdcount similarity index 100% rename from helpfiles/cmdcount rename to files/helpfiles/cmdcount diff --git a/helpfiles/cname b/files/helpfiles/cname similarity index 100% rename from helpfiles/cname rename to files/helpfiles/cname diff --git a/helpfiles/colour b/files/helpfiles/colour similarity index 100% rename from helpfiles/colour rename to files/helpfiles/colour diff --git a/helpfiles/connect b/files/helpfiles/connect similarity index 100% rename from helpfiles/connect rename to files/helpfiles/connect diff --git a/helpfiles/copyto b/files/helpfiles/copyto similarity index 100% rename from helpfiles/copyto rename to files/helpfiles/copyto diff --git a/helpfiles/create b/files/helpfiles/create similarity index 100% rename from helpfiles/create rename to files/helpfiles/create diff --git a/helpfiles/csay b/files/helpfiles/csay similarity index 100% rename from helpfiles/csay rename to files/helpfiles/csay diff --git a/helpfiles/cshout b/files/helpfiles/cshout similarity index 100% rename from helpfiles/cshout rename to files/helpfiles/cshout diff --git a/helpfiles/ctells b/files/helpfiles/ctells similarity index 100% rename from helpfiles/ctells rename to files/helpfiles/ctells diff --git a/helpfiles/ctopic b/files/helpfiles/ctopic similarity index 100% rename from helpfiles/ctopic rename to files/helpfiles/ctopic diff --git a/helpfiles/demote b/files/helpfiles/demote similarity index 100% rename from helpfiles/demote rename to files/helpfiles/demote diff --git a/helpfiles/desc b/files/helpfiles/desc similarity index 100% rename from helpfiles/desc rename to files/helpfiles/desc diff --git a/helpfiles/destroy b/files/helpfiles/destroy similarity index 100% rename from helpfiles/destroy rename to files/helpfiles/destroy diff --git a/helpfiles/disconnect b/files/helpfiles/disconnect similarity index 100% rename from helpfiles/disconnect rename to files/helpfiles/disconnect diff --git a/helpfiles/dmail b/files/helpfiles/dmail similarity index 100% rename from helpfiles/dmail rename to files/helpfiles/dmail diff --git a/helpfiles/donate b/files/helpfiles/donate similarity index 100% rename from helpfiles/donate rename to files/helpfiles/donate diff --git a/helpfiles/dsug b/files/helpfiles/dsug similarity index 100% rename from helpfiles/dsug rename to files/helpfiles/dsug diff --git a/helpfiles/dump b/files/helpfiles/dump similarity index 100% rename from helpfiles/dump rename to files/helpfiles/dump diff --git a/helpfiles/echo b/files/helpfiles/echo similarity index 100% rename from helpfiles/echo rename to files/helpfiles/echo diff --git a/helpfiles/emote b/files/helpfiles/emote similarity index 100% rename from helpfiles/emote rename to files/helpfiles/emote diff --git a/helpfiles/entpro b/files/helpfiles/entpro similarity index 100% rename from helpfiles/entpro rename to files/helpfiles/entpro diff --git a/helpfiles/ewiz b/files/helpfiles/ewiz similarity index 100% rename from helpfiles/ewiz rename to files/helpfiles/ewiz diff --git a/helpfiles/examine b/files/helpfiles/examine similarity index 100% rename from helpfiles/examine rename to files/helpfiles/examine diff --git a/helpfiles/expire b/files/helpfiles/expire similarity index 100% rename from helpfiles/expire rename to files/helpfiles/expire diff --git a/helpfiles/femote b/files/helpfiles/femote similarity index 100% rename from helpfiles/femote rename to files/helpfiles/femote diff --git a/helpfiles/files b/files/helpfiles/files similarity index 100% rename from helpfiles/files rename to files/helpfiles/files diff --git a/helpfiles/fix b/files/helpfiles/fix similarity index 100% rename from helpfiles/fix rename to files/helpfiles/fix diff --git a/helpfiles/flagged b/files/helpfiles/flagged similarity index 100% rename from helpfiles/flagged rename to files/helpfiles/flagged diff --git a/helpfiles/fmail b/files/helpfiles/fmail similarity index 100% rename from helpfiles/fmail rename to files/helpfiles/fmail diff --git a/helpfiles/force b/files/helpfiles/force similarity index 100% rename from helpfiles/force rename to files/helpfiles/force diff --git a/helpfiles/forwarding b/files/helpfiles/forwarding similarity index 100% rename from helpfiles/forwarding rename to files/helpfiles/forwarding diff --git a/helpfiles/friends b/files/helpfiles/friends similarity index 100% rename from helpfiles/friends rename to files/helpfiles/friends diff --git a/helpfiles/from b/files/helpfiles/from similarity index 100% rename from helpfiles/from rename to files/helpfiles/from diff --git a/helpfiles/fsay b/files/helpfiles/fsay similarity index 100% rename from helpfiles/fsay rename to files/helpfiles/fsay diff --git a/helpfiles/fsmail b/files/helpfiles/fsmail similarity index 100% rename from helpfiles/fsmail rename to files/helpfiles/fsmail diff --git a/helpfiles/fwho b/files/helpfiles/fwho similarity index 100% rename from helpfiles/fwho rename to files/helpfiles/fwho diff --git a/helpfiles/gcom b/files/helpfiles/gcom similarity index 100% rename from helpfiles/gcom rename to files/helpfiles/gcom diff --git a/helpfiles/go b/files/helpfiles/go similarity index 100% rename from helpfiles/go rename to files/helpfiles/go diff --git a/helpfiles/greet b/files/helpfiles/greet similarity index 100% rename from helpfiles/greet rename to files/helpfiles/greet diff --git a/helpfiles/grepu b/files/helpfiles/grepu similarity index 100% rename from helpfiles/grepu rename to files/helpfiles/grepu diff --git a/helpfiles/guess b/files/helpfiles/guess similarity index 100% rename from helpfiles/guess rename to files/helpfiles/guess diff --git a/helpfiles/hangman b/files/helpfiles/hangman similarity index 100% rename from helpfiles/hangman rename to files/helpfiles/hangman diff --git a/helpfiles/help b/files/helpfiles/help similarity index 100% rename from helpfiles/help rename to files/helpfiles/help diff --git a/helpfiles/history b/files/helpfiles/history similarity index 100% rename from helpfiles/history rename to files/helpfiles/history diff --git a/helpfiles/home b/files/helpfiles/home similarity index 100% rename from helpfiles/home rename to files/helpfiles/home diff --git a/helpfiles/ignall b/files/helpfiles/ignall similarity index 100% rename from helpfiles/ignall rename to files/helpfiles/ignall diff --git a/helpfiles/ignbeeps b/files/helpfiles/ignbeeps similarity index 100% rename from helpfiles/ignbeeps rename to files/helpfiles/ignbeeps diff --git a/helpfiles/igngreets b/files/helpfiles/igngreets similarity index 100% rename from helpfiles/igngreets rename to files/helpfiles/igngreets diff --git a/helpfiles/ignlist b/files/helpfiles/ignlist similarity index 100% rename from helpfiles/ignlist rename to files/helpfiles/ignlist diff --git a/helpfiles/ignlogons b/files/helpfiles/ignlogons similarity index 100% rename from helpfiles/ignlogons rename to files/helpfiles/ignlogons diff --git a/helpfiles/ignpics b/files/helpfiles/ignpics similarity index 100% rename from helpfiles/ignpics rename to files/helpfiles/ignpics diff --git a/helpfiles/ignshout b/files/helpfiles/ignshout similarity index 100% rename from helpfiles/ignshout rename to files/helpfiles/ignshout diff --git a/helpfiles/igntell b/files/helpfiles/igntell similarity index 100% rename from helpfiles/igntell rename to files/helpfiles/igntell diff --git a/helpfiles/ignuser b/files/helpfiles/ignuser similarity index 100% rename from helpfiles/ignuser rename to files/helpfiles/ignuser diff --git a/helpfiles/ignwiz b/files/helpfiles/ignwiz similarity index 100% rename from helpfiles/ignwiz rename to files/helpfiles/ignwiz diff --git a/helpfiles/inmsg b/files/helpfiles/inmsg similarity index 100% rename from helpfiles/inmsg rename to files/helpfiles/inmsg diff --git a/helpfiles/invis b/files/helpfiles/invis similarity index 100% rename from helpfiles/invis rename to files/helpfiles/invis diff --git a/helpfiles/invite b/files/helpfiles/invite similarity index 100% rename from helpfiles/invite rename to files/helpfiles/invite diff --git a/helpfiles/join b/files/helpfiles/join similarity index 100% rename from helpfiles/join rename to files/helpfiles/join diff --git a/helpfiles/kill b/files/helpfiles/kill similarity index 100% rename from helpfiles/kill rename to files/helpfiles/kill diff --git a/helpfiles/knock b/files/helpfiles/knock similarity index 100% rename from helpfiles/knock rename to files/helpfiles/knock diff --git a/helpfiles/last b/files/helpfiles/last similarity index 100% rename from helpfiles/last rename to files/helpfiles/last diff --git a/helpfiles/lban b/files/helpfiles/lban similarity index 100% rename from helpfiles/lban rename to files/helpfiles/lban diff --git a/helpfiles/listen b/files/helpfiles/listen similarity index 100% rename from helpfiles/listen rename to files/helpfiles/listen diff --git a/helpfiles/lmail b/files/helpfiles/lmail similarity index 100% rename from helpfiles/lmail rename to files/helpfiles/lmail diff --git a/helpfiles/logging b/files/helpfiles/logging similarity index 100% rename from helpfiles/logging rename to files/helpfiles/logging diff --git a/helpfiles/look b/files/helpfiles/look similarity index 100% rename from helpfiles/look rename to files/helpfiles/look diff --git a/helpfiles/macros b/files/helpfiles/macros similarity index 100% rename from helpfiles/macros rename to files/helpfiles/macros diff --git a/helpfiles/makeinvis b/files/helpfiles/makeinvis similarity index 100% rename from helpfiles/makeinvis rename to files/helpfiles/makeinvis diff --git a/helpfiles/makevis b/files/helpfiles/makevis similarity index 100% rename from helpfiles/makevis rename to files/helpfiles/makevis diff --git a/helpfiles/map b/files/helpfiles/map similarity index 100% rename from helpfiles/map rename to files/helpfiles/map diff --git a/helpfiles/memcount b/files/helpfiles/memcount similarity index 100% rename from helpfiles/memcount rename to files/helpfiles/memcount diff --git a/helpfiles/minlogin b/files/helpfiles/minlogin similarity index 100% rename from helpfiles/minlogin rename to files/helpfiles/minlogin diff --git a/helpfiles/mode b/files/helpfiles/mode similarity index 100% rename from helpfiles/mode rename to files/helpfiles/mode diff --git a/helpfiles/money b/files/helpfiles/money similarity index 100% rename from helpfiles/money rename to files/helpfiles/money diff --git a/helpfiles/monitor b/files/helpfiles/monitor similarity index 100% rename from helpfiles/monitor rename to files/helpfiles/monitor diff --git a/helpfiles/move b/files/helpfiles/move similarity index 100% rename from helpfiles/move rename to files/helpfiles/move diff --git a/helpfiles/mutter b/files/helpfiles/mutter similarity index 100% rename from helpfiles/mutter rename to files/helpfiles/mutter diff --git a/helpfiles/muzzle b/files/helpfiles/muzzle similarity index 100% rename from helpfiles/muzzle rename to files/helpfiles/muzzle diff --git a/helpfiles/mybgone b/files/helpfiles/mybgone similarity index 100% rename from helpfiles/mybgone rename to files/helpfiles/mybgone diff --git a/helpfiles/myclones b/files/helpfiles/myclones similarity index 100% rename from helpfiles/myclones rename to files/helpfiles/myclones diff --git a/helpfiles/mykey b/files/helpfiles/mykey similarity index 100% rename from helpfiles/mykey rename to files/helpfiles/mykey diff --git a/helpfiles/mylock b/files/helpfiles/mylock similarity index 100% rename from helpfiles/mylock rename to files/helpfiles/mylock diff --git a/helpfiles/myname b/files/helpfiles/myname similarity index 100% rename from helpfiles/myname rename to files/helpfiles/myname diff --git a/helpfiles/mypaint b/files/helpfiles/mypaint similarity index 100% rename from helpfiles/mypaint rename to files/helpfiles/mypaint diff --git a/helpfiles/myroom b/files/helpfiles/myroom similarity index 100% rename from helpfiles/myroom rename to files/helpfiles/myroom diff --git a/helpfiles/netdata b/files/helpfiles/netdata similarity index 100% rename from helpfiles/netdata rename to files/helpfiles/netdata diff --git a/helpfiles/netstat b/files/helpfiles/netstat similarity index 100% rename from helpfiles/netstat rename to files/helpfiles/netstat diff --git a/helpfiles/news b/files/helpfiles/news similarity index 100% rename from helpfiles/news rename to files/helpfiles/news diff --git a/helpfiles/nocopys b/files/helpfiles/nocopys similarity index 100% rename from helpfiles/nocopys rename to files/helpfiles/nocopys diff --git a/helpfiles/nuke b/files/helpfiles/nuke similarity index 100% rename from helpfiles/nuke rename to files/helpfiles/nuke diff --git a/helpfiles/outmsg b/files/helpfiles/outmsg similarity index 100% rename from helpfiles/outmsg rename to files/helpfiles/outmsg diff --git a/helpfiles/passwd b/files/helpfiles/passwd similarity index 100% rename from helpfiles/passwd rename to files/helpfiles/passwd diff --git a/helpfiles/pemote b/files/helpfiles/pemote similarity index 100% rename from helpfiles/pemote rename to files/helpfiles/pemote diff --git a/helpfiles/people b/files/helpfiles/people similarity index 100% rename from helpfiles/people rename to files/helpfiles/people diff --git a/helpfiles/picture b/files/helpfiles/picture similarity index 100% rename from helpfiles/picture rename to files/helpfiles/picture diff --git a/helpfiles/preview b/files/helpfiles/preview similarity index 100% rename from helpfiles/preview rename to files/helpfiles/preview diff --git a/helpfiles/private b/files/helpfiles/private similarity index 100% rename from helpfiles/private rename to files/helpfiles/private diff --git a/helpfiles/promote b/files/helpfiles/promote similarity index 100% rename from helpfiles/promote rename to files/helpfiles/promote diff --git a/helpfiles/prompt b/files/helpfiles/prompt similarity index 100% rename from helpfiles/prompt rename to files/helpfiles/prompt diff --git a/helpfiles/ptell b/files/helpfiles/ptell similarity index 100% rename from helpfiles/ptell rename to files/helpfiles/ptell diff --git a/helpfiles/public b/files/helpfiles/public similarity index 100% rename from helpfiles/public rename to files/helpfiles/public diff --git a/helpfiles/purge b/files/helpfiles/purge similarity index 100% rename from helpfiles/purge rename to files/helpfiles/purge diff --git a/helpfiles/quit b/files/helpfiles/quit similarity index 100% rename from helpfiles/quit rename to files/helpfiles/quit diff --git a/helpfiles/ranks b/files/helpfiles/ranks similarity index 100% rename from helpfiles/ranks rename to files/helpfiles/ranks diff --git a/helpfiles/rcountu b/files/helpfiles/rcountu similarity index 100% rename from helpfiles/rcountu rename to files/helpfiles/rcountu diff --git a/helpfiles/read b/files/helpfiles/read similarity index 100% rename from helpfiles/read rename to files/helpfiles/read diff --git a/helpfiles/reboot b/files/helpfiles/reboot similarity index 100% rename from helpfiles/reboot rename to files/helpfiles/reboot diff --git a/helpfiles/recaps b/files/helpfiles/recaps similarity index 100% rename from helpfiles/recaps rename to files/helpfiles/recaps diff --git a/helpfiles/recount b/files/helpfiles/recount similarity index 100% rename from helpfiles/recount rename to files/helpfiles/recount diff --git a/helpfiles/reload b/files/helpfiles/reload similarity index 100% rename from helpfiles/reload rename to files/helpfiles/reload diff --git a/helpfiles/reminder b/files/helpfiles/reminder similarity index 100% rename from helpfiles/reminder rename to files/helpfiles/reminder diff --git a/helpfiles/resite b/files/helpfiles/resite similarity index 100% rename from helpfiles/resite rename to files/helpfiles/resite diff --git a/helpfiles/retire b/files/helpfiles/retire similarity index 100% rename from helpfiles/retire rename to files/helpfiles/retire diff --git a/helpfiles/revafk b/files/helpfiles/revafk similarity index 100% rename from helpfiles/revafk rename to files/helpfiles/revafk diff --git a/helpfiles/revedit b/files/helpfiles/revedit similarity index 100% rename from helpfiles/revedit rename to files/helpfiles/revedit diff --git a/helpfiles/review b/files/helpfiles/review similarity index 100% rename from helpfiles/review rename to files/helpfiles/review diff --git a/helpfiles/revshout b/files/helpfiles/revshout similarity index 100% rename from helpfiles/revshout rename to files/helpfiles/revshout diff --git a/helpfiles/revtell b/files/helpfiles/revtell similarity index 100% rename from helpfiles/revtell rename to files/helpfiles/revtell diff --git a/helpfiles/rloadrm b/files/helpfiles/rloadrm similarity index 100% rename from helpfiles/rloadrm rename to files/helpfiles/rloadrm diff --git a/helpfiles/rmadmin b/files/helpfiles/rmadmin similarity index 100% rename from helpfiles/rmadmin rename to files/helpfiles/rmadmin diff --git a/helpfiles/rmail b/files/helpfiles/rmail similarity index 100% rename from helpfiles/rmail rename to files/helpfiles/rmail diff --git a/helpfiles/rnet b/files/helpfiles/rnet similarity index 100% rename from helpfiles/rnet rename to files/helpfiles/rnet diff --git a/helpfiles/rooms b/files/helpfiles/rooms similarity index 100% rename from helpfiles/rooms rename to files/helpfiles/rooms diff --git a/helpfiles/rstat b/files/helpfiles/rstat similarity index 100% rename from helpfiles/rstat rename to files/helpfiles/rstat diff --git a/helpfiles/rsug b/files/helpfiles/rsug similarity index 100% rename from helpfiles/rsug rename to files/helpfiles/rsug diff --git a/helpfiles/rules b/files/helpfiles/rules similarity index 100% rename from helpfiles/rules rename to files/helpfiles/rules diff --git a/helpfiles/samesite b/files/helpfiles/samesite similarity index 100% rename from helpfiles/samesite rename to files/helpfiles/samesite diff --git a/helpfiles/save b/files/helpfiles/save similarity index 100% rename from helpfiles/save rename to files/helpfiles/save diff --git a/helpfiles/say b/files/helpfiles/say similarity index 100% rename from helpfiles/say rename to files/helpfiles/say diff --git a/helpfiles/sayto b/files/helpfiles/sayto similarity index 100% rename from helpfiles/sayto rename to files/helpfiles/sayto diff --git a/helpfiles/search b/files/helpfiles/search similarity index 100% rename from helpfiles/search rename to files/helpfiles/search diff --git a/helpfiles/semote b/files/helpfiles/semote similarity index 100% rename from helpfiles/semote rename to files/helpfiles/semote diff --git a/helpfiles/set b/files/helpfiles/set similarity index 100% rename from helpfiles/set rename to files/helpfiles/set diff --git a/helpfiles/set_age b/files/helpfiles/set_age similarity index 100% rename from helpfiles/set_age rename to files/helpfiles/set_age diff --git a/helpfiles/set_alert b/files/helpfiles/set_alert similarity index 100% rename from helpfiles/set_alert rename to files/helpfiles/set_alert diff --git a/helpfiles/set_autofwd b/files/helpfiles/set_autofwd similarity index 100% rename from helpfiles/set_autofwd rename to files/helpfiles/set_autofwd diff --git a/helpfiles/set_colour b/files/helpfiles/set_colour similarity index 100% rename from helpfiles/set_colour rename to files/helpfiles/set_colour diff --git a/helpfiles/set_command b/files/helpfiles/set_command similarity index 100% rename from helpfiles/set_command rename to files/helpfiles/set_command diff --git a/helpfiles/set_email b/files/helpfiles/set_email similarity index 100% rename from helpfiles/set_email rename to files/helpfiles/set_email diff --git a/helpfiles/set_gender b/files/helpfiles/set_gender similarity index 100% rename from helpfiles/set_gender rename to files/helpfiles/set_gender diff --git a/helpfiles/set_hide b/files/helpfiles/set_hide similarity index 100% rename from helpfiles/set_hide rename to files/helpfiles/set_hide diff --git a/helpfiles/set_icq b/files/helpfiles/set_icq similarity index 100% rename from helpfiles/set_icq rename to files/helpfiles/set_icq diff --git a/helpfiles/set_pager b/files/helpfiles/set_pager similarity index 100% rename from helpfiles/set_pager rename to files/helpfiles/set_pager diff --git a/helpfiles/set_password b/files/helpfiles/set_password similarity index 100% rename from helpfiles/set_password rename to files/helpfiles/set_password diff --git a/helpfiles/set_rdesc b/files/helpfiles/set_rdesc similarity index 100% rename from helpfiles/set_rdesc rename to files/helpfiles/set_rdesc diff --git a/helpfiles/set_recap b/files/helpfiles/set_recap similarity index 100% rename from helpfiles/set_recap rename to files/helpfiles/set_recap diff --git a/helpfiles/set_revbuf b/files/helpfiles/set_revbuf similarity index 100% rename from helpfiles/set_revbuf rename to files/helpfiles/set_revbuf diff --git a/helpfiles/set_room b/files/helpfiles/set_room similarity index 100% rename from helpfiles/set_room rename to files/helpfiles/set_room diff --git a/helpfiles/set_show b/files/helpfiles/set_show similarity index 100% rename from helpfiles/set_show rename to files/helpfiles/set_show diff --git a/helpfiles/set_wrap b/files/helpfiles/set_wrap similarity index 100% rename from helpfiles/set_wrap rename to files/helpfiles/set_wrap diff --git a/helpfiles/set_www b/files/helpfiles/set_www similarity index 100% rename from helpfiles/set_www rename to files/helpfiles/set_www diff --git a/helpfiles/setcmdlev b/files/helpfiles/setcmdlev similarity index 100% rename from helpfiles/setcmdlev rename to files/helpfiles/setcmdlev diff --git a/helpfiles/sfrom b/files/helpfiles/sfrom similarity index 100% rename from helpfiles/sfrom rename to files/helpfiles/sfrom diff --git a/helpfiles/shackle b/files/helpfiles/shackle similarity index 100% rename from helpfiles/shackle rename to files/helpfiles/shackle diff --git a/helpfiles/shoot b/files/helpfiles/shoot similarity index 100% rename from helpfiles/shoot rename to files/helpfiles/shoot diff --git a/helpfiles/shout b/files/helpfiles/shout similarity index 100% rename from helpfiles/shout rename to files/helpfiles/shout diff --git a/helpfiles/show b/files/helpfiles/show similarity index 100% rename from helpfiles/show rename to files/helpfiles/show diff --git a/helpfiles/shutdown b/files/helpfiles/shutdown similarity index 100% rename from helpfiles/shutdown rename to files/helpfiles/shutdown diff --git a/helpfiles/sing b/files/helpfiles/sing similarity index 100% rename from helpfiles/sing rename to files/helpfiles/sing diff --git a/helpfiles/site b/files/helpfiles/site similarity index 100% rename from helpfiles/site rename to files/helpfiles/site diff --git a/helpfiles/smail b/files/helpfiles/smail similarity index 100% rename from helpfiles/smail rename to files/helpfiles/smail diff --git a/helpfiles/sos b/files/helpfiles/sos similarity index 100% rename from helpfiles/sos rename to files/helpfiles/sos diff --git a/helpfiles/spodlist b/files/helpfiles/spodlist similarity index 100% rename from helpfiles/spodlist rename to files/helpfiles/spodlist diff --git a/helpfiles/sreboot b/files/helpfiles/sreboot similarity index 100% rename from helpfiles/sreboot rename to files/helpfiles/sreboot diff --git a/helpfiles/suggest b/files/helpfiles/suggest similarity index 100% rename from helpfiles/suggest rename to files/helpfiles/suggest diff --git a/helpfiles/suicide b/files/helpfiles/suicide similarity index 100% rename from helpfiles/suicide rename to files/helpfiles/suicide diff --git a/helpfiles/swban b/files/helpfiles/swban similarity index 100% rename from helpfiles/swban rename to files/helpfiles/swban diff --git a/helpfiles/switch b/files/helpfiles/switch similarity index 100% rename from helpfiles/switch rename to files/helpfiles/switch diff --git a/helpfiles/system b/files/helpfiles/system similarity index 100% rename from helpfiles/system rename to files/helpfiles/system diff --git a/helpfiles/tell b/files/helpfiles/tell similarity index 100% rename from helpfiles/tell rename to files/helpfiles/tell diff --git a/helpfiles/think b/files/helpfiles/think similarity index 100% rename from helpfiles/think rename to files/helpfiles/think diff --git a/helpfiles/time b/files/helpfiles/time similarity index 100% rename from helpfiles/time rename to files/helpfiles/time diff --git a/helpfiles/topic b/files/helpfiles/topic similarity index 100% rename from helpfiles/topic rename to files/helpfiles/topic diff --git a/helpfiles/tpromote b/files/helpfiles/tpromote similarity index 100% rename from helpfiles/tpromote rename to files/helpfiles/tpromote diff --git a/helpfiles/twiz b/files/helpfiles/twiz similarity index 100% rename from helpfiles/twiz rename to files/helpfiles/twiz diff --git a/helpfiles/unarrest b/files/helpfiles/unarrest similarity index 100% rename from helpfiles/unarrest rename to files/helpfiles/unarrest diff --git a/helpfiles/unban b/files/helpfiles/unban similarity index 100% rename from helpfiles/unban rename to files/helpfiles/unban diff --git a/helpfiles/uncall b/files/helpfiles/uncall similarity index 100% rename from helpfiles/uncall rename to files/helpfiles/uncall diff --git a/helpfiles/unfix b/files/helpfiles/unfix similarity index 100% rename from helpfiles/unfix rename to files/helpfiles/unfix diff --git a/helpfiles/uninvite b/files/helpfiles/uninvite similarity index 100% rename from helpfiles/uninvite rename to files/helpfiles/uninvite diff --git a/helpfiles/unmuzzle b/files/helpfiles/unmuzzle similarity index 100% rename from helpfiles/unmuzzle rename to files/helpfiles/unmuzzle diff --git a/helpfiles/unretire b/files/helpfiles/unretire similarity index 100% rename from helpfiles/unretire rename to files/helpfiles/unretire diff --git a/helpfiles/unshackle b/files/helpfiles/unshackle similarity index 100% rename from helpfiles/unshackle rename to files/helpfiles/unshackle diff --git a/helpfiles/ustat b/files/helpfiles/ustat similarity index 100% rename from helpfiles/ustat rename to files/helpfiles/ustat diff --git a/helpfiles/verify b/files/helpfiles/verify similarity index 100% rename from helpfiles/verify rename to files/helpfiles/verify diff --git a/helpfiles/version b/files/helpfiles/version similarity index 100% rename from helpfiles/version rename to files/helpfiles/version diff --git a/helpfiles/viewlog b/files/helpfiles/viewlog similarity index 100% rename from helpfiles/viewlog rename to files/helpfiles/viewlog diff --git a/helpfiles/vis b/files/helpfiles/vis similarity index 100% rename from helpfiles/vis rename to files/helpfiles/vis diff --git a/helpfiles/visit b/files/helpfiles/visit similarity index 100% rename from helpfiles/visit rename to files/helpfiles/visit diff --git a/helpfiles/wake b/files/helpfiles/wake similarity index 100% rename from helpfiles/wake rename to files/helpfiles/wake diff --git a/helpfiles/who b/files/helpfiles/who similarity index 100% rename from helpfiles/who rename to files/helpfiles/who diff --git a/helpfiles/wipe b/files/helpfiles/wipe similarity index 100% rename from helpfiles/wipe rename to files/helpfiles/wipe diff --git a/helpfiles/wizlist b/files/helpfiles/wizlist similarity index 100% rename from helpfiles/wizlist rename to files/helpfiles/wizlist diff --git a/helpfiles/write b/files/helpfiles/write similarity index 100% rename from helpfiles/write rename to files/helpfiles/write diff --git a/helpfiles/wrules b/files/helpfiles/wrules similarity index 100% rename from helpfiles/wrules rename to files/helpfiles/wrules diff --git a/helpfiles/xcom b/files/helpfiles/xcom similarity index 100% rename from helpfiles/xcom rename to files/helpfiles/xcom diff --git a/files/logfiles/.gitignore b/files/logfiles/.gitignore new file mode 100644 index 0000000..814dd9c --- /dev/null +++ b/files/logfiles/.gitignore @@ -0,0 +1,2 @@ +syslog.* +last_command.* \ No newline at end of file diff --git a/logfiles/.gitignore b/files/mailspool/.gitkeep similarity index 100% rename from logfiles/.gitignore rename to files/mailspool/.gitkeep diff --git a/files/miscfiles/hangman_words b/files/miscfiles/hangman_words new file mode 100644 index 0000000..b2dbde1 --- /dev/null +++ b/files/miscfiles/hangman_words @@ -0,0 +1,295 @@ +abruptly +absurd +abyss +affix +amphibious +analog +andy +animation +anonymous +anthropomorphize +anything +artwork +askew +attitude +avenue +awkward +axiom +azure +backstabbing +bagpipes +bandwagon +banjo +bayou +beekeeper +beer +bikini +blister +blitz +blizzard +boggle +bookworm +boxcar +boxful +buckaroo +buffalo +buffoon +buxom +buzzard +buzzing +buzzwords +caliph +chastity +cobweb +cockiness +commands +communicator +community +compact +computer +condom +confidence +connection +cosmetic +croquet +crypt +curacao +cycle +daiquiri +desired +desktop +directory +dirndl +disavow +dizzying +duplex +dwarves +education +embezzle +england +equip +espionage +exodus +explorer +faking +familiar +fathom +fishhook +fixable +fjord +flapjack +flopping +fluffiness +flyby +folder +foxglove +frazzled +frizzled +frozen +fuchsia +funny +gabby +galaxy +galvanize +gazebo +giaour +gizmo +glowworm +glyph +gnarly +gnostic +gossip +grogginess +haiku +haphazard +haunted +holiday +hyphen +iatrogenic +icebox +information +injury +interpolate +ivory +ivy +jackpot +jaundice +jawbreaker +jaywalk +jazziest +jazzy +jelly +jigsaw +jinx +jiujitsu +jockey +jogging +joking +jovial +joyful +juicy +jukebox +jumbo +justify +kayak +kazoo +keyhole +khaki +kilobyte +kiosk +kitsch +kiwifruit +klutz +knapsack +larynx +lengths +letter +library +listening +lucky +luxury +lymph +management +marquis +material +matrix +maximum +megahertz +microprocessor +microwave +mnemonic +mystify +naphtha +national +network +nightclub +nowadays +numbskull +nymph +obnoxious +onyx +orgasm +originated +ovary +oxidize +oxygen +pajama +peekaboo +perfectly +perpendicular +phlegm +photograph +pixel +pizazz +plug +pneumonia +polka +preferences +printer +pshaw +psyche +puppy +puzzling +quadragesima +quadruple +qualification +quantify +quartz +question +queue +quips +quixotic +quiz +quizzes +quorum +razzmatazz +recycle +representation +republic +research +responsibilities +restricting +rhubarb +rhythm +rickshaw +schnapps +scratch +shared +shiv +sincerely +snazzy +something +sphinx +spritz +squawk +staff +storage +strength +strengths +stretch +stronghold +studious +stymied +subway +swivel +syllogism +syndrome +talent +talker +thriftless +thumbscrew +together +topaz +transcript +transfer +transgress +transplant +triphthong +twelfth +twelfths +tycoon +unknown +unworthy +unyielding +unzip +uptown +vaporize +vixen +vodka +voodoo +vortex +voyage +voyeurism +walkway +waltz +washer +washington +wave +wavy +waxy +wellspring +wheezy +whiskey +whizzing +whomever +wimpy +witchcraft +wizard +woozy +worried +wristwatch +wyvern +xylophone +yachtsman +yippee +yoked +youthful +yummy +zeal +zephyr +zigzag +zigzagging +zilch +zipper +zodiac +zombie \ No newline at end of file diff --git a/miscfiles/newsfile b/files/miscfiles/newsfile similarity index 94% rename from miscfiles/newsfile rename to files/miscfiles/newsfile index b7e36d7..41f2c6d 100644 --- a/miscfiles/newsfile +++ b/files/miscfiles/newsfile @@ -17,6 +17,6 @@ the talker (instead of readin' this generic thing!) To find out what all the changes are it's best to talk to your admins and ask them all that has changed by telling them to look in the amnuts_changes file that came with Amnuts. Of course, you could also check out the -Amnuts website at: ~OL~FChttp://amnuts.talker.com/~RS if you want! +Amnuts website at: ~OL~FChttps://amnuts.net/~RS if you want! +----------------------------------------------------------------------------+ diff --git a/miscfiles/rules b/files/miscfiles/rules similarity index 86% rename from miscfiles/rules rename to files/miscfiles/rules index f62fccc..6c1f9fb 100644 --- a/miscfiles/rules +++ b/files/miscfiles/rules @@ -1,13 +1,13 @@ +----------------------------------------------------------------------------+ -Rule 1 : No harrassment of any kind is acceptable. +Rule 1 : No harassment of any kind is acceptable. Rule 2 : Please try not to swear in a public area. Although you may not find it offensive some people might. So please try to keep that to private rooms. Rule 3 : Do not ask for a promotion in levels. If you are deemed worthy of promotion, then you will be promoted. Rule 4 : No illegal dealings are to take place in a public area on the talker, - ie, the selling of drugs, illegaly copied materials, pornography, + ie, the selling of drugs, illegally copied materials, pornography, etc. I know it seems a little over the top to be telling you this, but it's for our own interest ;) Rule 5 : No multiple accounts. If you want to change your alias or would like diff --git a/miscfiles/wizrules b/files/miscfiles/wizrules similarity index 91% rename from miscfiles/wizrules rename to files/miscfiles/wizrules index 3dbfaab..302674d 100644 --- a/miscfiles/wizrules +++ b/files/miscfiles/wizrules @@ -8,7 +8,7 @@ Rule 2 : Try to use minimal force to begin with to sort out a problem. Eg, Rule 3 : Do not ask for a promotion in levels. It's bad enough when regular users to this without having to have admins do it too. Rule 4 : No illegal dealings are to take place in a public area on the talker, - ie, the selling of drugs, illegaly copied materials, pornography, + ie, the selling of drugs, illegally copied materials, pornography, etc. I know it seems a little over the top to be telling you this, but it's for our own interest ;) diff --git a/motds/motd1/motd1 b/files/motds/motd1/motd1 similarity index 91% rename from motds/motd1/motd1 rename to files/motds/motd1/motd1 index 6455ef9..2cc202a 100644 --- a/motds/motd1/motd1 +++ b/files/motds/motd1/motd1 @@ -5,7 +5,7 @@ # # # # # ## # # # # # # # # # # ##### # #### ver 2.3.0 +----------------------------------------------------+ -Changed this for whatever your talker screen should be + Change this to suit your talker +----------------------------------------------------+ | type 'who' at the prompt to see who is on | \ type 'quit' at the prompt to quit your login / diff --git a/motds/motd1/motd2 b/files/motds/motd1/motd2 similarity index 100% rename from motds/motd1/motd2 rename to files/motds/motd1/motd2 diff --git a/motds/motd1/motd3 b/files/motds/motd1/motd3 similarity index 90% rename from motds/motd1/motd3 rename to files/motds/motd1/motd3 index f8fe7e3..e0c7c80 100644 --- a/motds/motd1/motd3 +++ b/files/motds/motd1/motd3 @@ -7,6 +7,6 @@ version 2.3.0 (c) Andrew Collington # # # # # ## # # # # # # # # # # ##### # #### +----------------------------------------------------+ -amnuts@talker.com http://amnuts.talker.com/ +talker@amnuts.net https://amnuts.net/ +----------------------------------------------------+ diff --git a/motds/motd2/motd1 b/files/motds/motd2/motd1 similarity index 100% rename from motds/motd2/motd1 rename to files/motds/motd2/motd1 diff --git a/motds/motd2/motd2 b/files/motds/motd2/motd2 similarity index 100% rename from motds/motd2/motd2 rename to files/motds/motd2/motd2 diff --git a/pictfiles/ack b/files/pictfiles/ack similarity index 100% rename from pictfiles/ack rename to files/pictfiles/ack diff --git a/pictfiles/baby b/files/pictfiles/baby similarity index 100% rename from pictfiles/baby rename to files/pictfiles/baby diff --git a/pictfiles/batman b/files/pictfiles/batman similarity index 100% rename from pictfiles/batman rename to files/pictfiles/batman diff --git a/pictfiles/beer b/files/pictfiles/beer similarity index 100% rename from pictfiles/beer rename to files/pictfiles/beer diff --git a/pictfiles/bonsai b/files/pictfiles/bonsai similarity index 100% rename from pictfiles/bonsai rename to files/pictfiles/bonsai diff --git a/pictfiles/bug b/files/pictfiles/bug similarity index 100% rename from pictfiles/bug rename to files/pictfiles/bug diff --git a/pictfiles/bull b/files/pictfiles/bull similarity index 100% rename from pictfiles/bull rename to files/pictfiles/bull diff --git a/pictfiles/bye b/files/pictfiles/bye similarity index 100% rename from pictfiles/bye rename to files/pictfiles/bye diff --git a/pictfiles/calvin b/files/pictfiles/calvin similarity index 100% rename from pictfiles/calvin rename to files/pictfiles/calvin diff --git a/pictfiles/catgal b/files/pictfiles/catgal similarity index 100% rename from pictfiles/catgal rename to files/pictfiles/catgal diff --git a/pictfiles/charm b/files/pictfiles/charm similarity index 100% rename from pictfiles/charm rename to files/pictfiles/charm diff --git a/pictfiles/chilly b/files/pictfiles/chilly similarity index 100% rename from pictfiles/chilly rename to files/pictfiles/chilly diff --git a/pictfiles/cowboy b/files/pictfiles/cowboy similarity index 100% rename from pictfiles/cowboy rename to files/pictfiles/cowboy diff --git a/pictfiles/dancers b/files/pictfiles/dancers similarity index 100% rename from pictfiles/dancers rename to files/pictfiles/dancers diff --git a/pictfiles/dragon b/files/pictfiles/dragon similarity index 100% rename from pictfiles/dragon rename to files/pictfiles/dragon diff --git a/pictfiles/edge b/files/pictfiles/edge similarity index 100% rename from pictfiles/edge rename to files/pictfiles/edge diff --git a/pictfiles/exams b/files/pictfiles/exams similarity index 100% rename from pictfiles/exams rename to files/pictfiles/exams diff --git a/pictfiles/freek b/files/pictfiles/freek similarity index 100% rename from pictfiles/freek rename to files/pictfiles/freek diff --git a/pictfiles/garfield b/files/pictfiles/garfield similarity index 100% rename from pictfiles/garfield rename to files/pictfiles/garfield diff --git a/pictfiles/heart b/files/pictfiles/heart similarity index 100% rename from pictfiles/heart rename to files/pictfiles/heart diff --git a/pictfiles/hi b/files/pictfiles/hi similarity index 100% rename from pictfiles/hi rename to files/pictfiles/hi diff --git a/pictfiles/hot b/files/pictfiles/hot similarity index 100% rename from pictfiles/hot rename to files/pictfiles/hot diff --git a/pictfiles/lips b/files/pictfiles/lips similarity index 100% rename from pictfiles/lips rename to files/pictfiles/lips diff --git a/pictfiles/love b/files/pictfiles/love similarity index 100% rename from pictfiles/love rename to files/pictfiles/love diff --git a/pictfiles/lust b/files/pictfiles/lust similarity index 100% rename from pictfiles/lust rename to files/pictfiles/lust diff --git a/pictfiles/marvin b/files/pictfiles/marvin similarity index 100% rename from pictfiles/marvin rename to files/pictfiles/marvin diff --git a/pictfiles/mickey b/files/pictfiles/mickey similarity index 100% rename from pictfiles/mickey rename to files/pictfiles/mickey diff --git a/pictfiles/mouse2 b/files/pictfiles/mouse2 similarity index 100% rename from pictfiles/mouse2 rename to files/pictfiles/mouse2 diff --git a/pictfiles/mug b/files/pictfiles/mug similarity index 100% rename from pictfiles/mug rename to files/pictfiles/mug diff --git a/pictfiles/nghost b/files/pictfiles/nghost similarity index 100% rename from pictfiles/nghost rename to files/pictfiles/nghost diff --git a/pictfiles/opus b/files/pictfiles/opus similarity index 100% rename from pictfiles/opus rename to files/pictfiles/opus diff --git a/pictfiles/orca b/files/pictfiles/orca similarity index 100% rename from pictfiles/orca rename to files/pictfiles/orca diff --git a/pictfiles/panic b/files/pictfiles/panic similarity index 100% rename from pictfiles/panic rename to files/pictfiles/panic diff --git a/pictfiles/pizza b/files/pictfiles/pizza similarity index 100% rename from pictfiles/pizza rename to files/pictfiles/pizza diff --git a/pictfiles/ppanther b/files/pictfiles/ppanther similarity index 100% rename from pictfiles/ppanther rename to files/pictfiles/ppanther diff --git a/pictfiles/rose b/files/pictfiles/rose similarity index 100% rename from pictfiles/rose rename to files/pictfiles/rose diff --git a/pictfiles/seal b/files/pictfiles/seal similarity index 100% rename from pictfiles/seal rename to files/pictfiles/seal diff --git a/pictfiles/shuttle b/files/pictfiles/shuttle similarity index 100% rename from pictfiles/shuttle rename to files/pictfiles/shuttle diff --git a/pictfiles/sick b/files/pictfiles/sick similarity index 100% rename from pictfiles/sick rename to files/pictfiles/sick diff --git a/pictfiles/skier b/files/pictfiles/skier similarity index 100% rename from pictfiles/skier rename to files/pictfiles/skier diff --git a/pictfiles/smile b/files/pictfiles/smile similarity index 100% rename from pictfiles/smile rename to files/pictfiles/smile diff --git a/pictfiles/surprise b/files/pictfiles/surprise similarity index 100% rename from pictfiles/surprise rename to files/pictfiles/surprise diff --git a/pictfiles/there b/files/pictfiles/there similarity index 100% rename from pictfiles/there rename to files/pictfiles/there diff --git a/pictfiles/twerp b/files/pictfiles/twerp similarity index 100% rename from pictfiles/twerp rename to files/pictfiles/twerp diff --git a/pictfiles/wink b/files/pictfiles/wink similarity index 100% rename from pictfiles/wink rename to files/pictfiles/wink diff --git a/mailspool/.gitignore b/files/reboot/.gitkeep similarity index 100% rename from mailspool/.gitignore rename to files/reboot/.gitkeep diff --git a/textfiles/adminfiles/showfiles b/files/textfiles/adminfiles/showfiles similarity index 100% rename from textfiles/adminfiles/showfiles rename to files/textfiles/adminfiles/showfiles diff --git a/textfiles/colors b/files/textfiles/colors similarity index 100% rename from textfiles/colors rename to files/textfiles/colors diff --git a/textfiles/colours b/files/textfiles/colours similarity index 100% rename from textfiles/colours rename to files/textfiles/colours diff --git a/textfiles/machelp b/files/textfiles/machelp similarity index 100% rename from textfiles/machelp rename to files/textfiles/machelp diff --git a/textfiles/remote b/files/textfiles/remote similarity index 100% rename from textfiles/remote rename to files/textfiles/remote diff --git a/textfiles/showfiles b/files/textfiles/showfiles similarity index 100% rename from textfiles/showfiles rename to files/textfiles/showfiles diff --git a/userfiles/Identduser.D b/files/userfiles/Identduser.D similarity index 100% rename from userfiles/Identduser.D rename to files/userfiles/Identduser.D diff --git a/userfiles/Test.D b/files/userfiles/Test.D similarity index 80% rename from userfiles/Test.D rename to files/userfiles/Test.D index 17e2f2c..f84c8cd 100644 --- a/userfiles/Test.D +++ b/files/userfiles/Test.D @@ -1,12 +1,12 @@ version 0.3 password NUKyNCCLvgLH. promote_date on Saturday 8th December 2001 at 09:04pm -times 1315269289 4090 4 1009740417 +times 1676561659 4098 10 1009740417 levels 6 6 0 0 0 -general -1 0 0 1 1 0 0 7 +general -1 0 0 1 1 0 0 8 user_set 1 0 0 23 1 1 0 0 0 0 1 0 #UNSET 0 user_ignores 0 0 0 0 0 0 0 0 -purging 1 1318725289 +purging 1 1680017659 last_site localhost reception mail_verify #UNSET description - remove this character diff --git a/reboot/.gitignore b/files/userfiles/flagged/.gitkeep similarity index 100% rename from reboot/.gitignore rename to files/userfiles/flagged/.gitkeep diff --git a/src/objects/.gitignore b/files/userfiles/historys/.gitkeep similarity index 100% rename from src/objects/.gitignore rename to files/userfiles/historys/.gitkeep diff --git a/userfiles/flagged/.gitignore b/files/userfiles/macros/.gitkeep similarity index 100% rename from userfiles/flagged/.gitignore rename to files/userfiles/macros/.gitkeep diff --git a/userfiles/historys/.gitignore b/files/userfiles/mail/.gitkeep similarity index 100% rename from userfiles/historys/.gitignore rename to files/userfiles/mail/.gitkeep diff --git a/userfiles/macros/.gitignore b/files/userfiles/profiles/.gitkeep similarity index 100% rename from userfiles/macros/.gitignore rename to files/userfiles/profiles/.gitkeep diff --git a/userfiles/mail/.gitignore b/files/userfiles/reminders/.gitkeep similarity index 100% rename from userfiles/mail/.gitignore rename to files/userfiles/reminders/.gitkeep diff --git a/userfiles/profiles/.gitignore b/files/userfiles/rooms/.gitkeep similarity index 100% rename from userfiles/profiles/.gitignore rename to files/userfiles/rooms/.gitkeep diff --git a/userfiles/reminders/.gitignore b/files/userfiles/xgcoms/.gitkeep similarity index 100% rename from userfiles/reminders/.gitignore rename to files/userfiles/xgcoms/.gitkeep diff --git a/miscfiles/hangman_words b/miscfiles/hangman_words deleted file mode 100644 index 6080dcb..0000000 --- a/miscfiles/hangman_words +++ /dev/null @@ -1,86 +0,0 @@ -talker -letter -washer -washington -england -anthropomorphize -computer -plug -photograph -familiar -interpolate -directory -orgasm -commands -connection -haunted -frozen -studious -desired -maximum -question -anonymous -amphibious -communicator -something -listening -explorer -perfectly -anything -recycle -together -justify -preferences -transfer -attitude -restricting -folder -fathom -microprocessor -perpendicular -syllogism -republic -responsibilities -national -worried -cosmetic -network -confidence -information -education -compact -printer -community -representation -originated -material -shared -artwork -talent -desktop -library -holiday -beer -condom -research -analog -management -sincerely -animation -storage -listening -backstabbing -qualification -zeal -voyage -rhythm -quantify -tycoon -quadragesima -quadruple -unyielding -blister -eunich -chastity -obnoxious -andy diff --git a/src/admin.c b/src/admin.c index d3392ac..19c90fa 100644 --- a/src/admin.c +++ b/src/admin.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -78,11 +77,11 @@ talker_shutdown(UR_OBJECT user, const char *str, int sdboot) /* If someone has changed the binary or the config filename while this prog has been running this will not work */ /* - * XXX: ISO C and historical compatibility introduce anomolies for + * XXX: ISO C and historical compatibility introduce anomalies for * all exec functions. * * execv style will strip const from char specifiers because - * historically there was no const and const cannot be tranparently + * historically there was no const and const cannot be transparently * added to indirect types. * * execl style need a char null pointer because they are variadic @@ -720,8 +719,8 @@ purge(int type, char *purge_site, int purge_days) strcpy(u->name, entry->name); if (!load_user_details(u)) { rem_user_node(u->name); /* get rid of name from userlist */ - clean_files(u->name); /* just incase there are any odd files around */ - clean_retire_list(u->name); /* just incase the user is retired */ + clean_files(u->name); /* just in case there are any odd files around */ + clean_retire_list(u->name); /* just in case the user is retired */ destruct_user(u); destructed = 0; continue; diff --git a/src/amnuts230.c b/src/amnuts.c similarity index 94% rename from src/amnuts230.c rename to src/amnuts.c index bdcbf02..d9da982 100644 --- a/src/amnuts230.c +++ b/src/amnuts.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -141,18 +140,23 @@ main(int argc, char **argv) #endif } - /* Run in background automatically. */ - switch (fork()) { - case -1: - /* fork failure */ - boot_exit(11); - break; - case 0: - /* child continues */ - break; - default: - /* parent dies */ - _exit(0); + /* Run in background automatically unless we're running in a docker container */ + char* run_in_foreground = getenv("IN_FOREGROUND"); + if (run_in_foreground == NULL) { + switch (fork()) { + case -1: + /* fork failure */ + boot_exit(11); + break; + case 0: + /* child continues */ + break; + default: + /* parent dies */ + _exit(0); + } + } else { + printf("Running in foreground..."); } /* XXX: Add setsid() and redirect stdio to /dev/null somewhere */ @@ -779,8 +783,9 @@ accept_connection(int lsock) /* resolve using identd (ArIdent) */ strcpy(hostname, hostaddr); if (amsys->ident_state) { - sprintf(buffer, "SITE: %s\n", hostaddr); + sds buffer = sdscatfmt(sdsempty(), "SITE: %s\n", hostaddr); write_sock(amsys->ident_socket, buffer); + sdsfree(buffer); } break; #endif @@ -3059,7 +3064,7 @@ save_user_details(UR_OBJECT user, int save_current) int load_user_details_old(UR_OBJECT user) { - char line[82], filename[80]; + char line[1024], filename[80]; FILE *fp; int temp1, temp2, temp3, temp4; @@ -3197,7 +3202,7 @@ load_user_details_old(UR_OBJECT user) int load_oldversion_user(UR_OBJECT user, int version) { - char line[81], filename[80]; + char line[1024], filename[80]; FILE *fp; int temp1, temp2, temp3, temp4, oldvote; @@ -3576,7 +3581,7 @@ write_user(UR_OBJECT user, const char *str) cnt = 0; buffpos = 0; for (s = str; *s; ++s) { - /* Flush buffer if above high water mark; + /* Flush buffer if above high watermark; * 6 chars is max a single char can expand into */ if (buffpos > OUT_BUFF_SIZE - 6) { send(user->socket, buff, buffpos, 0); @@ -3596,8 +3601,8 @@ write_user(UR_OBJECT user, const char *str) } else if (*s == '~') { /* Process colour commands eg ~FR. We have to strip out the commands - from the string even if user doesnt have colour switched on hence - the user->colour check isnt done just yet + from the string even if user doesn't have colour switched on hence + the user->colour check isn't done just yet */ for (i = 0; colour_codes[i].txt_code; ++i) { if (!strncmp(s + 1, colour_codes[i].txt_code, @@ -3615,7 +3620,7 @@ write_user(UR_OBJECT user, const char *str) continue; } } else if (*s == '^') { - /* See if its a ^ before a ~ , if so then we print colour command as text */ + /* See if it's a ^ before a ~ , if so then we print colour command as text */ if (s[1] == '~') { ++s; } @@ -3934,7 +3939,7 @@ write_friends(UR_OBJECT user, const char *str, int revt) /* * Write a string to system log * type = what syslog(s) to write to - * write_time = whether or not you have a time stamp imcluded + * write_time = whether you have a time stamp included * str = string passed - possibly with %s, %d, etc * ... = variable length args passed */ @@ -3960,7 +3965,7 @@ write_syslog(int type, int write_time, const char *str, ...) type &= amsys->logging; /* Do not log to turned off logs */ if (type & SYSLOG) { sprintf(filename, "%s/%s.%s", LOGFILES, MAINSYSLOG, dstr); - /* even if do_write_syslog fails, continue incase trying to write to others */ + /* even if do_write_syslog fails, continue in case trying to write to others */ do_write_syslog(filename); } if (type & REQLOG) { @@ -3997,7 +4002,7 @@ do_write_syslog(const char *filename) } /* - * this version of the the last command log - the two procedures below - are + * this version of the last command log - the two procedures below - are * thanks to Karri (The Bat) Kalpio who makes KTserv * record the last command executed - helps find crashes */ @@ -4538,7 +4543,7 @@ login(UR_OBJECT user, char *inpstr) add_history(user->name, 1, "Was initially created.\n"); write_syslog(SYSLOG, 1, "New user \"%s\" created.\n", user->name); ++amsys->logons_new; - /* Check out above for explaination of this */ + /* Check out above for explanation of this */ cls(user); /* If there is no motd2 files then do not display them */ if (amsys->motd2_cnt) { @@ -4587,7 +4592,7 @@ show_login_info(UR_OBJECT user) static const char *const see[] = {"~OL~FYinvisible", "~OL~FCvisible"}; static const char *const myoffon[] = {"~OL~FCoff", "~OL~FRon "}; static const char *const times[] = {"morning", "afternoon", "evening"}; - char temp[ARR_SIZE], text2[ARR_SIZE]; + char temp[ARR_SIZE], text[ARR_SIZE * 2], text2[ARR_SIZE]; time_t now; const struct tm *date; int yes, cnt, phase, exline; @@ -4844,7 +4849,9 @@ connect_user(UR_OBJECT user) vwrite_user(user, "\nYou are connecting%s.\n\n", rmname); } } - sdsfree(rmname); + if (rmname != NULL) { + sdsfree(rmname); + } logon_flag = 0; ++user->logons; alert_friends(user); @@ -4941,7 +4948,7 @@ disconnect_user(UR_OBJECT user) user->misc_op = 0; user->edit_op = 0; user->edit_line = 0; - /* reset ignore status--incase user was in the editor */ + /* reset ignore status--in case user was in the editor */ user->ignall = user->ignall_store; } save_user_details(user, 1); @@ -6120,7 +6127,7 @@ login_who(UR_OBJECT user) write_user(user, "\n+----------------------------------------------------------------------------+\n"); write_user(user, - align_string(1, 78, 0, NULL, "Current users %s", long_date(1))); + align_string(ALIGN_CENTRE, 78, 0, NULL, "Current users %s", long_date(1))); write_user(user, "+----------------------------------------------------------------------------+\n\n"); @@ -6140,6 +6147,7 @@ login_who(UR_OBJECT user) userText = sdscat(userText, repeat_string(" ", len)); } lineText = sdscat(lineText, userText); + sdsfree(userText); if (!(++on % 4)) { lineText = sdscat(lineText, "\n"); write_user(user, lineText); @@ -6152,262 +6160,18 @@ login_who(UR_OBJECT user) } if (!(on + invis)) { write_user(user, - align_string(1, 78, 0, NULL, + align_string(ALIGN_CENTRE, 78, 0, NULL, "No users are currently logged on\n")); } else { write_user(user, "\n"); write_user(user, - align_string(1, 78, 0, NULL, + align_string(ALIGN_CENTRE, 78, 0, NULL, "%d user%s logged on, %d %s invis", on + invis, PLTEXT_S(on + invis), invis, PLTEXT_IS(invis))); } write_user(user, "+----------------------------------------------------------------------------+\n"); sdsfree(lineText); - sdsfree(userText); -} - -/* - * Show the command available listed by level - */ -void -help_commands_level(UR_OBJECT user) -{ - int cnt, total, highlight; - enum lvl_value lvl; - sds temp, temp1; - CMD_OBJECT cmd; - - start_pager(user); - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "| All commands start with a \".\" (when in ~FYspeech~RS mode) and can be abbreviated |\n"); - write_user(user, - "| Remember, a \".\" by itself will repeat your last command or speech |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - align_string(1, 78, 1, "|", - " Commands available to you (level ~OL%s~RS) ", - user_level[user->level].name)); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - total = 0; - for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { - if (user->level < lvl) { - break; - } - cnt = 0; - *text = '\0'; - sprintf(text, " ~FG~OL%-1.1s)~RS ~FC", user_level[lvl].name); - highlight = 1; - /* scroll through all commands, format and print */ - for (cmd = first_command; cmd; cmd = cmd->next) { - temp1 = sdsempty(); - if (cmd->level != lvl) { - continue; - } - if (has_xcom(user, cmd->id)) { - temp1 = sdscatfmt(sdsempty(), "~FR%s~RS%s %s", cmd->name, highlight ? "~FC" : "", - cmd->alias); - } else { - temp1 = sdscatfmt(sdsempty(), "%s %s", cmd->name, cmd->alias); - } - if (++cnt == 5) { - strcat(text, temp1); - strcat(text, "~RS"); - write_user(user, align_string(0, 78, 1, "|", "%s", text)); - cnt = 0; - highlight = 0; - *text = '\0'; - } else { - temp = sdscatprintf(sdsempty(), "%-*s ", 11 + (int) teslen(temp1, 0), temp1); - strcat(text, temp); - } - if (!cnt) { - strcat(text, " "); - } - } - if (cnt > 0 && cnt < 5) - write_user(user, align_string(0, 78, 1, "|", "%s", text)); - } - /* count up total number of commands for user level */ - for (cmd = first_command; cmd; cmd = cmd->next) { - if (cmd->level > user->level) { - continue; - } - ++total; - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - align_string(0, 78, 1, "|", - " There is a total of ~OL%d~RS command%s that you can use ", - total, PLTEXT_S(total))); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - stop_pager(user); - sdsfree(temp); - sdsfree(temp1); -} - -/* - * Show the command available listed by function - */ -void -help_commands_function(UR_OBJECT user) -{ - sds temp, temp1; - CMD_OBJECT cmd; - int cnt, total, function, found; - - start_pager(user); - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "| All commands start with a \".\" (when in ~FYspeech~RS mode) and can be abbreviated |\n"); - write_user(user, - "| Remember, a \".\" by itself will repeat your last command or speech |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - align_string(1, 78, 1, "|", - " Commands available to you (level ~OL%s~RS) ", - user_level[user->level].name)); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - /* scroll through all the commands listing by function */ - total = 0; - for (function = 0; command_types[function]; ++function) { - cnt = 0; - found = 0; - *text = '\0'; - /* scroll through all commands, format and print */ - for (cmd = first_command; cmd; cmd = cmd->next) { - temp1 = sdsempty(); - if (cmd->level > user->level || cmd->function != function) { - continue; - } - if (!found++) { - write_user(user, - align_string(0, 78, 1, "|", " ~OL~FG%s~RS ", - command_types[function])); - strcpy(text, " "); - } - if (has_xcom(user, cmd->id)) { - temp1 = sdscatfmt(sdsempty(), "~FR%s~RS %s", cmd->name, cmd->alias); - } else { - temp1 = sdscatfmt(sdsempty(), "%s %s", cmd->name, cmd->alias); - } - if (++cnt == 5) { - strcat(text, temp1); - strcat(text, "~RS"); - write_user(user, align_string(0, 78, 1, "|", "%s", text)); - cnt = 0; - *text = '\0'; - } else { - temp = sdscatprintf(sdsempty(), "%-*s ", 11 + (int) teslen(temp1, 0), temp1); - strcat(text, temp); - } - if (!cnt) { - strcat(text, " "); - } - } - if (cnt > 0 && cnt < 5) - write_user(user, align_string(0, 78, 1, "|", "%s", text)); - } - /* count up total number of commands for user level */ - for (cmd = first_command; cmd; cmd = cmd->next) { - if (cmd->level > user->level) { - continue; - } - ++total; - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - align_string(0, 78, 1, "|", - " There is a total of ~OL%d~RS command%s that you can use ", - total, PLTEXT_S(total))); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - stop_pager(user); - sdsfree(temp); - sdsfree(temp1); -} - -/* - * Show NUTS credits - */ -void -help_nuts_credits(UR_OBJECT user) -{ - write_user(user, - "\n~BB*** NUTS Credits :) (for Amnuts credits, see \".help credits\") ***\n\n"); - vwrite_user(user, - "~BRNUTS version %s, Copyright (C) Neil Robertson 1996.\n\n", - NUTSVER); - write_user(user, - "~BM ~BB ~BC ~BG ~BY ~BR \n"); - write_user(user, - "NUTS stands for Neil's Unix Talk Server, a program which started out as a\n"); - write_user(user, - "university project in autumn 1992 and has progressed from thereon. In no\n"); - write_user(user, - "particular order thanks go to the following people who helped me develop or\n"); - write_user(user, "debug this code in one way or another over the years:\n"); - write_user(user, - " ~FCDarren Seryck, Steve Guest, Dave Temple, Satish Bedi, Tim Bernhardt,\n"); - write_user(user, - " ~FCKien Tran, Jesse Walton, Pak Chan, Scott MacKenzie and Bryan McPhail.\n"); - write_user(user, - "Also thanks must go to anyone else who has emailed me with ideas and/or bug\n"); - write_user(user, - "reports and all the people who have used NUTS over the intervening years.\n"); - write_user(user, - "I know I have said this before but this time I really mean it--this is the final\n"); - write_user(user, - "version of NUTS 3. In a few years NUTS 4 may spring forth but in the meantime\n"); - write_user(user, "that, as they say, is that. :)\n\n"); - write_user(user, - "If you wish to email me my address is \"~FGneil@ogham.demon.co.uk~RS\" and should\n"); - write_user(user, - "remain so for the forseeable future.\n\nNeil Robertson - November 1996.\n"); - write_user(user, - "~BM ~BB ~BC ~BG ~BY ~BR \n\n"); -} - -/* - * Show the credits. Add your own credits here if you wish but PLEASE leave - * my credits intact. Thanks. - */ -void -help_amnuts_credits(UR_OBJECT user) -{ - write_user(user, - "~BM ~BB ~BC ~BG ~BY ~BR \n\n"); - vwrite_user(user, - "~OL~FCAmnuts version %s~RS, Copyright (C) Andrew Collington, 2003\n", - AMNUTSVER); - write_user(user, - "Brought to you by the Amnuts Development Group (Andy, Ardant and Uzume)\n\n"); - write_user(user, - "Amnuts stands for ~OLA~RSndy's ~OLM~RSodified ~OLNUTS~RS, a Unix talker server written in C.\n\n"); - write_user(user, - "Many thanks to everyone who has helped out with Amnuts. Special thanks go to\n"); - write_user(user, - "Ardant, Uzume, Arny (of Paris fame), Silver (of PG+ fame), and anyone else who\n"); - write_user(user, - "has contributed at all to the development of Amnuts.\n\n"); - write_user(user, - "If you are interested, you can purchase Amnuts t-shirts, mugs, mousemats, and\n"); - write_user(user, - "more, from http://www.cafepress.com/amnuts/\n\nWe hope you enjoy the talker!\n\n"); - write_user(user, - " -- The Amnuts Development Group\n\n(for NUTS credits, see \".help nuts\")\n"); - write_user(user, - "\n~BM ~BB ~BC ~BG ~BY ~BR \n\n"); } void @@ -6788,7 +6552,7 @@ user_is_friend(UR_OBJECT user, UR_OBJECT u) /* * Alert anyone logged on who has user in their friends - * list that the user has just loged on + * list that the user has just logged on */ void alert_friends(UR_OBJECT user) @@ -6888,7 +6652,7 @@ scalar_to_ymd(long scalar, int *yr, int *mo, int *dy) } /* - * determine if the y/m/d given is todays date + * determine if the y/m/d given is today's date */ int is_ymd_today(int yr, int mo, int dy) diff --git a/src/commands/account.c b/src/commands/account.c index 2610f3a..4ffaba5 100644 --- a/src/commands/account.c +++ b/src/commands/account.c @@ -1,106 +1,106 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Create an account for a user if new users from their site have been - * banned and they want to log on - you know they aint a trouble maker, etc - */ -void -create_account(UR_OBJECT user) -{ - UR_OBJECT u; - int i; - - if (word_count < 3) { - write_user(user, "Usage: create \n"); - return; - } - if (find_user_listed(word[1])) { - write_user(user, - "You cannot create with the name of an existing user!\n"); - return; - } - for (i = 0; word[1][i]; ++i) { - if (!isalpha(word[1][i])) { - break; - } - } - if (word[1][i]) { - write_user(user, - "You cannot have anything but letters in the name - account not created.\n\n"); - return; - } - if (i < USER_NAME_MIN) { - write_user(user, "Name was too short--account not created.\n"); - return; - } - if (i > USER_NAME_LEN) { - write_user(user, "Name was too long--account not created.\n"); - return; - } - if (contains_swearing(word[1])) { - write_user(user, - "You cannot use a name like that--account not created.\n\n"); - return; - } - i = strlen(word[2]); - if (i < PASS_MIN) { - write_user(user, "Password was too short--account not created.\n"); - return; - } - i = strlen(word[2]); - /* Via use of crypt() */ - if (i > 8) { - write_user(user, - "WARNING: Only the first eight characters of password will be used!\n"); - } - u = create_user(); - if (!u) { - vwrite_user(user, "%s: unable to create temporary user session.\n", - syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to create temporary user session in create_account().\n"); - return; - } - strtolower(word[1]); - *word[1] = toupper(*word[1]); - strcpy(u->name, word[1]); - if (!load_user_details(u)) { - strcpy(u->pass, crypt(word[2], crypt_salt)); - strcpy(u->recap, u->name); - strcpy(u->desc, "is a newbie"); - strcpy(u->in_phrase, "wanders in."); - strcpy(u->out_phrase, "wanders out"); - strcpy(u->last_site, "created_account"); - strcpy(u->site, u->last_site); - strcpy(u->logout_room, ""); - *u->verify_code = '\0'; - *u->email = '\0'; - *u->homepage = '\0'; - *u->icq = '\0'; - u->prompt = amsys->prompt_def; - u->charmode_echo = 0; - u->room = room_first; - u->level = NEW; - u->unarrest = NEW; - save_user_details(u, 0); - add_user_node(u->name, u->level); - add_user_date_node(u->name, (long_date(1))); - sprintf(text, "Was manually created by %s.\n", user->name); - add_history(u->name, 1, "%s", text); - vwrite_user(user, - "You have created an account with the name \"~FC%s~RS\" and password \"~FG%s~RS\".\n", - u->name, word[2]); - write_syslog(SYSLOG, 1, "%s created a new account with the name \"%s\"\n", - user->name, u->name); - destruct_user(u); - destructed = 0; - return; - } - write_user(user, - "You cannot create an account with the name of an existing user!\n"); - destruct_user(u); - destructed = 0; -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Create an account for a user if new users from their site have been + * banned, and they want to log on - you know they ain't a troublemaker, etc + */ +void +create_account(UR_OBJECT user) +{ + UR_OBJECT u; + int i; + + if (word_count < 3) { + write_user(user, "Usage: create \n"); + return; + } + if (find_user_listed(word[1])) { + write_user(user, + "You cannot create with the name of an existing user!\n"); + return; + } + for (i = 0; word[1][i]; ++i) { + if (!isalpha(word[1][i])) { + break; + } + } + if (word[1][i]) { + write_user(user, + "You cannot have anything but letters in the name - account not created.\n\n"); + return; + } + if (i < USER_NAME_MIN) { + write_user(user, "Name was too short--account not created.\n"); + return; + } + if (i > USER_NAME_LEN) { + write_user(user, "Name was too long--account not created.\n"); + return; + } + if (contains_swearing(word[1])) { + write_user(user, + "You cannot use a name like that--account not created.\n\n"); + return; + } + i = strlen(word[2]); + if (i < PASS_MIN) { + write_user(user, "Password was too short--account not created.\n"); + return; + } + i = strlen(word[2]); + /* Via use of crypt() */ + if (i > 8) { + write_user(user, + "WARNING: Only the first eight characters of password will be used!\n"); + } + u = create_user(); + if (!u) { + vwrite_user(user, "%s: unable to create temporary user session.\n", + syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to create temporary user session in create_account().\n"); + return; + } + strtolower(word[1]); + *word[1] = toupper(*word[1]); + strcpy(u->name, word[1]); + if (!load_user_details(u)) { + strcpy(u->pass, crypt(word[2], crypt_salt)); + strcpy(u->recap, u->name); + strcpy(u->desc, "is a newbie"); + strcpy(u->in_phrase, "wanders in."); + strcpy(u->out_phrase, "wanders out"); + strcpy(u->last_site, "created_account"); + strcpy(u->site, u->last_site); + strcpy(u->logout_room, ""); + *u->verify_code = '\0'; + *u->email = '\0'; + *u->homepage = '\0'; + *u->icq = '\0'; + u->prompt = amsys->prompt_def; + u->charmode_echo = 0; + u->room = room_first; + u->level = NEW; + u->unarrest = NEW; + save_user_details(u, 0); + add_user_node(u->name, u->level); + add_user_date_node(u->name, (long_date(1))); + sprintf(text, "Was manually created by %s.\n", user->name); + add_history(u->name, 1, "%s", text); + vwrite_user(user, + "You have created an account with the name \"~FC%s~RS\" and password \"~FG%s~RS\".\n", + u->name, word[2]); + write_syslog(SYSLOG, 1, "%s created a new account with the name \"%s\"\n", + user->name, u->name); + destruct_user(u); + destructed = 0; + return; + } + write_user(user, + "You cannot create an account with the name of an existing user!\n"); + destruct_user(u); + destructed = 0; +} diff --git a/src/commands/accreq.c b/src/commands/accreq.c index fbe1c50..c488b23 100644 --- a/src/commands/accreq.c +++ b/src/commands/accreq.c @@ -1,45 +1,45 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * A newbie is requesting an account. Get his email address off him so we - * can validate who he is before we promote him and let him loose as a - * proper user. - */ -void -account_request(UR_OBJECT user, char *inpstr) -{ - if (user->level != NEW) { - write_user(user, - "This command is for new users only, you already have a full account.\n"); - return; - } - /* stop them from requesting an account twice */ - if (user->accreq & BIT(3)) { - write_user(user, "You have already requested an account.\n"); - return; - } - if (word_count < 2) { - write_user(user, "Usage: accreq []\n"); - return; - } - if (!validate_email(word[1])) { - write_user(user, - "That email address format is incorrect. Correct format: user@network.net\n"); - return; - } - write_syslog(REQLOG, 1, "%-*s : %s\n", USER_NAME_LEN, user->name, inpstr); - vwrite_level(WIZ, 1, RECORD, user, - "~OLSYSTEM:~RS %s~RS has made an account request with: %s\n", - user->recap, inpstr); - write_user(user, "Account request logged.\n"); - add_history(user->name, 1, "Made a request for an account.\n"); - /* permanent record of email address in user history file */ - sprintf(text, "Used email address \"%s\" in the request.\n", word[1]); - add_history(user->name, 1, "%s", text); - /* check to see if user should be promoted yet */ - check_autopromote(user, 3); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * A newbie is requesting an account. Get his email address off him so we + * can validate who he is before we promote him and let him loose as a + * proper user. + */ +void +account_request(UR_OBJECT user, char *inpstr) +{ + if (user->level != NEW) { + write_user(user, + "This command is for new users only, you already have a full account.\n"); + return; + } + /* stop them from requesting an account twice */ + if (user->accreq & BIT(3)) { + write_user(user, "You have already requested an account.\n"); + return; + } + if (word_count < 2) { + write_user(user, "Usage: accreq []\n"); + return; + } + if (!validate_email(word[1])) { + write_user(user, + "That email address format is incorrect. Correct format: user@network.net\n"); + return; + } + write_syslog(REQLOG, 1, "%-*s : %s\n", USER_NAME_LEN, user->name, inpstr); + vwrite_level(WIZ, 1, RECORD, user, + "~OLSYSTEM:~RS %s~RS has made an account request with: %s\n", + user->recap, inpstr); + write_user(user, "Account request logged.\n"); + add_history(user->name, 1, "Made a request for an account.\n"); + /* permanent record of email address in user history file */ + sprintf(text, "Used email address \"%s\" in the request.\n", word[1]); + add_history(user->name, 1, "%s", text); + /* check to see if user should be promoted yet */ + check_autopromote(user, 3); +} diff --git a/src/commands/addhistory.c b/src/commands/addhistory.c index 9ee212b..bf74180 100644 --- a/src/commands/addhistory.c +++ b/src/commands/addhistory.c @@ -1,30 +1,30 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * allows a user to add to another users history list - */ -void -manual_history(UR_OBJECT user, char *inpstr) -{ - if (word_count < 3) { - write_user(user, "Usage: addhistory \n"); - return; - } - *word[1] = toupper(*word[1]); - if (!strcmp(user->name, word[1])) { - write_user(user, "You cannot add to your own history list.\n"); - return; - } - if (!find_user_listed(word[1])) { - write_user(user, nosuchuser); - return; - } - inpstr = remove_first(inpstr); - sprintf(text, "%-*s : %s\n", USER_NAME_LEN, user->name, inpstr); - add_history(word[1], 1, "%s", text); - vwrite_user(user, "You have added to %s's history list.\n", word[1]); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * allows a user to add to another users history list + */ +void +manual_history(UR_OBJECT user, char *inpstr) +{ + if (word_count < 3) { + write_user(user, "Usage: addhistory \n"); + return; + } + *word[1] = toupper(*word[1]); + if (!strcmp(user->name, word[1])) { + write_user(user, "You cannot add to your own history list.\n"); + return; + } + if (!find_user_listed(word[1])) { + write_user(user, nosuchuser); + return; + } + inpstr = remove_first(inpstr); + sprintf(text, "%-*s : %s\n", USER_NAME_LEN, user->name, inpstr); + add_history(word[1], 1, "%s", text); + vwrite_user(user, "You have added to %s's history list.\n", word[1]); } \ No newline at end of file diff --git a/src/commands/afk.c b/src/commands/afk.c index 46c73d8..5416136 100644 --- a/src/commands/afk.c +++ b/src/commands/afk.c @@ -1,64 +1,64 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Do AFK - */ -void -afk(UR_OBJECT user, char *inpstr) -{ - if (word_count > 1) { - if (!strcmp(word[1], "lock")) { -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - /* - This is because they might not have a local account and hence - they have no password to use. - */ - write_user(user, - "Sorry, due to software limitations remote users cannot use the lock option.\n"); - return; - } -#endif - inpstr = remove_first(inpstr); - if (strlen(inpstr) > AFK_MESG_LEN) { - write_user(user, "AFK message too long.\n"); - return; - } - write_user(user, - "You are now AFK with the session locked, enter your password to unlock it.\n"); - if (*inpstr) { - strcpy(user->afk_mesg, inpstr); - write_user(user, "AFK message set.\n"); - } - user->afk = 2; - } else { - if (strlen(inpstr) > AFK_MESG_LEN) { - write_user(user, "AFK message too long.\n"); - return; - } - write_user(user, "You are now AFK, press to reset.\n"); - if (*inpstr) { - strcpy(user->afk_mesg, inpstr); - write_user(user, "AFK message set.\n"); - } - user->afk = 1; - } - } else { - write_user(user, "You are now AFK, press to reset.\n"); - user->afk = 1; - } - if (user->vis) { - if (*user->afk_mesg) { - vwrite_room_except(user->room, user, "%s~RS goes AFK: %s\n", - user->recap, user->afk_mesg); - } else { - vwrite_room_except(user->room, user, "%s~RS goes AFK...\n", - user->recap); - } - } - clear_afk(user); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Do AFK + */ +void +afk(UR_OBJECT user, char *inpstr) +{ + if (word_count > 1) { + if (!strcmp(word[1], "lock")) { +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + /* + This is because they might not have a local account and hence + they have no password to use. + */ + write_user(user, + "Sorry, due to software limitations remote users cannot use the lock option.\n"); + return; + } +#endif + inpstr = remove_first(inpstr); + if (strlen(inpstr) > AFK_MESG_LEN) { + write_user(user, "AFK message too long.\n"); + return; + } + write_user(user, + "You are now AFK with the session locked, enter your password to unlock it.\n"); + if (*inpstr) { + strcpy(user->afk_mesg, inpstr); + write_user(user, "AFK message set.\n"); + } + user->afk = 2; + } else { + if (strlen(inpstr) > AFK_MESG_LEN) { + write_user(user, "AFK message too long.\n"); + return; + } + write_user(user, "You are now AFK, press to reset.\n"); + if (*inpstr) { + strcpy(user->afk_mesg, inpstr); + write_user(user, "AFK message set.\n"); + } + user->afk = 1; + } + } else { + write_user(user, "You are now AFK, press to reset.\n"); + user->afk = 1; + } + if (user->vis) { + if (*user->afk_mesg) { + vwrite_room_except(user->room, user, "%s~RS goes AFK: %s\n", + user->recap, user->afk_mesg); + } else { + vwrite_room_except(user->room, user, "%s~RS goes AFK...\n", + user->recap); + } + } + clear_afk(user); +} diff --git a/src/commands/allclones.c b/src/commands/allclones.c index ad25755..b874ba3 100644 --- a/src/commands/allclones.c +++ b/src/commands/allclones.c @@ -1,31 +1,31 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show all clones on the system - */ -void -allclones(UR_OBJECT user) -{ - UR_OBJECT u; - int cnt; - - cnt = 0; - for (u = user_first; u; u = u->next) { - if (u->type != CLONE_TYPE) { - continue; - } - if (!cnt++) { - vwrite_user(user, "\n~BB*** Current clones %s ***\n\n", long_date(1)); - } - vwrite_user(user, "%-15s : %s\n", u->name, u->room->name); - } - if (!cnt) { - write_user(user, "There are no clones on the system.\n"); - } else { - vwrite_user(user, "\nTotal of ~OL%d~RS clone%s.\n\n", cnt, PLTEXT_S(cnt)); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show all clones on the system + */ +void +allclones(UR_OBJECT user) +{ + UR_OBJECT u; + int cnt; + + cnt = 0; + for (u = user_first; u; u = u->next) { + if (u->type != CLONE_TYPE) { + continue; + } + if (!cnt++) { + vwrite_user(user, "\n~BB*** Current clones %s ***\n\n", long_date(1)); + } + vwrite_user(user, "%-15s : %s\n", u->name, u->room->name); + } + if (!cnt) { + write_user(user, "There are no clones on the system.\n"); + } else { + vwrite_user(user, "\nTotal of ~OL%d~RS clone%s.\n\n", cnt, PLTEXT_S(cnt)); + } +} diff --git a/src/commands/arrest.c b/src/commands/arrest.c index 1008659..d15319b 100644 --- a/src/commands/arrest.c +++ b/src/commands/arrest.c @@ -1,80 +1,80 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Put annoying user in jail - */ -void -arrest(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - int on; - - if (word_count < 2) { - write_user(user, "Usage: arrest \n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - /* error checks */ - if (u == user) { - write_user(user, "You cannot arrest yourself.\n"); - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot arrest anyone of the same or higher level than yourself.\n"); - done_retrieve(u); - return; - } - if (u->level == JAILED) { - vwrite_user(user, "%s~RS has already been arrested.\n", u->recap); - done_retrieve(u); - return; - } - /* do it */ - u->vis = 1; - u->unarrest = u->level; - u->arrestby = user->level; - u->level = JAILED; - u->real_level = u->level; - user_list_level(u->name, u->level); - strcpy(u->date, (long_date(1))); - sprintf(text, "~FR~OLYou have been placed under arrest.\n"); - if (!on) { - send_mail(user, u->name, text, 0); - vwrite_user(user, "%s has been placed under arrest.\n", u->name); - } else { - write_user(u, text); - vwrite_user(user, "%s has been placed under arrest.\n", u->name); - write_room(NULL, "The Hand of Justice reaches through the air...\n"); - rm = get_room_full(amsys->default_jail); - if (!rm) { - vwrite_user(user, - "Cannot find the jail, so %s~RS is arrested but still in the %s.\n", - u->recap, u->room->name); - } else { - move_user(u, rm, 2); - } - vwrite_room_except_both(NULL, user, u, - "%s~RS has been placed under arrest...\n", - u->recap); - } - write_syslog(SYSLOG, 1, "%s ARRESTED %s (at level %s)\n", user->name, - u->name, user_level[u->arrestby].name); - add_history(u->name, 1, "Was ~FRarrested~RS by %s (at level ~OL%s~RS).\n", - user->name, user_level[u->arrestby].name); - if (!on) { - u->socket = -2; - strcpy(u->site, u->last_site); - } - save_user_details(u, on); - done_retrieve(u); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Put annoying user in jail + */ +void +arrest(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + int on; + + if (word_count < 2) { + write_user(user, "Usage: arrest \n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + /* error checks */ + if (u == user) { + write_user(user, "You cannot arrest yourself.\n"); + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot arrest anyone of the same or higher level than yourself.\n"); + done_retrieve(u); + return; + } + if (u->level == JAILED) { + vwrite_user(user, "%s~RS has already been arrested.\n", u->recap); + done_retrieve(u); + return; + } + /* do it */ + u->vis = 1; + u->unarrest = u->level; + u->arrestby = user->level; + u->level = JAILED; + u->real_level = u->level; + user_list_level(u->name, u->level); + strcpy(u->date, (long_date(1))); + sprintf(text, "~FR~OLYou have been placed under arrest.\n"); + if (!on) { + send_mail(user, u->name, text, 0); + vwrite_user(user, "%s has been placed under arrest.\n", u->name); + } else { + write_user(u, text); + vwrite_user(user, "%s has been placed under arrest.\n", u->name); + write_room(NULL, "The Hand of Justice reaches through the air...\n"); + rm = get_room_full(amsys->default_jail); + if (!rm) { + vwrite_user(user, + "Cannot find the jail, so %s~RS is arrested but still in the %s.\n", + u->recap, u->room->name); + } else { + move_user(u, rm, 2); + } + vwrite_room_except_both(NULL, user, u, + "%s~RS has been placed under arrest...\n", + u->recap); + } + write_syslog(SYSLOG, 1, "%s ARRESTED %s (at level %s)\n", user->name, + u->name, user_level[u->arrestby].name); + add_history(u->name, 1, "Was ~FRarrested~RS by %s (at level ~OL%s~RS).\n", + user->name, user_level[u->arrestby].name); + if (!on) { + u->socket = -2; + strcpy(u->site, u->last_site); + } + save_user_details(u, on); + done_retrieve(u); } \ No newline at end of file diff --git a/src/commands/ban.c b/src/commands/ban.c index cf67d3b..ebc3abe 100644 --- a/src/commands/ban.c +++ b/src/commands/ban.c @@ -1,34 +1,34 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Ban a site, domain or user - */ -void -ban(UR_OBJECT user) -{ - static const char usage[] = - "Usage: ban site|user|new ||\n"; - - if (word_count < 3) { - write_user(user, usage); - return; - } - strtolower(word[1]); - if (!strcmp(word[1], "site")) { - ban_site(user); - return; - } - if (!strcmp(word[1], "user")) { - ban_user(user); - return; - } - if (!strcmp(word[1], "new")) { - ban_new(user); - return; - } - write_user(user, usage); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Ban a site, domain or user + */ +void +ban(UR_OBJECT user) +{ + static const char usage[] = + "Usage: ban site|user|new ||\n"; + + if (word_count < 3) { + write_user(user, usage); + return; + } + strtolower(word[1]); + if (!strcmp(word[1], "site")) { + ban_site(user); + return; + } + if (!strcmp(word[1], "user")) { + ban_user(user); + return; + } + if (!strcmp(word[1], "new")) { + ban_new(user); + return; + } + write_user(user, usage); +} diff --git a/src/commands/bcast.c b/src/commands/bcast.c index 7b81916..7ef7b7d 100644 --- a/src/commands/bcast.c +++ b/src/commands/bcast.c @@ -1,51 +1,51 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Broadcast an important message - */ -void -bcast(UR_OBJECT user, char *inpstr, int beeps) -{ - static const char usage[] = "Usage: bcast \n"; - static const char busage[] = "Usage: bbcast \n"; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot broadcast.\n"); - return; - } - if (word_count < 2) { - switch (beeps) { - case 0: - write_user(user, usage); - return; - case 1: - write_user(user, busage); - return; - } - } - /* wizzes should be trusted...But they are not! */ - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - force_listen = 1; - write_monitor(user, NULL, 0); - vwrite_room(NULL, "%s~OL~FR--==<~RS %s~RS ~OL~FR>==--\n", - beeps ? "\007" : "", inpstr); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Broadcast an important message + */ +void +bcast(UR_OBJECT user, char *inpstr, int beeps) +{ + static const char usage[] = "Usage: bcast \n"; + static const char busage[] = "Usage: bbcast \n"; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot broadcast.\n"); + return; + } + if (word_count < 2) { + switch (beeps) { + case 0: + write_user(user, usage); + return; + case 1: + write_user(user, busage); + return; + } + } + /* wizzes should be trusted...But they are not! */ + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + force_listen = 1; + write_monitor(user, NULL, 0); + vwrite_room(NULL, "%s~OL~FR--==<~RS %s~RS ~OL~FR>==--\n", + beeps ? "\007" : "", inpstr); +} diff --git a/src/commands/beep.c b/src/commands/beep.c index e03a077..22e6ad7 100644 --- a/src/commands/beep.c +++ b/src/commands/beep.c @@ -1,90 +1,90 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Beep a user - as tell but with audio warning - */ -void -beep(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: beep []\n"; - const char *name; - UR_OBJECT u; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot beep.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "Beeping yourself is yet another sign of madness!\n"); - return; - } - if (check_igusers(u, user) && user->level < GOD) { - vwrite_user(user, "%s~RS is ignoring beeps from you.\n", u->recap); - return; - } - if (u->ignbeeps && (user->level < WIZ || u->level > user->level)) { - vwrite_user(user, "%s~RS is ignoring beeps at the moment.\n", u->recap); - return; - } - if (u->afk) { - write_user(user, "You cannot beep someone who is AFK.\n"); - return; - } - if (u->malloc_start) { - vwrite_user(user, "%s~RS is writing a message at the moment.\n", - u->recap); - return; - } - if (u->ignall && (user->level < WIZ || u->level > user->level)) { - vwrite_user(user, "%s~RS is not listening at the moment.\n", u->recap); - return; - } -#ifdef NETLINKS - if (!u->room) { - vwrite_user(user, - "%s~RS is offsite and would not be able to reply to you.\n", - u->recap); - return; - } -#endif - name = user->vis || u->level >= user->level ? user->recap : invisname; - if (word_count < 3) { - vwrite_user(u, "\007%s~RS ~OL~FRbeeps to you~RS: ~FR-=[*] BEEP [*]=-\n", - name); - vwrite_user(user, "\007You ~OL~FRbeep to~RS %s~RS: ~FR-=[*] BEEP [*]=-\n", - u->recap); - return; - } - inpstr = remove_first(inpstr); - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - vwrite_user(u, "\007%s~RS ~OL~FRbeeps to you~RS: %s\n", name, inpstr); - vwrite_user(user, "\007You ~OL~FRbeep to~RS %s~RS: %s\n", u->recap, inpstr); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Beep a user - as tell but with audio warning + */ +void +beep(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: beep []\n"; + const char *name; + UR_OBJECT u; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot beep.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "Beeping yourself is yet another sign of madness!\n"); + return; + } + if (check_igusers(u, user) && user->level < GOD) { + vwrite_user(user, "%s~RS is ignoring beeps from you.\n", u->recap); + return; + } + if (u->ignbeeps && (user->level < WIZ || u->level > user->level)) { + vwrite_user(user, "%s~RS is ignoring beeps at the moment.\n", u->recap); + return; + } + if (u->afk) { + write_user(user, "You cannot beep someone who is AFK.\n"); + return; + } + if (u->malloc_start) { + vwrite_user(user, "%s~RS is writing a message at the moment.\n", + u->recap); + return; + } + if (u->ignall && (user->level < WIZ || u->level > user->level)) { + vwrite_user(user, "%s~RS is not listening at the moment.\n", u->recap); + return; + } +#ifdef NETLINKS + if (!u->room) { + vwrite_user(user, + "%s~RS is offsite and would not be able to reply to you.\n", + u->recap); + return; + } +#endif + name = user->vis || u->level >= user->level ? user->recap : invisname; + if (word_count < 3) { + vwrite_user(u, "\007%s~RS ~OL~FRbeeps to you~RS: ~FR-=[*] BEEP [*]=-\n", + name); + vwrite_user(user, "\007You ~OL~FRbeep to~RS %s~RS: ~FR-=[*] BEEP [*]=-\n", + u->recap); + return; + } + inpstr = remove_first(inpstr); + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + vwrite_user(u, "\007%s~RS ~OL~FRbeeps to you~RS: %s\n", name, inpstr); + vwrite_user(user, "\007You ~OL~FRbeep to~RS %s~RS: %s\n", u->recap, inpstr); +} diff --git a/src/commands/bring.c b/src/commands/bring.c index d91de03..27d7bc1 100644 --- a/src/commands/bring.c +++ b/src/commands/bring.c @@ -1,51 +1,51 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * bring a user to the same room - */ -void -bring(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - - if (word_count < 2) { - write_user(user, "Usage: bring \n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - rm = user->room; - if (user == u) { - write_user(user, - "You ~OLreally~RS want to bring yourself?! What would others think?!\n"); - return; - } - if (rm == u->room) { - vwrite_user(user, "%s~RS is already here!\n", u->recap); - return; - } - if (u->level >= user->level && user->level != GOD) { - write_user(user, - "You cannot move a user of equal or higher level that yourself.\n"); - return; - } - write_user(user, "You chant a mystic spell...\n"); - if (user->vis) { - vwrite_room_except(user->room, user, "%s~RS chants a mystic spell...\n", - user->recap); - } else { - write_monitor(user, user->room, 0); - vwrite_room_except(user->room, user, "%s chants a mystic spell...\n", - invisname); - } - move_user(u, rm, 2); - prompt(u); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * bring a user to the same room + */ +void +bring(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + + if (word_count < 2) { + write_user(user, "Usage: bring \n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + rm = user->room; + if (user == u) { + write_user(user, + "You ~OLreally~RS want to bring yourself?! What would others think?!\n"); + return; + } + if (rm == u->room) { + vwrite_user(user, "%s~RS is already here!\n", u->recap); + return; + } + if (u->level >= user->level && user->level != GOD) { + write_user(user, + "You cannot move a user of equal or higher level that yourself.\n"); + return; + } + write_user(user, "You chant a mystic spell...\n"); + if (user->vis) { + vwrite_room_except(user->room, user, "%s~RS chants a mystic spell...\n", + user->recap); + } else { + write_monitor(user, user->room, 0); + vwrite_room_except(user->room, user, "%s chants a mystic spell...\n", + invisname); + } + move_user(u, rm, 2); + prompt(u); } \ No newline at end of file diff --git a/src/commands/cafk.c b/src/commands/cafk.c index 8953bad..ce63702 100644 --- a/src/commands/cafk.c +++ b/src/commands/cafk.c @@ -1,14 +1,14 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Clear the tell buffer of the user - */ -void -clear_afk(UR_OBJECT user) -{ - destruct_review_buffer_type(user, rbfAFK, 0); - write_user(user, "Your AFK review buffer has now been cleared.\n"); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Clear the tell buffer of the user + */ +void +clear_afk(UR_OBJECT user) +{ + destruct_review_buffer_type(user, rbfAFK, 0); + write_user(user, "Your AFK review buffer has now been cleared.\n"); +} diff --git a/src/commands/calendar.c b/src/commands/calendar.c index 4fdf28c..cf8f400 100644 --- a/src/commands/calendar.c +++ b/src/commands/calendar.c @@ -1,92 +1,92 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * display the calendar to the user - */ -void -show_calendar(UR_OBJECT user) -{ - static const char *const short_month_name[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", - "Nov", "Dec" - }; - static const char *const short_day_name[] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; - static const int num_of_days[] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - char temp[ARR_SIZE]; - const struct tm *date; - time_t now; - int dow, numdays; - int yr, mo, dy; - - time(&now); - date = localtime(&now); - yr = word_count < 3 ? 1900 + date->tm_year : atoi(word[2]); - mo = word_count < 2 ? 1 + date->tm_mon : atoi(word[1]); - if (yr == 99) { - yr += 1900; - } else if (yr < 99) { - yr += 2000; - } - if (word_count > 3 || yr > 3000 || yr < 1800 || mo < 1 || mo > 12) { - write_user(user, "Usage: calendar [ []]\n"); - write_user(user, "where: = month from 1 to 12\n"); - write_user(user, " = year from 1 to 99, or 1800 to 3000\n"); - return; - } - /* show calendar */ - write_user(user, "\n+-----------------------------------+\n"); - write_user(user, - align_string(1, 37, 1, "|", "~OL~FC%.4d %s~RS", yr, - short_month_name[mo - 1])); - write_user(user, "+-----------------------------------+\n"); - *temp = '\0'; - *text = '\0'; - for (dow = 0; dow < 7; ++dow) { -#ifdef ISOWEEKS - sprintf(temp, " ~OL~FY%s~RS", short_day_name[(1 + dow) % 7]); -#else - sprintf(temp, " ~OL~FY%s~RS", short_day_name[dow]); -#endif - strcat(text, temp); - } - strcat(text, "\n+-----------------------------------+\n"); - numdays = num_of_days[mo - 1]; - if (2 == mo && is_leap(yr)) { - ++numdays; - } -#ifdef ISOWEEKS - dow = (ymd_to_scalar(yr, mo, 1) - 1) % 7L; -#else - dow = ymd_to_scalar(yr, mo, 1) % 7L; -#endif - for (dy = 0; dy < dow; ++dy) { - strcat(text, " "); - } - for (dy = 1; dy <= numdays; ++dy, ++dow, dow %= 7) { - if (!dow && 1 != dy) { - strcat(text, "\n\n"); - } - if (has_reminder(user, dy, mo, yr)) { - sprintf(temp, " ~OL~FR%3d~RS ", dy); - strcat(text, temp); - } else if (is_ymd_today(yr, mo, dy)) { - sprintf(temp, " ~OL~FG%3d~RS ", dy); - strcat(text, temp); - } else { - sprintf(temp, " %3d ", dy); - strcat(text, temp); - } - } - for (; dow; ++dow, dow %= 7) { - strcat(text, " "); - } - strcat(text, "\n+-----------------------------------+\n\n"); - write_user(user, text); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * display the calendar to the user + */ +void +show_calendar(UR_OBJECT user) +{ + static const char *const short_month_name[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", + "Nov", "Dec" + }; + static const char *const short_day_name[] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static const int num_of_days[] = { + 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + char temp[ARR_SIZE]; + const struct tm *date; + time_t now; + int dow, numdays; + int yr, mo, dy; + + time(&now); + date = localtime(&now); + yr = word_count < 3 ? 1900 + date->tm_year : atoi(word[2]); + mo = word_count < 2 ? 1 + date->tm_mon : atoi(word[1]); + if (yr == 99) { + yr += 1900; + } else if (yr < 99) { + yr += 2000; + } + if (word_count > 3 || yr > 3000 || yr < 1800 || mo < 1 || mo > 12) { + write_user(user, "Usage: calendar [ []]\n"); + write_user(user, "where: = month from 1 to 12\n"); + write_user(user, " = year from 1 to 99, or 1800 to 3000\n"); + return; + } + /* show calendar */ + write_user(user, "\n+-----------------------------------+\n"); + write_user(user, + align_string(ALIGN_CENTRE, 37, 1, "|", "~OL~FC%.4d %s~RS", yr, + short_month_name[mo - 1])); + write_user(user, "+-----------------------------------+\n"); + *temp = '\0'; + *text = '\0'; + for (dow = 0; dow < 7; ++dow) { +#ifdef ISOWEEKS + sprintf(temp, " ~OL~FY%s~RS", short_day_name[(1 + dow) % 7]); +#else + sprintf(temp, " ~OL~FY%s~RS", short_day_name[dow]); +#endif + strcat(text, temp); + } + strcat(text, "\n+-----------------------------------+\n"); + numdays = num_of_days[mo - 1]; + if (2 == mo && is_leap(yr)) { + ++numdays; + } +#ifdef ISOWEEKS + dow = (ymd_to_scalar(yr, mo, 1) - 1) % 7L; +#else + dow = ymd_to_scalar(yr, mo, 1) % 7L; +#endif + for (dy = 0; dy < dow; ++dy) { + strcat(text, " "); + } + for (dy = 1; dy <= numdays; ++dy, ++dow, dow %= 7) { + if (!dow && 1 != dy) { + strcat(text, "\n\n"); + } + if (has_reminder(user, dy, mo, yr)) { + sprintf(temp, " ~OL~FR%3d~RS ", dy); + strcat(text, temp); + } else if (is_ymd_today(yr, mo, dy)) { + sprintf(temp, " ~OL~FG%3d~RS ", dy); + strcat(text, temp); + } else { + sprintf(temp, " %3d ", dy); + strcat(text, temp); + } + } + for (; dow; ++dow, dow %= 7) { + strcat(text, " "); + } + strcat(text, "\n+-----------------------------------+\n\n"); + write_user(user, text); +} diff --git a/src/commands/cedit.c b/src/commands/cedit.c index 1e8149e..34bb367 100644 --- a/src/commands/cedit.c +++ b/src/commands/cedit.c @@ -1,13 +1,13 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Clear the tell buffer of the user - */ -void -clear_edit(UR_OBJECT user) -{ - destruct_review_buffer_type(user, rbfEDIT, 0); +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Clear the tell buffer of the user + */ +void +clear_edit(UR_OBJECT user) +{ + destruct_review_buffer_type(user, rbfEDIT, 0); } \ No newline at end of file diff --git a/src/commands/change_pass.c b/src/commands/change_pass.c index 5dcdc34..99288f8 100644 --- a/src/commands/change_pass.c +++ b/src/commands/change_pass.c @@ -1,129 +1,129 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Change users password. Only GODs and above can change another users - * password and they do this by specifying the user at the end. When this is - * done the old password given can be anything, the wiz doesnt have to know it - * in advance - */ -void -change_pass(UR_OBJECT user) -{ - UR_OBJECT u; - const char *name; - int i; - - if (word_count < 3) { - if (user->level < GOD) { - write_user(user, "Usage: passwd \n"); - } else { - write_user(user, - "Usage: passwd []\n"); - } - return; - } - i = strlen(word[2]); - if (i < PASS_MIN) { - write_user(user, "New password too short.\n"); - return; - } - /* Via use of crypt() */ - if (i > 8) { - write_user(user, - "WARNING: Only the first eight characters of password will be used!\n"); - } - /* Change own password */ - if (word_count == 3) { - if (strcmp(user->pass, crypt(word[1], user->pass))) { - write_user(user, "Old password incorrect.\n"); - return; - } - if (!strcmp(word[1], word[2])) { - write_user(user, "Old and new passwords are the same.\n"); - return; - } - strcpy(user->pass, crypt(word[2], crypt_salt)); - save_user_details(user, 0); - cls(user); - write_user(user, "Password changed.\n"); - add_history(user->name, 1, "Changed passwords.\n"); - return; - } - /* Change someone elses */ - if (user->level < GOD) { - write_user(user, - "You are not a high enough level to use the user option.\n"); - return; - } - *word[3] = toupper(*word[3]); - if (!strcmp(word[3], user->name)) { - /* - security feature - prevents someone coming to a wizes terminal and - changing his password since he wont have to know the old one - */ - write_user(user, - "You cannot change your own password using the option.\n"); - return; - } - u = get_user(word[3]); - if (u) { -#ifdef NETLINKS - if (u->type == REMOTE_TYPE) { - write_user(user, - "You cannot change the password of a user logged on remotely.\n"); - return; - } -#endif - if (u->level >= user->level) { - write_user(user, - "You cannot change the password of a user of equal or higher level than yourself.\n"); - return; - } - strcpy(u->pass, crypt(word[2], crypt_salt)); - cls(user); - vwrite_user(user, "%s~RS's password has been changed.\n", u->recap); - name = user->vis ? user->name : invisname; - vwrite_user(u, "~FR~OLYour password has been changed by %s!\n", name); - write_syslog(SYSLOG, 1, "%s changed %s's password.\n", user->name, - u->name); - sprintf(text, "Forced password change by %s.\n", user->name); - add_history(u->name, 0, "%s", text); - return; - } - u = create_user(); - if (!u) { - vwrite_user(user, "%s: unable to create temporary user object.\n", - syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to create temporary user object in change_pass().\n"); - return; - } - strcpy(u->name, word[3]); - if (!load_user_details(u)) { - write_user(user, nosuchuser); - destruct_user(u); - destructed = 0; - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot change the password of a user of equal or higher level than yourself.\n"); - destruct_user(u); - destructed = 0; - return; - } - strcpy(u->pass, crypt(word[2], crypt_salt)); - save_user_details(u, 0); - destruct_user(u); - destructed = 0; - cls(user); - vwrite_user(user, "%s's password changed to \"%s\".\n", word[3], word[2]); - sprintf(text, "Forced password change by %s.\n", user->name); - add_history(word[3], 0, "%s", text); - write_syslog(SYSLOG, 1, "%s changed %s's password.\n", user->name, word[3]); -} - + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Change users password. Only GODs and above can change another users + * password and they do this by specifying the user at the end. When this is + * done the old password given can be anything, the wiz doesnt have to know it + * in advance + */ +void +change_pass(UR_OBJECT user) +{ + UR_OBJECT u; + const char *name; + int i; + + if (word_count < 3) { + if (user->level < GOD) { + write_user(user, "Usage: passwd \n"); + } else { + write_user(user, + "Usage: passwd []\n"); + } + return; + } + i = strlen(word[2]); + if (i < PASS_MIN) { + write_user(user, "New password too short.\n"); + return; + } + /* Via use of crypt() */ + if (i > 8) { + write_user(user, + "WARNING: Only the first eight characters of password will be used!\n"); + } + /* Change own password */ + if (word_count == 3) { + if (strcmp(user->pass, crypt(word[1], user->pass))) { + write_user(user, "Old password incorrect.\n"); + return; + } + if (!strcmp(word[1], word[2])) { + write_user(user, "Old and new passwords are the same.\n"); + return; + } + strcpy(user->pass, crypt(word[2], crypt_salt)); + save_user_details(user, 0); + cls(user); + write_user(user, "Password changed.\n"); + add_history(user->name, 1, "Changed passwords.\n"); + return; + } + /* Change someone else's password */ + if (user->level < GOD) { + write_user(user, + "You are not a high enough level to use the user option.\n"); + return; + } + *word[3] = toupper(*word[3]); + if (!strcmp(word[3], user->name)) { + /* + security feature - prevents someone coming to a wizes terminal and + changing their password since they won't have to know the old one + */ + write_user(user, + "You cannot change your own password using the option.\n"); + return; + } + u = get_user(word[3]); + if (u) { +#ifdef NETLINKS + if (u->type == REMOTE_TYPE) { + write_user(user, + "You cannot change the password of a user logged on remotely.\n"); + return; + } +#endif + if (u->level >= user->level) { + write_user(user, + "You cannot change the password of a user of equal or higher level than yourself.\n"); + return; + } + strcpy(u->pass, crypt(word[2], crypt_salt)); + cls(user); + vwrite_user(user, "%s~RS's password has been changed.\n", u->recap); + name = user->vis ? user->name : invisname; + vwrite_user(u, "~FR~OLYour password has been changed by %s!\n", name); + write_syslog(SYSLOG, 1, "%s changed %s's password.\n", user->name, + u->name); + sprintf(text, "Forced password change by %s.\n", user->name); + add_history(u->name, 0, "%s", text); + return; + } + u = create_user(); + if (!u) { + vwrite_user(user, "%s: unable to create temporary user object.\n", + syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to create temporary user object in change_pass().\n"); + return; + } + strcpy(u->name, word[3]); + if (!load_user_details(u)) { + write_user(user, nosuchuser); + destruct_user(u); + destructed = 0; + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot change the password of a user of equal or higher level than yourself.\n"); + destruct_user(u); + destructed = 0; + return; + } + strcpy(u->pass, crypt(word[2], crypt_salt)); + save_user_details(u, 0); + destruct_user(u); + destructed = 0; + cls(user); + vwrite_user(user, "%s's password changed to \"%s\".\n", word[3], word[2]); + sprintf(text, "Forced password change by %s.\n", user->name); + add_history(word[3], 0, "%s", text); + write_syslog(SYSLOG, 1, "%s changed %s's password.\n", user->name, word[3]); +} + diff --git a/src/commands/charecho.c b/src/commands/charecho.c index f798ca4..1471437 100644 --- a/src/commands/charecho.c +++ b/src/commands/charecho.c @@ -1,25 +1,25 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set the character mode echo on or off. This is only for users logging in - * via a character mode client, those using a line mode client (eg unix - * telnet) will see no effect. - */ -void -toggle_charecho(UR_OBJECT user) -{ - if (!user->charmode_echo) { - write_user(user, "Echoing for character mode clients ~FGON~RS.\n"); - user->charmode_echo = 1; - } else { - write_user(user, "Echoing for character mode clients ~FROFF~RS.\n"); - user->charmode_echo = 0; - } - if (!user->room) { - prompt(user); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set the character mode echo on or off. This is only for users logging in + * via a character mode client, those using a line mode client (eg unix + * telnet) will see no effect. + */ +void +toggle_charecho(UR_OBJECT user) +{ + if (!user->charmode_echo) { + write_user(user, "Echoing for character mode clients ~FGON~RS.\n"); + user->charmode_echo = 1; + } else { + write_user(user, "Echoing for character mode clients ~FROFF~RS.\n"); + user->charmode_echo = 0; + } + if (!user->room) { + prompt(user); + } +} diff --git a/src/commands/clearline.c b/src/commands/clearline.c index 3a32ccf..3592a60 100644 --- a/src/commands/clearline.c +++ b/src/commands/clearline.c @@ -1,41 +1,41 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Free a hung socket - */ -void -clearline(UR_OBJECT user) -{ - UR_OBJECT u; - int sock; - - if (word_count < 2 || !is_number(word[1])) { - write_user(user, "Usage: clearline \n"); - return; - } - sock = atoi(word[1]); - /* Find line amongst users */ - for (u = user_first; u; u = u->next) { - if (u->type != CLONE_TYPE && u->socket == sock) { - break; - } - } - if (!u) { - write_user(user, "That line is not currently active.\n"); - return; - } - if (!u->login) { - write_user(user, "You cannot clear the line of a logged in user.\n"); - return; - } - write_user(u, "\n\nThis line is being cleared.\n\n"); - disconnect_user(u); - write_syslog(SYSLOG, 1, "%s cleared line %d.\n", user->name, sock); - vwrite_user(user, "Line %d cleared.\n", sock); - destructed = 0; - no_prompt = 0; + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Free a hung socket + */ +void +clearline(UR_OBJECT user) +{ + UR_OBJECT u; + int sock; + + if (word_count < 2 || !is_number(word[1])) { + write_user(user, "Usage: clearline \n"); + return; + } + sock = atoi(word[1]); + /* Find line amongst users */ + for (u = user_first; u; u = u->next) { + if (u->type != CLONE_TYPE && u->socket == sock) { + break; + } + } + if (!u) { + write_user(user, "That line is not currently active.\n"); + return; + } + if (!u->login) { + write_user(user, "You cannot clear the line of a logged in user.\n"); + return; + } + write_user(u, "\n\nThis line is being cleared.\n\n"); + disconnect_user(u); + write_syslog(SYSLOG, 1, "%s cleared line %d.\n", user->name, sock); + vwrite_user(user, "Line %d cleared.\n", sock); + destructed = 0; + no_prompt = 0; } \ No newline at end of file diff --git a/src/commands/clone_emote.c b/src/commands/clone_emote.c index 317d853..5533cb8 100644 --- a/src/commands/clone_emote.c +++ b/src/commands/clone_emote.c @@ -1,41 +1,41 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Make a clone emote - */ -void -clone_emote(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: cemote \n"; - RM_OBJECT rm; - UR_OBJECT u; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, your clone cannot emote.\n"); - return; - } - if (word_count < 3) { - write_user(user, usage); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { - break; - } - } - if (!u) { - write_user(user, "You do not have a clone in that room.\n"); - return; - } - emote(u, remove_first(inpstr)); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Make a clone emote + */ +void +clone_emote(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: cemote \n"; + RM_OBJECT rm; + UR_OBJECT u; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, your clone cannot emote.\n"); + return; + } + if (word_count < 3) { + write_user(user, usage); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { + break; + } + } + if (!u) { + write_user(user, "You do not have a clone in that room.\n"); + return; + } + emote(u, remove_first(inpstr)); +} diff --git a/src/commands/clone_hear.c b/src/commands/clone_hear.c index afc7cb7..7d144ec 100644 --- a/src/commands/clone_hear.c +++ b/src/commands/clone_hear.c @@ -1,53 +1,53 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set what a clone will hear, either all speach , just bad language - * or nothing. - */ -void -clone_hear(UR_OBJECT user) -{ - static const char usage[] = "Usage: chear all|swears|nothing\n"; - RM_OBJECT rm; - UR_OBJECT u; - - if (word_count < 3) { - write_user(user, usage); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { - break; - } - } - if (!u) { - write_user(user, "You do not have a clone in that room.\n"); - return; - } - strtolower(word[2]); - if (!strcmp(word[2], "all")) { - u->clone_hear = CLONE_HEAR_ALL; - write_user(user, "Clone will now hear everything.\n"); - return; - } - if (!strcmp(word[2], "swears")) { - u->clone_hear = CLONE_HEAR_SWEARS; - write_user(user, "Clone will now only hear swearing.\n"); - return; - } - if (!strcmp(word[2], "nothing")) { - u->clone_hear = CLONE_HEAR_NOTHING; - write_user(user, "Clone will now hear nothing.\n"); - return; - } - write_user(user, usage); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set what a clone will hear, either all speech , just bad language + * or nothing. + */ +void +clone_hear(UR_OBJECT user) +{ + static const char usage[] = "Usage: chear all|swears|nothing\n"; + RM_OBJECT rm; + UR_OBJECT u; + + if (word_count < 3) { + write_user(user, usage); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { + break; + } + } + if (!u) { + write_user(user, "You do not have a clone in that room.\n"); + return; + } + strtolower(word[2]); + if (!strcmp(word[2], "all")) { + u->clone_hear = CLONE_HEAR_ALL; + write_user(user, "Clone will now hear everything.\n"); + return; + } + if (!strcmp(word[2], "swears")) { + u->clone_hear = CLONE_HEAR_SWEARS; + write_user(user, "Clone will now only hear swearing.\n"); + return; + } + if (!strcmp(word[2], "nothing")) { + u->clone_hear = CLONE_HEAR_NOTHING; + write_user(user, "Clone will now hear nothing.\n"); + return; + } + write_user(user, usage); +} diff --git a/src/commands/clone_say.c b/src/commands/clone_say.c index 0a54bca..5529a0a 100644 --- a/src/commands/clone_say.c +++ b/src/commands/clone_say.c @@ -1,41 +1,41 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Make a clone speak - */ -void -clone_say(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: csay \n"; - RM_OBJECT rm; - UR_OBJECT u; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, your clone cannot speak.\n"); - return; - } - if (word_count < 3) { - write_user(user, usage); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { - break; - } - } - if (!u) { - write_user(user, "You do not have a clone in that room.\n"); - return; - } - say(u, remove_first(inpstr)); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Make a clone speak + */ +void +clone_say(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: csay \n"; + RM_OBJECT rm; + UR_OBJECT u; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, your clone cannot speak.\n"); + return; + } + if (word_count < 3) { + write_user(user, usage); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { + break; + } + } + if (!u) { + write_user(user, "You do not have a clone in that room.\n"); + return; + } + say(u, remove_first(inpstr)); +} diff --git a/src/commands/clone_switch.c b/src/commands/clone_switch.c index 59823b0..4d0e503 100644 --- a/src/commands/clone_switch.c +++ b/src/commands/clone_switch.c @@ -1,63 +1,63 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * User swaps places with his own clone. All we do is swap the rooms the objects are in - */ -void -clone_switch(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - - /* - if no room was given then check to see how many clones user has. If 1, then - move the user to that clone, else give an error - */ - if (word_count < 2) { - UR_OBJECT tu; - - u = NULL; - for (tu = user_first; tu; tu = tu->next) { - if (tu->type == CLONE_TYPE && tu->owner == user) { - if (u) { - write_user(user, - "You have more than one clone active. Please specify a room to switch to.\n"); - return; - } - u = tu; - } - } - if (!u) { - write_user(user, "You do not currently have any active clones.\n"); - return; - } - rm = u->room; - } else { - /* if a room name was given then try to switch to a clone there */ - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { - break; - } - } - if (!u) { - write_user(user, "You do not have a clone in that room.\n"); - return; - } - } - write_user(user, "\n~FB~OLYou experience a strange sensation...\n"); - u->room = user->room; - user->room = rm; - vwrite_room_except(user->room, user, "The clone of %s comes alive!\n", - u->name); - vwrite_room_except(u->room, u, "%s~RS turns into a clone!\n", u->recap); - look(user); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * User swaps places with his own clone. All we do is swap the rooms the objects are in + */ +void +clone_switch(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + + /* + if no room was given then check to see how many clones user has. If 1, then + move the user to that clone, else give an error + */ + if (word_count < 2) { + UR_OBJECT tu; + + u = NULL; + for (tu = user_first; tu; tu = tu->next) { + if (tu->type == CLONE_TYPE && tu->owner == user) { + if (u) { + write_user(user, + "You have more than one clone active. Please specify a room to switch to.\n"); + return; + } + u = tu; + } + } + if (!u) { + write_user(user, "You do not currently have any active clones.\n"); + return; + } + rm = u->room; + } else { + /* if a room name was given then try to switch to a clone there */ + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE && u->room == rm && u->owner == user) { + break; + } + } + if (!u) { + write_user(user, "You do not have a clone in that room.\n"); + return; + } + } + write_user(user, "\n~FB~OLYou experience a strange sensation...\n"); + u->room = user->room; + user->room = rm; + vwrite_room_except(user->room, user, "The clone of %s comes alive!\n", + u->name); + vwrite_room_except(u->room, u, "%s~RS turns into a clone!\n", u->recap); + look(user); +} diff --git a/src/commands/cls.c b/src/commands/cls.c index 07388ec..4ac45c3 100644 --- a/src/commands/cls.c +++ b/src/commands/cls.c @@ -1,20 +1,20 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Clear the screen - */ -void -cls(UR_OBJECT user) -{ - int i; - /* For clients that don't support telnet clear screen escape character, we flood them with new lines... */ - for (i = 0; i < 6; ++i) { - write_user(user, "\n\n\n\n\n\n\n\n\n\n"); - } - /* ...and for the others, here's The Real Thing (TM) */ - write_user(user, "\x01B[2J"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Clear the screen + */ +void +cls(UR_OBJECT user) +{ + int i; + /* For clients that don't support telnet clear screen escape character, we flood them with new lines... */ + for (i = 0; i < 6; ++i) { + write_user(user, "\n\n\n\n\n\n\n\n\n\n"); + } + /* ...and for the others, here's The Real Thing (TM) */ + write_user(user, "\x01B[2J"); +} diff --git a/src/commands/cmdcount.c b/src/commands/cmdcount.c index 263b25a..bce35aa 100644 --- a/src/commands/cmdcount.c +++ b/src/commands/cmdcount.c @@ -1,88 +1,88 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Display how many times a command has been used, and its overall - * percentage of showings compared to other commands - */ -void -show_command_counts(UR_OBJECT user) -{ - CMD_OBJECT cmd; - int total_hits, total_cmds, cmds_used, i, x; - char text2[ARR_SIZE]; - - x = i = total_hits = total_cmds = cmds_used = 0; - *text2 = '\0'; - /* get totals of commands and hits */ - for (cmd = first_command; cmd; cmd = cmd->next) { - total_hits += cmd->count; - ++total_cmds; - } - start_pager(user); - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~FC~OLCommand usage statistics~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - for (cmd = first_command; cmd; cmd = cmd->next) { - /* skip if command has not been used so as not to cause crash by trying to / by 0 */ - if (!cmd->count) { - continue; - } - ++cmds_used; - /* skip if user cannot use that command anyway */ - if (cmd->level > user->level) { - continue; - } - i = ((cmd->count * 10000) / total_hits); - /* build up first half of the string */ - if (!x) { - sprintf(text, "| %11.11s %4d %3d%% ", cmd->name, cmd->count, i / 100); - ++x; - } /* build up full line and print to user */ - else if (x == 1) { - sprintf(text2, " %11.11s %4d %3d%% ", cmd->name, cmd->count, - i / 100); - strcat(text, text2); - write_user(user, text); - *text = '\0'; - *text2 = '\0'; - ++x; - } else { - sprintf(text2, " %11.11s %4d %3d%% |\n", cmd->name, cmd->count, - i / 100); - strcat(text, text2); - write_user(user, text); - *text = '\0'; - *text2 = '\0'; - x = 0; - } - } - /* If you have only printed first half of the string */ - if (x == 1) { - strcat(text, " |\n"); - write_user(user, text); - } - if (x == 2) { - strcat(text, " |\n"); - write_user(user, text); - } - write_user(user, - "| |\n"); - write_user(user, - "| Any other commands have not yet been used, or you cannot view them |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - sprintf(text2, - "Total of ~OL%d~RS commands. ~OL%d~RS command%s used a total of ~OL%d~RS time%s.", - total_cmds, cmds_used, PLTEXT_S(cmds_used), total_hits, - PLTEXT_S(total_hits)); - vwrite_user(user, "| %-92s |\n", text2); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - stop_pager(user); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Display how many times a command has been used, and its overall + * percentage of showings compared to other commands + */ +void +show_command_counts(UR_OBJECT user) +{ + CMD_OBJECT cmd; + int total_hits, total_cmds, cmds_used, i, x; + char text2[ARR_SIZE]; + + x = i = total_hits = total_cmds = cmds_used = 0; + *text2 = '\0'; + /* get totals of commands and hits */ + for (cmd = first_command; cmd; cmd = cmd->next) { + total_hits += cmd->count; + ++total_cmds; + } + start_pager(user); + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~FC~OLCommand usage statistics~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + for (cmd = first_command; cmd; cmd = cmd->next) { + /* skip if command has not been used so as not to cause crash by trying to / by 0 */ + if (!cmd->count) { + continue; + } + ++cmds_used; + /* skip if user cannot use that command anyway */ + if (cmd->level > user->level) { + continue; + } + i = ((cmd->count * 10000) / total_hits); + /* build up first half of the string */ + if (!x) { + sprintf(text, "| %11.11s %4d %3d%% ", cmd->name, cmd->count, i / 100); + ++x; + } /* build up full line and print to user */ + else if (x == 1) { + sprintf(text2, " %11.11s %4d %3d%% ", cmd->name, cmd->count, + i / 100); + strcat(text, text2); + write_user(user, text); + *text = '\0'; + *text2 = '\0'; + ++x; + } else { + sprintf(text2, " %11.11s %4d %3d%% |\n", cmd->name, cmd->count, + i / 100); + strcat(text, text2); + write_user(user, text); + *text = '\0'; + *text2 = '\0'; + x = 0; + } + } + /* If you have only printed first half of the string */ + if (x == 1) { + strcat(text, " |\n"); + write_user(user, text); + } + if (x == 2) { + strcat(text, " |\n"); + write_user(user, text); + } + write_user(user, + "| |\n"); + write_user(user, + "| Any other commands have not yet been used, or you cannot view them |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + sprintf(text2, + "Total of ~OL%d~RS commands. ~OL%d~RS command%s used a total of ~OL%d~RS time%s.", + total_cmds, cmds_used, PLTEXT_S(cmds_used), total_hits, + PLTEXT_S(total_hits)); + vwrite_user(user, "| %-92s |\n", text2); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + stop_pager(user); +} diff --git a/src/commands/colour.c b/src/commands/colour.c index f2bfa09..19a0272 100644 --- a/src/commands/colour.c +++ b/src/commands/colour.c @@ -1,29 +1,29 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Display colours to user - */ -void -display_colour(UR_OBJECT user) -{ - static const char *const colours[] = { - "~OL", "~UL", "~LI", "~RV", - "~FK", "~FR", "~FG", "~FY", "~FB", "~FM", "~FC", "~FW", - "~BK", "~BR", "~BG", "~BY", "~BB", "~BM", "~BC", "~BW", - NULL - }; - size_t i; - - if (!user->room) { - prompt(user); - return; - } - for (i = 0; colours[i]; ++i) { - vwrite_user(user, "^%s: %sAmnuts version %s VIDEO TEST\n", - colours[i], colours[i], AMNUTSVER); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Display colours to user + */ +void +display_colour(UR_OBJECT user) +{ + static const char *const colours[] = { + "~OL", "~UL", "~LI", "~RV", + "~FK", "~FR", "~FG", "~FY", "~FB", "~FM", "~FC", "~FW", + "~BK", "~BR", "~BG", "~BY", "~BB", "~BM", "~BC", "~BW", + NULL + }; + size_t i; + + if (!user->room) { + prompt(user); + return; + } + for (i = 0; colours[i]; ++i) { + vwrite_user(user, "^%s: %sAmnuts version %s VIDEO TEST\n", + colours[i], colours[i], AMNUTSVER); + } +} diff --git a/src/commands/connect_netlink.c b/src/commands/connect_netlink.c index c8a5a67..908cc9b 100644 --- a/src/commands/connect_netlink.c +++ b/src/commands/connect_netlink.c @@ -1,63 +1,63 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -#ifdef NETLINKS - -/* - * Connect a netlink. Use the room as the key - */ -void -connect_netlink(UR_OBJECT user) -{ - RM_OBJECT rm; - NL_OBJECT nl; - - if (word_count < 2) { - write_user(user, "Usage: connect \n"); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - nl = rm->netlink; - if (!nl) { - write_user(user, "That room is not linked to a service.\n"); - return; - } - if (nl->type != UNCONNECTED) { - write_user(user, "That rooms netlink is already up.\n"); - return; - } - write_user(user, - "Attempting connect (this may cause a temporary hang)...\n"); - write_syslog(NETLOG, 1, - "NETLINK: Connection attempt to %s initiated by %s.\n", - nl->service, user->name); - nl->socket = socket_connect(nl->site, nl->port); - if (nl->socket < 0) { - vwrite_user(user, "~FRConnect failed: %s.\n", - nl->socket != -1 ? "Unknown hostname" : strerror(errno)); - write_syslog(NETLOG, 1, "NETLINK: Failed to connect to %s: %s.\n", - nl->service, - nl->socket != -1 ? "Unknown hostname" : strerror(errno)); - return; - } - nl->type = OUTGOING; - nl->stage = VERIFYING; - nl->last_recvd = time(0); - nl->connect_room = rm; - write_user(user, "~FGInitial connection made...\n"); - write_syslog(NETLOG, 1, "NETLINK: Connected to %s (%s:%s).\n", nl->service, - nl->site, nl->port); -} - -#else - -#define NO_NETLINKS - -#endif + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +#ifdef NETLINKS + +/* + * Connect a netlink. Use the room as the key + */ +void +connect_netlink(UR_OBJECT user) +{ + RM_OBJECT rm; + NL_OBJECT nl; + + if (word_count < 2) { + write_user(user, "Usage: connect \n"); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + nl = rm->netlink; + if (!nl) { + write_user(user, "That room is not linked to a service.\n"); + return; + } + if (nl->type != UNCONNECTED) { + write_user(user, "That rooms netlink is already up.\n"); + return; + } + write_user(user, + "Attempting connect (this may cause a temporary hang)...\n"); + write_syslog(NETLOG, 1, + "NETLINK: Connection attempt to %s initiated by %s.\n", + nl->service, user->name); + nl->socket = socket_connect(nl->site, nl->port); + if (nl->socket < 0) { + vwrite_user(user, "~FRConnect failed: %s.\n", + nl->socket != -1 ? "Unknown hostname" : strerror(errno)); + write_syslog(NETLOG, 1, "NETLINK: Failed to connect to %s: %s.\n", + nl->service, + nl->socket != -1 ? "Unknown hostname" : strerror(errno)); + return; + } + nl->type = OUTGOING; + nl->stage = VERIFYING; + nl->last_recvd = time(0); + nl->connect_room = rm; + write_user(user, "~FGInitial connection made...\n"); + write_syslog(NETLOG, 1, "NETLINK: Connected to %s (%s:%s).\n", nl->service, + nl->site, nl->port); +} + +#else + +#define NO_NETLINKS + +#endif diff --git a/src/commands/copyto.c b/src/commands/copyto.c index ad76b09..5b69683 100644 --- a/src/commands/copyto.c +++ b/src/commands/copyto.c @@ -1,106 +1,106 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * get users which to send copies of smail to - */ -void -copies_to(UR_OBJECT user) -{ - int i, found, x, y; - char *remote; - - if (com_num == NOCOPIES) { - for (i = 0; i < MAX_COPIES; ++i) { - *user->copyto[i] = '\0'; - } - write_user(user, "Sending no copies of your next smail.\n"); - return; - } - if (word_count < 2) { - *text = '\0'; - found = 0; - for (i = 0; i < MAX_COPIES; ++i) { - if (!*user->copyto[i]) { - continue; - } - if (!found++) { - write_user(user, "Sending copies of your next smail to...\n"); - } - strcat(text, " "); - strcat(text, user->copyto[i]); - } - strcat(text, "\n\n"); - if (!found) { - write_user(user, "You are not sending a copy to anyone.\n"); - } else { - write_user(user, text); - } - return; - } - if (word_count > MAX_COPIES + 1) { /* +1 because 1 count for command */ - vwrite_user(user, "You can only copy to a maximum of %d people.\n", - MAX_COPIES); - return; - } - /* check to see the user is not trying to send duplicates */ - for (x = 1; x < word_count; ++x) { - for (y = x + 1; y < word_count; ++y) { - if (!strcasecmp(word[x], word[y])) { - write_user(user, "Cannot send to same person more than once.\n"); - return; - } - } - } - write_user(user, "\n"); - for (i = 0; i < MAX_COPIES; ++i) { - *user->copyto[i] = '\0'; - } - i = 0; - for (x = 1; x < word_count; ++x) { - /* See if its to another site */ - if (*word[x] == '@') { - vwrite_user(user, - "Name missing before @ sign for copy to name \"%s\".\n", - word[x]); - continue; - } - remote = strchr(word[x], '@'); - if (!remote) { - *word[x] = toupper(*word[x]); - /* See if user exists */ - if (get_user(word[x]) == user && user->level < ARCH) { - write_user(user, "You cannot send yourself a copy.\n"); - continue; - } - if (!find_user_listed(word[x])) { - vwrite_user(user, - "There is no such user with the name \"%s\" to copy to.\n", - word[x]); - continue; - } - } - strcpy(user->copyto[i++], word[x]); - } - *text = '\0'; - found = 0; - for (i = 0; i < MAX_COPIES; ++i) { - if (!*user->copyto[i]) { - continue; - } - if (!found++) { - write_user(user, "Sending copies of your next smail to...\n"); - } - strcat(text, " "); - strcat(text, user->copyto[i]); - } - strcat(text, "\n\n"); - if (!found) { - write_user(user, "You are not sending a copy to anyone.\n"); - } else { - write_user(user, text); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * get users which to send copies of smail to + */ +void +copies_to(UR_OBJECT user) +{ + int i, found, x, y; + char *remote; + + if (com_num == NOCOPIES) { + for (i = 0; i < MAX_COPIES; ++i) { + *user->copyto[i] = '\0'; + } + write_user(user, "Sending no copies of your next smail.\n"); + return; + } + if (word_count < 2) { + *text = '\0'; + found = 0; + for (i = 0; i < MAX_COPIES; ++i) { + if (!*user->copyto[i]) { + continue; + } + if (!found++) { + write_user(user, "Sending copies of your next smail to...\n"); + } + strcat(text, " "); + strcat(text, user->copyto[i]); + } + strcat(text, "\n\n"); + if (!found) { + write_user(user, "You are not sending a copy to anyone.\n"); + } else { + write_user(user, text); + } + return; + } + if (word_count > MAX_COPIES + 1) { /* +1 because 1 count for command */ + vwrite_user(user, "You can only copy to a maximum of %d people.\n", + MAX_COPIES); + return; + } + /* check to see the user is not trying to send duplicates */ + for (x = 1; x < word_count; ++x) { + for (y = x + 1; y < word_count; ++y) { + if (!strcasecmp(word[x], word[y])) { + write_user(user, "Cannot send to same person more than once.\n"); + return; + } + } + } + write_user(user, "\n"); + for (i = 0; i < MAX_COPIES; ++i) { + *user->copyto[i] = '\0'; + } + i = 0; + for (x = 1; x < word_count; ++x) { + /* See if its to another site */ + if (*word[x] == '@') { + vwrite_user(user, + "Name missing before @ sign for copy to name \"%s\".\n", + word[x]); + continue; + } + remote = strchr(word[x], '@'); + if (!remote) { + *word[x] = toupper(*word[x]); + /* See if user exists */ + if (get_user(word[x]) == user && user->level < ARCH) { + write_user(user, "You cannot send yourself a copy.\n"); + continue; + } + if (!find_user_listed(word[x])) { + vwrite_user(user, + "There is no such user with the name \"%s\" to copy to.\n", + word[x]); + continue; + } + } + strcpy(user->copyto[i++], word[x]); + } + *text = '\0'; + found = 0; + for (i = 0; i < MAX_COPIES; ++i) { + if (!*user->copyto[i]) { + continue; + } + if (!found++) { + write_user(user, "Sending copies of your next smail to...\n"); + } + strcat(text, " "); + strcat(text, user->copyto[i]); + } + strcat(text, "\n\n"); + if (!found) { + write_user(user, "You are not sending a copy to anyone.\n"); + } else { + write_user(user, text); + } +} diff --git a/src/commands/create_clone.c b/src/commands/create_clone.c index ffc4c28..c315b24 100644 --- a/src/commands/create_clone.c +++ b/src/commands/create_clone.c @@ -1,80 +1,80 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Clone a user in another room - */ -void -create_clone(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - const char *name; - int cnt; - - /* Check room */ - if (word_count < 2) { - rm = user->room; - } else { - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - } - /* If room is private then nocando */ - if (!has_room_access(user, rm)) { - write_user(user, - "That room is currently private, you cannot create a clone there.\n"); - return; - } - /* Count clones and see if user already has a copy there , no point having 2 in the same room */ - cnt = 0; - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE && u->owner == user) { - if (u->room == rm) { - vwrite_user(user, "You already have a clone in the %s.\n", rm->name); - return; - } - if (++cnt == amsys->max_clones) { - write_user(user, - "You already have the maximum number of clones allowed.\n"); - return; - } - } - } - /* Create clone */ - u = create_user(); - if (!u) { - vwrite_user(user, "%s: Unable to create copy.\n", syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to create user copy in clone().\n"); - return; - } - u->type = CLONE_TYPE; - u->socket = user->socket; - u->room = rm; - u->owner = user; - u->vis = 1; - strcpy(u->name, user->name); - strcpy(u->recap, user->recap); - strcpy(u->bw_recap, colour_com_strip(u->recap)); - strcpy(u->desc, "~BR~OL(CLONE)"); - if (rm == user->room) { - write_user(user, - "~FB~OLYou wave your hands, mix some chemicals and a clone is created here.\n"); - } else { - vwrite_user(user, - "~FB~OLYou wave your hands, mix some chemicals, and a clone is created in the %s.\n", - rm->name); - } - name = user->vis ? user->bw_recap : invisname; - vwrite_room_except(user->room, user, "~FB~OL%s waves their hands...\n", - name); - vwrite_room_except(rm, user, - "~FB~OLA clone of %s appears in a swirling magical mist!\n", - user->bw_recap); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Clone a user in another room + */ +void +create_clone(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + const char *name; + int cnt; + + /* Check room */ + if (word_count < 2) { + rm = user->room; + } else { + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + } + /* If room is private then no-can-do */ + if (!has_room_access(user, rm)) { + write_user(user, + "That room is currently private, you cannot create a clone there.\n"); + return; + } + /* Count clones and see if user already has a copy there , no point having 2 in the same room */ + cnt = 0; + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE && u->owner == user) { + if (u->room == rm) { + vwrite_user(user, "You already have a clone in the %s.\n", rm->name); + return; + } + if (++cnt == amsys->max_clones) { + write_user(user, + "You already have the maximum number of clones allowed.\n"); + return; + } + } + } + /* Create clone */ + u = create_user(); + if (!u) { + vwrite_user(user, "%s: Unable to create copy.\n", syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to create user copy in clone().\n"); + return; + } + u->type = CLONE_TYPE; + u->socket = user->socket; + u->room = rm; + u->owner = user; + u->vis = 1; + strcpy(u->name, user->name); + strcpy(u->recap, user->recap); + strcpy(u->bw_recap, colour_com_strip(u->recap)); + strcpy(u->desc, "~BR~OL(CLONE)"); + if (rm == user->room) { + write_user(user, + "~FB~OLYou wave your hands, mix some chemicals and a clone is created here.\n"); + } else { + vwrite_user(user, + "~FB~OLYou wave your hands, mix some chemicals, and a clone is created in the %s.\n", + rm->name); + } + name = user->vis ? user->bw_recap : invisname; + vwrite_room_except(user->room, user, "~FB~OL%s waves their hands...\n", + name); + vwrite_room_except(rm, user, + "~FB~OLA clone of %s appears in a swirling magical mist!\n", + user->bw_recap); +} diff --git a/src/commands/cshouts.c b/src/commands/cshouts.c index 0a9f93d..95fbcbd 100644 --- a/src/commands/cshouts.c +++ b/src/commands/cshouts.c @@ -1,19 +1,19 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Clear the shout buffer of the talker - */ -void -clear_shouts(void) -{ - int i; - - for (i = 0; i < REVIEW_LINES; ++i) { - *amsys->shoutbuff[i] = '\0'; - } - amsys->sbuffline = 0; + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Clear the shout buffer of the talker + */ +void +clear_shouts(void) +{ + int i; + + for (i = 0; i < REVIEW_LINES; ++i) { + *amsys->shoutbuff[i] = '\0'; + } + amsys->sbuffline = 0; } \ No newline at end of file diff --git a/src/commands/ctells.c b/src/commands/ctells.c index 0745265..de05a4a 100644 --- a/src/commands/ctells.c +++ b/src/commands/ctells.c @@ -1,14 +1,14 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Clear the tell buffer of the user - */ -void -clear_tells(UR_OBJECT user) -{ - destruct_review_buffer_type(user, rbfTELL, 0); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Clear the tell buffer of the user + */ +void +clear_tells(UR_OBJECT user) +{ + destruct_review_buffer_type(user, rbfTELL, 0); +} diff --git a/src/commands/ctopic.c b/src/commands/ctopic.c index ea3f0a9..0f2b7e9 100644 --- a/src/commands/ctopic.c +++ b/src/commands/ctopic.c @@ -1,41 +1,41 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * clears a room topic - */ -void -clear_topic(UR_OBJECT user) -{ - RM_OBJECT rm; - const char *name; - - if (word_count < 2) { - rm = user->room; - *rm->topic = '\0'; - write_user(user, "Topic has been cleared\n"); - name = user->vis ? user->recap : invisname; - vwrite_room_except(rm, user, "%s~RS ~FY~OLhas cleared the topic.\n", - name); - return; - } - strtolower(word[1]); - if (!strcmp(word[1], "all")) { - if (user->level > (enum lvl_value) command_table[CTOPIC].level - || user->level >= ARCH) { - for (rm = room_first; rm; rm = rm->next) { - *rm->topic = '\0'; - write_room_except(rm, "\n~FY~OLThe topic has been cleared.\n", user); - } - write_user(user, "All room topics have now been cleared\n"); - return; - } - write_user(user, - "You can only clear the topic of the room you are in.\n"); - return; - } - write_user(user, "Usage: ctopic [all]\n"); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * clears a room topic + */ +void +clear_topic(UR_OBJECT user) +{ + RM_OBJECT rm; + const char *name; + + if (word_count < 2) { + rm = user->room; + *rm->topic = '\0'; + write_user(user, "Topic has been cleared\n"); + name = user->vis ? user->recap : invisname; + vwrite_room_except(rm, user, "%s~RS ~FY~OLhas cleared the topic.\n", + name); + return; + } + strtolower(word[1]); + if (!strcmp(word[1], "all")) { + if (user->level > (enum lvl_value) command_table[CTOPIC].level + || user->level >= ARCH) { + for (rm = room_first; rm; rm = rm->next) { + *rm->topic = '\0'; + write_room_except(rm, "\n~FY~OLThe topic has been cleared.\n", user); + } + write_user(user, "All room topics have now been cleared\n"); + return; + } + write_user(user, + "You can only clear the topic of the room you are in.\n"); + return; + } + write_user(user, "Usage: ctopic [all]\n"); } \ No newline at end of file diff --git a/src/commands/delete_suggestions.c b/src/commands/delete_suggestions.c index 43e9eaa..1ff646c 100644 --- a/src/commands/delete_suggestions.c +++ b/src/commands/delete_suggestions.c @@ -1,60 +1,60 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * delete suggestions from the board - */ -void -delete_suggestions(UR_OBJECT user) -{ - char filename[80]; - int cnt; - - if (word_count < 2) { - write_user(user, "Usage: dsug all\n"); - write_user(user, "Usage: dsug <#>\n"); - write_user(user, "Usage: dsug to <#>\n"); - write_user(user, "Usage: dsug from <#> to <#>\n"); - return; - } - if (get_wipe_parameters(user) == -1) { - return; - } - if (!amsys->suggestion_count) { - write_user(user, "There are no suggestions to delete.\n"); - return; - } - sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); - if (user->wipe_from == -1) { - remove(filename); - write_user(user, "All suggestions deleted.\n"); - write_syslog(SYSLOG, 1, "%s wiped all suggestions from the %s board\n", - user->name, SUGBOARD); - amsys->suggestion_count = 0; - return; - } - if (user->wipe_from > amsys->suggestion_count) { - vwrite_user(user, "There %s only %d suggestion%s on the board.\n", - PLTEXT_IS(amsys->suggestion_count), amsys->suggestion_count, - PLTEXT_S(amsys->suggestion_count)); - return; - } - cnt = wipe_messages(filename, user->wipe_from, user->wipe_to, 0); - if (cnt == amsys->suggestion_count) { - remove(filename); - vwrite_user(user, - "There %s only %d suggestion%s on the board, all now deleted.\n", - PLTEXT_WAS(cnt), cnt, PLTEXT_S(cnt)); - write_syslog(SYSLOG, 1, "%s wiped all suggestions from the %s board\n", - user->name, SUGBOARD); - amsys->suggestion_count = 0; - return; - } - amsys->suggestion_count -= cnt; - vwrite_user(user, "%d suggestion%s deleted.\n", cnt, PLTEXT_S(cnt)); - write_syslog(SYSLOG, 1, "%s wiped %d suggestion%s from the %s board\n", - user->name, cnt, PLTEXT_S(cnt), SUGBOARD); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * delete suggestions from the board + */ +void +delete_suggestions(UR_OBJECT user) +{ + char filename[80]; + int cnt; + + if (word_count < 2) { + write_user(user, "Usage: dsug all\n"); + write_user(user, "Usage: dsug <#>\n"); + write_user(user, "Usage: dsug to <#>\n"); + write_user(user, "Usage: dsug from <#> to <#>\n"); + return; + } + if (get_wipe_parameters(user) == -1) { + return; + } + if (!amsys->suggestion_count) { + write_user(user, "There are no suggestions to delete.\n"); + return; + } + sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); + if (user->wipe_from == -1) { + remove(filename); + write_user(user, "All suggestions deleted.\n"); + write_syslog(SYSLOG, 1, "%s wiped all suggestions from the %s board\n", + user->name, SUGBOARD); + amsys->suggestion_count = 0; + return; + } + if (user->wipe_from > amsys->suggestion_count) { + vwrite_user(user, "There %s only %d suggestion%s on the board.\n", + PLTEXT_IS(amsys->suggestion_count), amsys->suggestion_count, + PLTEXT_S(amsys->suggestion_count)); + return; + } + cnt = wipe_messages(filename, user->wipe_from, user->wipe_to, 0); + if (cnt == amsys->suggestion_count) { + remove(filename); + vwrite_user(user, + "There %s only %d suggestion%s on the board, all now deleted.\n", + PLTEXT_WAS(cnt), cnt, PLTEXT_S(cnt)); + write_syslog(SYSLOG, 1, "%s wiped all suggestions from the %s board\n", + user->name, SUGBOARD); + amsys->suggestion_count = 0; + return; + } + amsys->suggestion_count -= cnt; + vwrite_user(user, "%d suggestion%s deleted.\n", cnt, PLTEXT_S(cnt)); + write_syslog(SYSLOG, 1, "%s wiped %d suggestion%s from the %s board\n", + user->name, cnt, PLTEXT_S(cnt), SUGBOARD); +} diff --git a/src/commands/delete_user.c b/src/commands/delete_user.c index c2cd56d..f795c67 100644 --- a/src/commands/delete_user.c +++ b/src/commands/delete_user.c @@ -1,75 +1,75 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Delete a user - */ -void -delete_user(UR_OBJECT user, int this_user) -{ - char name[USER_NAME_LEN + 1]; - UR_OBJECT u; - - if (this_user) { - /* - * User structure gets destructed in disconnect_user(), need to keep a - * copy of the name - */ - strcpy(name, user->name); - write_user(user, "\n~FR~LI~OLACCOUNT DELETED!\n"); - vwrite_room_except(user->room, user, "~OL~LI%s commits suicide!\n", - user->name); - write_syslog(SYSLOG, 1, "%s SUICIDED.\n", name); - disconnect_user(user); - clean_files(name); - rem_user_node(name); - return; - } - if (word_count < 2) { - write_user(user, "Usage: nuke \n"); - return; - } - *word[1] = toupper(*word[1]); - if (!strcmp(word[1], user->name)) { - write_user(user, - "Trying to delete yourself is the eleventh sign of madness.\n"); - return; - } - if (get_user(word[1])) { - /* Safety measure just in case. Will have to .kill them first */ - write_user(user, - "You cannot delete a user who is currently logged on.\n"); - return; - } - u = create_user(); - if (!u) { - vwrite_user(user, "%s: unable to create temporary user object.\n", - syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to create temporary user object in delete_user().\n"); - return; - } - strcpy(u->name, word[1]); - if (!load_user_details(u)) { - write_user(user, nosuchuser); - destruct_user(u); - destructed = 0; - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot delete a user of an equal or higher level than yourself.\n"); - destruct_user(u); - destructed = 0; - return; - } - clean_files(u->name); - rem_user_node(u->name); - vwrite_user(user, "\07~FR~OL~LIUser %s deleted!\n", u->name); - write_syslog(SYSLOG, 1, "%s DELETED %s.\n", user->name, u->name); - destruct_user(u); - destructed = 0; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Delete a user + */ +void +delete_user(UR_OBJECT user, int this_user) +{ + char name[USER_NAME_LEN + 1]; + UR_OBJECT u; + + if (this_user) { + /* + * User structure gets destructed in disconnect_user(), need to keep a + * copy of the name + */ + strcpy(name, user->name); + write_user(user, "\n~FR~LI~OLACCOUNT DELETED!\n"); + vwrite_room_except(user->room, user, "~OL~LI%s commits suicide!\n", + user->name); + write_syslog(SYSLOG, 1, "%s SUICIDED.\n", name); + disconnect_user(user); + clean_files(name); + rem_user_node(name); + return; + } + if (word_count < 2) { + write_user(user, "Usage: nuke \n"); + return; + } + *word[1] = toupper(*word[1]); + if (!strcmp(word[1], user->name)) { + write_user(user, + "Trying to delete yourself is the eleventh sign of madness.\n"); + return; + } + if (get_user(word[1])) { + /* Safety measure just in case. Will have to .kill them first */ + write_user(user, + "You cannot delete a user who is currently logged on.\n"); + return; + } + u = create_user(); + if (!u) { + vwrite_user(user, "%s: unable to create temporary user object.\n", + syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to create temporary user object in delete_user().\n"); + return; + } + strcpy(u->name, word[1]); + if (!load_user_details(u)) { + write_user(user, nosuchuser); + destruct_user(u); + destructed = 0; + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot delete a user of an equal or higher level than yourself.\n"); + destruct_user(u); + destructed = 0; + return; + } + clean_files(u->name); + rem_user_node(u->name); + vwrite_user(user, "\07~FR~OL~LIUser %s deleted!\n", u->name); + write_syslog(SYSLOG, 1, "%s DELETED %s.\n", user->name, u->name); + destruct_user(u); + destructed = 0; +} diff --git a/src/commands/demote.c b/src/commands/demote.c index bcfd190..f27b602 100644 --- a/src/commands/demote.c +++ b/src/commands/demote.c @@ -1,105 +1,105 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Demote a user - */ -void -demote(UR_OBJECT user) -{ - UR_OBJECT u; - int on; - enum lvl_value lvl; - - if (word_count < 2) { - write_user(user, "Usage: demote []\n"); - return; - } - if (word_count > 3) { - write_user(user, "Usage: demote []\n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - /* FIXME: lose .tpromote if .demote fails */ - /* first, gotta reset the user level if they have been temp promoted */ - if (u->real_level < u->level) { - u->level = u->real_level; - } - /* cannot demote new or jailed users */ - if (u->level <= NEW) { - vwrite_user(user, "You cannot demote a user of level %s or %s.\n", - user_level[NEW].name, user_level[JAILED].name); - done_retrieve(u); - return; - } - if (word_count < 3) { - lvl = (enum lvl_value) (u->level - 1); - } else { - strtoupper(word[2]); - lvl = get_level(word[2]); - if (lvl == NUM_LEVELS) { - vwrite_user(user, "You must select a level between %s and %s.\n", - user_level[NEW].name, user_level[ARCH].name); - done_retrieve(u); - return; - } - /* now runs checks if level option was used */ - if (lvl >= u->level) { - write_user(user, - "You cannot demote a user to a level higher than or equal to what they are now.\n"); - done_retrieve(u); - return; - } - if (lvl == JAILED) { - vwrite_user(user, "You cannot demote a user to the level %s.\n", - user_level[JAILED].name); - done_retrieve(u); - return; - } - } - if (u->level >= user->level) { - write_user(user, - "You cannot demote a user of an equal or higher level than yourself.\n"); - done_retrieve(u); - return; - } - /* do it */ - if (u->level == WIZ) { - clean_retire_list(u->name); - } - u->level = lvl; - u->unarrest = u->level; - u->real_level = u->level; - user_list_level(u->name, u->level); - u->vis = 1; - strcpy(u->date, long_date(1)); - add_user_date_node(u->name, (long_date(1))); - sprintf(text, "~FR~OLYou have been demoted to level: ~RS~OL%s.\n", - user_level[u->level].name); - if (!on) { - send_mail(user, u->name, text, 0); - } else { - write_user(u, text); - } - vwrite_level(u->level, 1, NORECORD, u, - "~FR~OL%s is demoted to level: ~RS~OL%s.\n", u->bw_recap, - user_level[u->level].name); - write_syslog(SYSLOG, 1, "%s DEMOTED %s to level %s.\n", user->name, u->name, - user_level[u->level].name); - sprintf(text, "Was ~FRdemoted~RS by %s to level %s.\n", user->name, - user_level[u->level].name); - add_history(u->name, 1, "%s", text); - if (!on) { - u->socket = -2; - strcpy(u->site, u->last_site); - } - save_user_details(u, on); - done_retrieve(u); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Demote a user + */ +void +demote(UR_OBJECT user) +{ + UR_OBJECT u; + int on; + enum lvl_value lvl; + + if (word_count < 2) { + write_user(user, "Usage: demote []\n"); + return; + } + if (word_count > 3) { + write_user(user, "Usage: demote []\n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + /* FIXME: lose .tpromote if .demote fails */ + /* first, gotta reset the user level if they have been temp promoted */ + if (u->real_level < u->level) { + u->level = u->real_level; + } + /* cannot demote new or jailed users */ + if (u->level <= NEW) { + vwrite_user(user, "You cannot demote a user of level %s or %s.\n", + user_level[NEW].name, user_level[JAILED].name); + done_retrieve(u); + return; + } + if (word_count < 3) { + lvl = (enum lvl_value) (u->level - 1); + } else { + strtoupper(word[2]); + lvl = get_level(word[2]); + if (lvl == NUM_LEVELS) { + vwrite_user(user, "You must select a level between %s and %s.\n", + user_level[NEW].name, user_level[ARCH].name); + done_retrieve(u); + return; + } + /* now runs checks if level option was used */ + if (lvl >= u->level) { + write_user(user, + "You cannot demote a user to a level higher than or equal to what they are now.\n"); + done_retrieve(u); + return; + } + if (lvl == JAILED) { + vwrite_user(user, "You cannot demote a user to the level %s.\n", + user_level[JAILED].name); + done_retrieve(u); + return; + } + } + if (u->level >= user->level) { + write_user(user, + "You cannot demote a user of an equal or higher level than yourself.\n"); + done_retrieve(u); + return; + } + /* do it */ + if (u->level == WIZ) { + clean_retire_list(u->name); + } + u->level = lvl; + u->unarrest = u->level; + u->real_level = u->level; + user_list_level(u->name, u->level); + u->vis = 1; + strcpy(u->date, long_date(1)); + add_user_date_node(u->name, (long_date(1))); + sprintf(text, "~FR~OLYou have been demoted to level: ~RS~OL%s.\n", + user_level[u->level].name); + if (!on) { + send_mail(user, u->name, text, 0); + } else { + write_user(u, text); + } + vwrite_level(u->level, 1, NORECORD, u, + "~FR~OL%s is demoted to level: ~RS~OL%s.\n", u->bw_recap, + user_level[u->level].name); + write_syslog(SYSLOG, 1, "%s DEMOTED %s to level %s.\n", user->name, u->name, + user_level[u->level].name); + sprintf(text, "Was ~FRdemoted~RS by %s to level %s.\n", user->name, + user_level[u->level].name); + add_history(u->name, 1, "%s", text); + if (!on) { + u->socket = -2; + strcpy(u->site, u->last_site); + } + save_user_details(u, on); + done_retrieve(u); +} diff --git a/src/commands/destroy_clone.c b/src/commands/destroy_clone.c index a35a08e..7649979 100644 --- a/src/commands/destroy_clone.c +++ b/src/commands/destroy_clone.c @@ -1,69 +1,69 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Destroy user clone - */ -void -destroy_clone(UR_OBJECT user) -{ - UR_OBJECT u, u2; - RM_OBJECT rm; - const char *name; - - /* Check room and user */ - if (word_count < 2) { - rm = user->room; - } else { - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - } - if (word_count > 2) { - u2 = get_user_name(user, word[2]); - if (!u2) { - write_user(user, notloggedon); - return; - } - if (u2->level >= user->level) { - write_user(user, - "You cannot destroy the clone of a user of an equal or higher level.\n"); - return; - } - } else { - u2 = user; - } - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE && u->room == rm && u->owner == u2) { - break; - } - } - if (!u) { - if (u2 == user) { - vwrite_user(user, "You do not have a clone in the %s.\n", rm->name); - } else { - vwrite_user(user, "%s~RS does not have a clone the %s.\n", u2->recap, - rm->name); - } - return; - } - destruct_user(u); - reset_access(rm); - write_user(user, - "~FM~OLYou whisper a sharp spell and the clone is destroyed.\n"); - name = user->vis ? user->bw_recap : invisname; - vwrite_room_except(user->room, user, "~FM~OL%s whispers a sharp spell...\n", - name); - vwrite_room(rm, "~FM~OLThe clone of %s shimmers and vanishes.\n", - u2->bw_recap); - if (u2 != user) { - vwrite_user(u2, "~OLSYSTEM: ~FR%s has destroyed your clone in the %s.\n", - user->bw_recap, rm->name); - } - destructed = 0; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Destroy user clone + */ +void +destroy_clone(UR_OBJECT user) +{ + UR_OBJECT u, u2; + RM_OBJECT rm; + const char *name; + + /* Check room and user */ + if (word_count < 2) { + rm = user->room; + } else { + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + } + if (word_count > 2) { + u2 = get_user_name(user, word[2]); + if (!u2) { + write_user(user, notloggedon); + return; + } + if (u2->level >= user->level) { + write_user(user, + "You cannot destroy the clone of a user of an equal or higher level.\n"); + return; + } + } else { + u2 = user; + } + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE && u->room == rm && u->owner == u2) { + break; + } + } + if (!u) { + if (u2 == user) { + vwrite_user(user, "You do not have a clone in the %s.\n", rm->name); + } else { + vwrite_user(user, "%s~RS does not have a clone the %s.\n", u2->recap, + rm->name); + } + return; + } + destruct_user(u); + reset_access(rm); + write_user(user, + "~FM~OLYou whisper a sharp spell and the clone is destroyed.\n"); + name = user->vis ? user->bw_recap : invisname; + vwrite_room_except(user->room, user, "~FM~OL%s whispers a sharp spell...\n", + name); + vwrite_room(rm, "~FM~OLThe clone of %s shimmers and vanishes.\n", + u2->bw_recap); + if (u2 != user) { + vwrite_user(u2, "~OLSYSTEM: ~FR%s has destroyed your clone in the %s.\n", + user->bw_recap, rm->name); + } + destructed = 0; +} diff --git a/src/commands/disconnect_netlink.c b/src/commands/disconnect_netlink.c index e2536e4..127f5b1 100644 --- a/src/commands/disconnect_netlink.c +++ b/src/commands/disconnect_netlink.c @@ -1,56 +1,56 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -#ifdef NETLINKS - -/* - * Disconnect a link - */ -void -disconnect_netlink(UR_OBJECT user) -{ - RM_OBJECT rm; - NL_OBJECT nl; - - if (word_count < 2) { - write_user(user, "Usage: disconnect \n"); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - nl = rm->netlink; - if (!nl) { - write_user(user, "That room is not linked to a service.\n"); - return; - } - if (nl->type == UNCONNECTED) { - write_user(user, "That rooms netlink is not connected.\n"); - return; - } - /* If link has hung at verification stage do not bother announcing it */ - if (nl->stage == UP) { - sprintf(text, "~OLSYSTEM:~RS Disconnecting from %s in the %s.\n", - nl->service, rm->name); - write_room(NULL, text); - write_syslog(NETLOG, 1, - "NETLINK: Link to %s in the %s disconnected by %s.\n", - nl->service, rm->name, user->name); - } else { - write_syslog(NETLOG, 1, "NETLINK: Link to %s disconnected by %s.\n", - nl->service, user->name); - } - shutdown_netlink(nl); - write_user(user, "Disconnected.\n"); -} - -#else - -#define NO_NETLINKS - -#endif + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +#ifdef NETLINKS + +/* + * Disconnect a link + */ +void +disconnect_netlink(UR_OBJECT user) +{ + RM_OBJECT rm; + NL_OBJECT nl; + + if (word_count < 2) { + write_user(user, "Usage: disconnect \n"); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + nl = rm->netlink; + if (!nl) { + write_user(user, "That room is not linked to a service.\n"); + return; + } + if (nl->type == UNCONNECTED) { + write_user(user, "That rooms netlink is not connected.\n"); + return; + } + /* If link has hung at verification stage do not bother announcing it */ + if (nl->stage == UP) { + sprintf(text, "~OLSYSTEM:~RS Disconnecting from %s in the %s.\n", + nl->service, rm->name); + write_room(NULL, text); + write_syslog(NETLOG, 1, + "NETLINK: Link to %s in the %s disconnected by %s.\n", + nl->service, rm->name, user->name); + } else { + write_syslog(NETLOG, 1, "NETLINK: Link to %s disconnected by %s.\n", + nl->service, user->name); + } + shutdown_netlink(nl); + write_user(user, "Disconnected.\n"); +} + +#else + +#define NO_NETLINKS + +#endif diff --git a/src/commands/display.c b/src/commands/display.c index 33071f9..d4f06c9 100644 --- a/src/commands/display.c +++ b/src/commands/display.c @@ -1,67 +1,67 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Display some files to the user. This was once intergrated with the ".help" command, - * but due to the new processing that goes through it was moved into its own command. - * The files listed are now stored in MISCFILES rather than HELPFILES as they may not - * necessarily be for any help commands. - */ -void -display_files(UR_OBJECT user, int admins) -{ - char filename[128]; - int ret; - - if (word_count < 2) { - if (!admins) { - sprintf(filename, "%s/%s", TEXTFILES, SHOWFILES); - } else { - sprintf(filename, "%s/%s/%s", TEXTFILES, ADMINFILES, SHOWFILES); - } - ret = more(user, user->socket, filename); - if (!ret) { - if (!admins) { - write_user(user, "There is no list of files at the moment.\n"); - } else { - write_user(user, "There is no list of admin files at the moment.\n"); - } - return; - } - if (ret == 1) { - user->misc_op = 2; - } - return; - } - /* check for any illegal characters */ - if (strpbrk(word[1], "./")) { - if (!admins) { - write_user(user, "Sorry, there are no files with that name.\n"); - } else { - write_user(user, "Sorry, there are no admin files with that name.\n"); - } - return; - } - /* show the file */ - if (!admins) { - sprintf(filename, "%s/%s", TEXTFILES, word[1]); - } else { - sprintf(filename, "%s/%s/%s", TEXTFILES, ADMINFILES, word[1]); - } - ret = more(user, user->socket, filename); - if (!ret) { - if (!admins) { - write_user(user, "Sorry, there are no files with that name.\n"); - } else { - write_user(user, "Sorry, there are no admin files with that name.\n"); - } - return; - } - if (ret == 1) { - user->misc_op = 2; - } - return; -} - +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Display some files to the user. This was once integrated with the ".help" command, + * but due to the new processing that goes through it was moved into its own command. + * The files listed are now stored in MISCFILES rather than HELPFILES as they may not + * necessarily be for any help commands. + */ +void +display_files(UR_OBJECT user, int admins) +{ + char filename[128]; + int ret; + + if (word_count < 2) { + if (!admins) { + sprintf(filename, "%s/%s", TEXTFILES, SHOWFILES); + } else { + sprintf(filename, "%s/%s/%s", TEXTFILES, ADMINFILES, SHOWFILES); + } + ret = more(user, user->socket, filename); + if (!ret) { + if (!admins) { + write_user(user, "There is no list of files at the moment.\n"); + } else { + write_user(user, "There is no list of admin files at the moment.\n"); + } + return; + } + if (ret == 1) { + user->misc_op = 2; + } + return; + } + /* check for any illegal characters */ + if (strpbrk(word[1], "./")) { + if (!admins) { + write_user(user, "Sorry, there are no files with that name.\n"); + } else { + write_user(user, "Sorry, there are no admin files with that name.\n"); + } + return; + } + /* show the file */ + if (!admins) { + sprintf(filename, "%s/%s", TEXTFILES, word[1]); + } else { + sprintf(filename, "%s/%s/%s", TEXTFILES, ADMINFILES, word[1]); + } + ret = more(user, user->socket, filename); + if (!ret) { + if (!admins) { + write_user(user, "Sorry, there are no files with that name.\n"); + } else { + write_user(user, "Sorry, there are no admin files with that name.\n"); + } + return; + } + if (ret == 1) { + user->misc_op = 2; + } + return; +} + diff --git a/src/commands/dmail.c b/src/commands/dmail.c index 6bf83a7..87390b0 100644 --- a/src/commands/dmail.c +++ b/src/commands/dmail.c @@ -1,56 +1,56 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Delete some or all of your mail. A problem here is once we have deleted - * some mail from the file do we mark the file as read? If not we could - * have a situation where the user deletes all his mail but still gets - * the YOU HAVE UNREAD MAIL message on logging on if the idiot forgot to - * read it first. - */ -void -dmail(UR_OBJECT user) -{ - int num, cnt; - char filename[80]; - - if (word_count < 2) { - write_user(user, "Usage: dmail all\n"); - write_user(user, " dmail <#>\n"); - write_user(user, " dmail to <#>\n"); - write_user(user, " dmail from <#> to <#>\n"); - return; - } - if (get_wipe_parameters(user) == -1) { - return; - } - num = mail_sizes(user->name, 0); - if (!num) { - write_user(user, "You have no mail to delete.\n"); - return; - } - sprintf(filename, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); - if (user->wipe_from == -1) { - write_user(user, "\07~OL~FR~LIDelete all of your mail?~RS (y/n): "); - user->misc_op = 18; - return; - } - if (user->wipe_from > num) { - vwrite_user(user, "You only have %d mail message%s.\n", num, - PLTEXT_S(num)); - return; - } - cnt = wipe_messages(filename, user->wipe_from, user->wipe_to, 1); - reset_mail_counts(user); - if (cnt == num) { - remove(filename); - vwrite_user(user, "There %s only %d mail message%s, all now deleted.\n", - PLTEXT_WAS(cnt), cnt, PLTEXT_S(cnt)); - return; - } - vwrite_user(user, "%d mail message%s deleted.\n", cnt, PLTEXT_S(cnt)); - user->read_mail = time(0) + 1; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Delete some or all of your mail. A problem here is once we have deleted + * some mail from the file do we mark the file as read? If not we could + * have a situation where the user deletes all his mail but still gets + * the YOU HAVE UNREAD MAIL message on logging on if the idiot forgot to + * read it first. + */ +void +dmail(UR_OBJECT user) +{ + int num, cnt; + char filename[80]; + + if (word_count < 2) { + write_user(user, "Usage: dmail all\n"); + write_user(user, " dmail <#>\n"); + write_user(user, " dmail to <#>\n"); + write_user(user, " dmail from <#> to <#>\n"); + return; + } + if (get_wipe_parameters(user) == -1) { + return; + } + num = mail_sizes(user->name, 0); + if (!num) { + write_user(user, "You have no mail to delete.\n"); + return; + } + sprintf(filename, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); + if (user->wipe_from == -1) { + write_user(user, "\07~OL~FR~LIDelete all of your mail?~RS (y/n): "); + user->misc_op = 18; + return; + } + if (user->wipe_from > num) { + vwrite_user(user, "You only have %d mail message%s.\n", num, + PLTEXT_S(num)); + return; + } + cnt = wipe_messages(filename, user->wipe_from, user->wipe_to, 1); + reset_mail_counts(user); + if (cnt == num) { + remove(filename); + vwrite_user(user, "There %s only %d mail message%s, all now deleted.\n", + PLTEXT_WAS(cnt), cnt, PLTEXT_S(cnt)); + return; + } + vwrite_user(user, "%d mail message%s deleted.\n", cnt, PLTEXT_S(cnt)); + user->read_mail = time(0) + 1; +} diff --git a/src/commands/dump.c b/src/commands/dump.c index 63c39ed..bf8fdbb 100644 --- a/src/commands/dump.c +++ b/src/commands/dump.c @@ -1,281 +1,281 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Allows you to dump certain things to files as a record - */ -void -dump_to_file(UR_OBJECT user) -{ - char filename[80], bstr[32]; - FILE *fp; - UR_OBJECT u; - UD_OBJECT d; - RM_OBJECT rm; - CMD_OBJECT cmd; - size_t l; - int ucount, dcount, rmcount, cmdcount, lcount; - int tsize; - int drcount; -#ifdef NETLINKS - NL_OBJECT nl; - int nlcount; -#endif - enum lvl_value lvl; - int days, hours, mins, secs; - int i, j; - - if (word_count < 2) { - write_user(user, "Usage: dump -u|-r |-c|-m|-s\n"); - return; - } - strtolower(word[1]); - /* see if -r switch was used : dump all users of given level */ - if (!strcmp("-r", word[1])) { - if (word_count < 3) { - write_user(user, "Usage: dump -r \n"); - return; - } - strtoupper(word[2]); - lvl = get_level(word[2]); - if (lvl == NUM_LEVELS) { - write_user(user, "Usage: dump -r \n"); - return; - } - sprintf(filename, "%s/%s.dump", DUMPFILES, user_level[lvl].name); - fp = fopen(filename, "w"); - if (!fp) { - write_user(user, - "There was an error trying to open the file to dump to.\n"); - write_syslog(SYSLOG, 0, - "Unable to open dump file %s in dump_to_file().\n", - filename); - return; - } - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "Users of level %s %s\n", user_level[lvl].name, long_date(1)); - fprintf(fp, - "------------------------------------------------------------------------------\n"); - drcount = 0; - for (d = first_user_entry; d; d = d->next) { - if (d->level != lvl) { - continue; - } - fprintf(fp, "%s\n", d->name); - ++drcount; - } - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "Total users at %s : %d\n", user_level[lvl].name, drcount); - fprintf(fp, - "------------------------------------------------------------------------------\n\n"); - fclose(fp); - sprintf(text, - "Dumped rank ~OL%s~RS to file. ~OL%d~RS user%s recorded.\n", - user_level[lvl].name, drcount, PLTEXT_S(drcount)); - write_user(user, text); - return; - } - /* check to see if -u switch was used : dump all users */ - if (!strcmp("-u", word[1])) { - sprintf(filename, "%s/users.dump", DUMPFILES); - fp = fopen(filename, "w"); - if (!fp) { - write_user(user, - "There was an error trying to open the file to dump to.\n"); - write_syslog(SYSLOG, 0, - "Unable to open dump file %s in dump_to_file().\n", - filename); - return; - } - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "All users %s\n", long_date(1)); - fprintf(fp, - "------------------------------------------------------------------------------\n"); - dcount = 0; - for (d = first_user_entry; d; d = d->next) { - fprintf(fp, "%s\n", d->name); - ++dcount; - } - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "Total users : %d\n", dcount); - fprintf(fp, - "------------------------------------------------------------------------------\n\n"); - fclose(fp); - sprintf(text, "Dumped all users to file. ~OL%d~RS user%s recorded.\n", - dcount, PLTEXT_S(dcount)); - write_user(user, text); - return; - } - /* check to see if -c switch was used : dump last few commands used */ - if (!strcmp("-c", word[1])) { - sprintf(filename, "%s/commands.dump", DUMPFILES); - fp = fopen(filename, "w"); - if (!fp) { - write_user(user, - "There was an error trying to open the file to dump to.\n"); - write_syslog(SYSLOG, 0, - "Unable to open dump file %s in dump_to_file().\n", - filename); - return; - } - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "The last 16 commands %s\n", long_date(1)); - fprintf(fp, - "------------------------------------------------------------------------------\n"); - j = amsys->last_cmd_cnt - 16; - for (i = j > 0 ? j : 0; i < amsys->last_cmd_cnt; ++i) { - fprintf(fp, "%s\n", cmd_history[i & 15]); - } - fprintf(fp, - "------------------------------------------------------------------------------\n\n"); - fclose(fp); - write_user(user, "Dumped the last 16 commands that have been used.\n"); - return; - } - /* check to see if -m was used : dump memory currently being used */ - if (!strcmp("-m", word[1])) { - sprintf(filename, "%s/memory.dump", DUMPFILES); - fp = fopen(filename, "w"); - if (!fp) { - write_user(user, - "There was an error trying to open the file to dump to.\n"); - write_syslog(SYSLOG, 0, - "Unable to open dump file %s in dump_to_file().\n", - filename); - return; - } - ucount = 0; - for (u = user_first; u; u = u->next) { - ++ucount; - } - dcount = 0; - for (d = first_user_entry; d; d = d->next) { - ++dcount; - } - rmcount = 0; - for (rm = room_first; rm; rm = rm->next) { - ++rmcount; - } - cmdcount = 0; - for (cmd = first_command; cmd; cmd = cmd->next) { - ++cmdcount; - } - lcount = 0; - for (l = 0; l < LASTLOGON_NUM; ++l) { - ++lcount; - } - tsize = - ucount * (sizeof *u) + rmcount * (sizeof *rm) + dcount * (sizeof *d) + - cmdcount * (sizeof *cmd) + (sizeof *amsys) + - lcount * (sizeof *last_login_info); -#ifdef NETLINKS - nlcount = 0; - for (nl = nl_first; nl; nl = nl->next) { - ++nlcount; - } - tsize += nlcount * (sizeof *nl); -#endif - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "Memory Object Allocation %s\n", long_date(1)); - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "users", - ucount, (int) (sizeof *u), ucount * (int) (sizeof *u)); - fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "all users", - dcount, (int) (sizeof *d), dcount * (int) (sizeof *d)); - fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "rooms", - rmcount, (int) (sizeof *rm), rmcount * (int) (sizeof *rm)); - fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "commands", - cmdcount, (int) (sizeof *cmd), cmdcount * (int) (sizeof *cmd)); - fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "system", 1, - (int) (sizeof *amsys), 1 * (int) (sizeof *amsys)); - fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "last logins", - lcount, (int) (sizeof *last_login_info), - lcount * (int) (sizeof *last_login_info)); -#ifdef NETLINKS - fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", - "netlinks", nlcount, (int) (sizeof *nl), - nlcount * (int) (sizeof *nl)); -#endif - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, " %-16s: %12.3f Mb %8d total bytes\n", "total", - tsize / 1048576.0, tsize); - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fclose(fp); - write_user(user, - "Dumped the memory currently being used by the talker.\n"); - return; - } - /* check to see if -s switch was used : show system details */ - if (!strcmp("-s", word[1])) { - sprintf(filename, "%s/system.dump", DUMPFILES); - fp = fopen(filename, "w"); - if (!fp) { - write_user(user, - "There was an error trying to open the file to dump to.\n"); - write_syslog(SYSLOG, 0, - "Unable to open dump file %s in dump_to_file().\n", - filename); - return; - } - strftime(bstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&amsys->boot_time)); - secs = (int) (time(0) - amsys->boot_time); - days = secs / 86400; - hours = (secs % 86400) / 3600; - mins = (secs % 3600) / 60; - secs = secs % 60; - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "System details %s\n", long_date(1)); - fprintf(fp, - "------------------------------------------------------------------------------\n"); - fprintf(fp, "Node name : %s\n", amsys->uts.nodename); - fprintf(fp, "Running on : %s %s %s %s\n", amsys->uts.machine, - amsys->uts.sysname, amsys->uts.release, amsys->uts.version); - fprintf(fp, "Talker PID : %u\n", getpid()); - fprintf(fp, "Booted : %s\n", bstr); - fprintf(fp, - "Uptime : %d day%s, %d hour%s, %d minute%s, %d second%s\n", - days, PLTEXT_S(days), hours, PLTEXT_S(hours), mins, - PLTEXT_S(mins), secs, PLTEXT_S(secs)); -#ifdef NETLINKS - fprintf(fp, "Netlinks : Compiled and running\n"); -#else - fprintf(fp, "Netlinks : Not currently compiled or running\n"); -#endif - switch (amsys->resolve_ip) { - default: - fprintf(fp, "IP Resolve : Off\n"); - break; - case 1: - fprintf(fp, "IP Resolve : On via automatic library\n"); - break; -#ifdef MANDNS - case 2: - fprintf(fp, "IP Resolve : On via manual program\n"); - break; -#endif -#ifdef IDENTD - case 3: - fprintf(fp, "IP Resolve : On via ident daemon\n"); - break; -#endif - } - fprintf(fp, - "------------------------------------------------------------------------------\n\n"); - fclose(fp); - write_user(user, "Dumped the system details.\n"); - return; - } - write_user(user, "Usage: dump -u|-r |-c|-m|-s\n"); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Allows you to dump certain things to files as a record + */ +void +dump_to_file(UR_OBJECT user) +{ + char filename[80], bstr[32]; + FILE *fp; + UR_OBJECT u; + UD_OBJECT d; + RM_OBJECT rm; + CMD_OBJECT cmd; + size_t l; + int ucount, dcount, rmcount, cmdcount, lcount; + int tsize; + int drcount; +#ifdef NETLINKS + NL_OBJECT nl; + int nlcount; +#endif + enum lvl_value lvl; + int days, hours, mins, secs; + int i, j; + + if (word_count < 2) { + write_user(user, "Usage: dump -u|-r |-c|-m|-s\n"); + return; + } + strtolower(word[1]); + /* see if -r switch was used : dump all users of given level */ + if (!strcmp("-r", word[1])) { + if (word_count < 3) { + write_user(user, "Usage: dump -r \n"); + return; + } + strtoupper(word[2]); + lvl = get_level(word[2]); + if (lvl == NUM_LEVELS) { + write_user(user, "Usage: dump -r \n"); + return; + } + sprintf(filename, "%s/%s.dump", DUMPFILES, user_level[lvl].name); + fp = fopen(filename, "w"); + if (!fp) { + write_user(user, + "There was an error trying to open the file to dump to.\n"); + write_syslog(SYSLOG, 0, + "Unable to open dump file %s in dump_to_file().\n", + filename); + return; + } + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "Users of level %s %s\n", user_level[lvl].name, long_date(1)); + fprintf(fp, + "------------------------------------------------------------------------------\n"); + drcount = 0; + for (d = first_user_entry; d; d = d->next) { + if (d->level != lvl) { + continue; + } + fprintf(fp, "%s\n", d->name); + ++drcount; + } + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "Total users at %s : %d\n", user_level[lvl].name, drcount); + fprintf(fp, + "------------------------------------------------------------------------------\n\n"); + fclose(fp); + sprintf(text, + "Dumped rank ~OL%s~RS to file. ~OL%d~RS user%s recorded.\n", + user_level[lvl].name, drcount, PLTEXT_S(drcount)); + write_user(user, text); + return; + } + /* check to see if -u switch was used : dump all users */ + if (!strcmp("-u", word[1])) { + sprintf(filename, "%s/users.dump", DUMPFILES); + fp = fopen(filename, "w"); + if (!fp) { + write_user(user, + "There was an error trying to open the file to dump to.\n"); + write_syslog(SYSLOG, 0, + "Unable to open dump file %s in dump_to_file().\n", + filename); + return; + } + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "All users %s\n", long_date(1)); + fprintf(fp, + "------------------------------------------------------------------------------\n"); + dcount = 0; + for (d = first_user_entry; d; d = d->next) { + fprintf(fp, "%s\n", d->name); + ++dcount; + } + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "Total users : %d\n", dcount); + fprintf(fp, + "------------------------------------------------------------------------------\n\n"); + fclose(fp); + sprintf(text, "Dumped all users to file. ~OL%d~RS user%s recorded.\n", + dcount, PLTEXT_S(dcount)); + write_user(user, text); + return; + } + /* check to see if -c switch was used : dump last few commands used */ + if (!strcmp("-c", word[1])) { + sprintf(filename, "%s/commands.dump", DUMPFILES); + fp = fopen(filename, "w"); + if (!fp) { + write_user(user, + "There was an error trying to open the file to dump to.\n"); + write_syslog(SYSLOG, 0, + "Unable to open dump file %s in dump_to_file().\n", + filename); + return; + } + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "The last 16 commands %s\n", long_date(1)); + fprintf(fp, + "------------------------------------------------------------------------------\n"); + j = amsys->last_cmd_cnt - 16; + for (i = j > 0 ? j : 0; i < amsys->last_cmd_cnt; ++i) { + fprintf(fp, "%s\n", cmd_history[i & 15]); + } + fprintf(fp, + "------------------------------------------------------------------------------\n\n"); + fclose(fp); + write_user(user, "Dumped the last 16 commands that have been used.\n"); + return; + } + /* check to see if -m was used : dump memory currently being used */ + if (!strcmp("-m", word[1])) { + sprintf(filename, "%s/memory.dump", DUMPFILES); + fp = fopen(filename, "w"); + if (!fp) { + write_user(user, + "There was an error trying to open the file to dump to.\n"); + write_syslog(SYSLOG, 0, + "Unable to open dump file %s in dump_to_file().\n", + filename); + return; + } + ucount = 0; + for (u = user_first; u; u = u->next) { + ++ucount; + } + dcount = 0; + for (d = first_user_entry; d; d = d->next) { + ++dcount; + } + rmcount = 0; + for (rm = room_first; rm; rm = rm->next) { + ++rmcount; + } + cmdcount = 0; + for (cmd = first_command; cmd; cmd = cmd->next) { + ++cmdcount; + } + lcount = 0; + for (l = 0; l < LASTLOGON_NUM; ++l) { + ++lcount; + } + tsize = + ucount * (sizeof *u) + rmcount * (sizeof *rm) + dcount * (sizeof *d) + + cmdcount * (sizeof *cmd) + (sizeof *amsys) + + lcount * (sizeof *last_login_info); +#ifdef NETLINKS + nlcount = 0; + for (nl = nl_first; nl; nl = nl->next) { + ++nlcount; + } + tsize += nlcount * (sizeof *nl); +#endif + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "Memory Object Allocation %s\n", long_date(1)); + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "users", + ucount, (int) (sizeof *u), ucount * (int) (sizeof *u)); + fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "all users", + dcount, (int) (sizeof *d), dcount * (int) (sizeof *d)); + fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "rooms", + rmcount, (int) (sizeof *rm), rmcount * (int) (sizeof *rm)); + fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "commands", + cmdcount, (int) (sizeof *cmd), cmdcount * (int) (sizeof *cmd)); + fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "system", 1, + (int) (sizeof *amsys), 1 * (int) (sizeof *amsys)); + fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", "last logins", + lcount, (int) (sizeof *last_login_info), + lcount * (int) (sizeof *last_login_info)); +#ifdef NETLINKS + fprintf(fp, " %-16s: %8d * %8d bytes = %8d total bytes\n", + "netlinks", nlcount, (int) (sizeof *nl), + nlcount * (int) (sizeof *nl)); +#endif + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, " %-16s: %12.3f Mb %8d total bytes\n", "total", + tsize / 1048576.0, tsize); + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fclose(fp); + write_user(user, + "Dumped the memory currently being used by the talker.\n"); + return; + } + /* check to see if -s switch was used : show system details */ + if (!strcmp("-s", word[1])) { + sprintf(filename, "%s/system.dump", DUMPFILES); + fp = fopen(filename, "w"); + if (!fp) { + write_user(user, + "There was an error trying to open the file to dump to.\n"); + write_syslog(SYSLOG, 0, + "Unable to open dump file %s in dump_to_file().\n", + filename); + return; + } + strftime(bstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&amsys->boot_time)); + secs = (int) (time(0) - amsys->boot_time); + days = secs / 86400; + hours = (secs % 86400) / 3600; + mins = (secs % 3600) / 60; + secs = secs % 60; + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "System details %s\n", long_date(1)); + fprintf(fp, + "------------------------------------------------------------------------------\n"); + fprintf(fp, "Node name : %s\n", amsys->uts.nodename); + fprintf(fp, "Running on : %s %s %s %s\n", amsys->uts.machine, + amsys->uts.sysname, amsys->uts.release, amsys->uts.version); + fprintf(fp, "Talker PID : %u\n", getpid()); + fprintf(fp, "Booted : %s\n", bstr); + fprintf(fp, + "Uptime : %d day%s, %d hour%s, %d minute%s, %d second%s\n", + days, PLTEXT_S(days), hours, PLTEXT_S(hours), mins, + PLTEXT_S(mins), secs, PLTEXT_S(secs)); +#ifdef NETLINKS + fprintf(fp, "Netlinks : Compiled and running\n"); +#else + fprintf(fp, "Netlinks : Not currently compiled or running\n"); +#endif + switch (amsys->resolve_ip) { + default: + fprintf(fp, "IP Resolve : Off\n"); + break; + case 1: + fprintf(fp, "IP Resolve : On via automatic library\n"); + break; +#ifdef MANDNS + case 2: + fprintf(fp, "IP Resolve : On via manual program\n"); + break; +#endif +#ifdef IDENTD + case 3: + fprintf(fp, "IP Resolve : On via ident daemon\n"); + break; +#endif + } + fprintf(fp, + "------------------------------------------------------------------------------\n\n"); + fclose(fp); + write_user(user, "Dumped the system details.\n"); + return; + } + write_user(user, "Usage: dump -u|-r |-c|-m|-s\n"); +} diff --git a/src/commands/echo.c b/src/commands/echo.c index 7f661ab..7f2b688 100644 --- a/src/commands/echo.c +++ b/src/commands/echo.c @@ -1,45 +1,45 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Echo something to screen - */ -void -echo(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: echo \n"; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot echo.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_private_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - write_monitor(user, user->room, 0); - sprintf(text, "+ %s\n", inpstr); - record(user->room, text); - write_room(user->room, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Echo something to screen + */ +void +echo(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: echo \n"; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot echo.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_private_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + write_monitor(user, user->room, 0); + sprintf(text, "+ %s\n", inpstr); + record(user->room, text); + write_room(user->room, text); +} diff --git a/src/commands/emote.c b/src/commands/emote.c index 74954c4..81afc71 100644 --- a/src/commands/emote.c +++ b/src/commands/emote.c @@ -1,56 +1,56 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Emote something - */ -void -emote(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: emote \n"; - const char *name; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot emote.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_private_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - if (!user->vis) { - write_monitor(user, user->room, 0); - } - name = user->vis ? user->recap : invisname; - if (user->type == CLONE_TYPE) { - sprintf(text, "Clone of %s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", - inpstr); - record(user->room, text); - write_room(user->room, text); - return; - } - sprintf(text, "%s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", inpstr); - record(user->room, text); - write_room_ignore(user->room, user, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Emote something + */ +void +emote(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: emote \n"; + const char *name; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot emote.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_private_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + if (!user->vis) { + write_monitor(user, user->room, 0); + } + name = user->vis ? user->recap : invisname; + if (user->type == CLONE_TYPE) { + sprintf(text, "Clone of %s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", + inpstr); + record(user->room, text); + write_room(user->room, text); + return; + } + sprintf(text, "%s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", inpstr); + record(user->room, text); + write_room_ignore(user->room, user, text); +} diff --git a/src/commands/enter_profile.c b/src/commands/enter_profile.c index cda814d..52565ae 100644 --- a/src/commands/enter_profile.c +++ b/src/commands/enter_profile.c @@ -1,42 +1,42 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Enter user profile - */ -void -enter_profile(UR_OBJECT user, char *inpstr) -{ - char filename[80]; - char *c; - FILE *fp; - - if (inpstr) { - if (word_count < 2) { - write_user(user, "\n~BB*** Writing profile ***\n\n"); - user->misc_op = 5; - editor(user, NULL); - return; - } - strcat(inpstr, "\n"); - } else { - inpstr = user->malloc_start; - } - sprintf(filename, "%s/%s/%s.P", USERFILES, USERPROFILES, user->name); - fp = fopen(filename, "w"); - if (!fp) { - vwrite_user(user, "%s: cannot save your profile.\n", syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Cannot open file %s to write in enter_profile().\n", - filename); - return; - } - for (c = inpstr; *c; ++c) { - putc(*c, fp); - } - fclose(fp); - write_user(user, "Profile stored.\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Enter user profile + */ +void +enter_profile(UR_OBJECT user, char *inpstr) +{ + char filename[80]; + char *c; + FILE *fp; + + if (inpstr) { + if (word_count < 2) { + write_user(user, "\n~BB*** Writing profile ***\n\n"); + user->misc_op = 5; + editor(user, NULL); + return; + } + strcat(inpstr, "\n"); + } else { + inpstr = user->malloc_start; + } + sprintf(filename, "%s/%s/%s.P", USERFILES, USERPROFILES, user->name); + fp = fopen(filename, "w"); + if (!fp) { + vwrite_user(user, "%s: cannot save your profile.\n", syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Cannot open file %s to write in enter_profile().\n", + filename); + return; + } + for (c = inpstr; *c; ++c) { + putc(*c, fp); + } + fclose(fp); + write_user(user, "Profile stored.\n"); +} diff --git a/src/commands/examine.c b/src/commands/examine.c index 062e216..21fb388 100644 --- a/src/commands/examine.c +++ b/src/commands/examine.c @@ -1,133 +1,133 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Examine a user - */ -void -examine(UR_OBJECT user) -{ - char filename[80], text2[ARR_SIZE]; - FILE *fp; - UR_OBJECT u; - int on, days, hours, mins, timelen, days2, hours2, mins2, idle, cnt, - newmail; - int lastdays, lasthours, lastmins; - - if (word_count < 2) { - u = user; - on = 1; - } else { - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - } - - days = u->total_login / 86400; - hours = (u->total_login % 86400) / 3600; - mins = (u->total_login % 3600) / 60; - timelen = (int) (time(0) - u->last_login); - days2 = timelen / 86400; - hours2 = (timelen % 86400) / 3600; - mins2 = (timelen % 3600) / 60; - - write_user(user, - "+----------------------------------------------------------------------------+\n"); - sprintf(text2, "%s~RS %s", u->recap, u->desc); - cnt = 45 + teslen(text2, 45); - vwrite_user(user, "Name : %-*.*s~RS Level : %s\n", cnt, cnt, text2, - user_level[u->level].name); - if (!on) { - lastdays = u->last_login_len / 86400; - lasthours = (u->last_login_len % 86400) / 3600; - lastmins = (u->last_login_len % 3600) / 60; - - strftime(text2, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", - localtime(&u->last_login)); - vwrite_user(user, "Last login : %s\n", text2); - vwrite_user(user, "Which was : %d day%s, %d hour%s, %d minute%s ago\n", - days2, PLTEXT_S(days2), hours2, PLTEXT_S(hours2), mins2, - PLTEXT_S(mins2)); - vwrite_user(user, - "Was on for : %d day%s, %d hour%s, %d minute%s\nTotal login: %d day%s, %d hour%s, %d minute%s\n", - lastdays, PLTEXT_S(lastdays), lasthours, PLTEXT_S(lasthours), - lastmins, PLTEXT_S(lastmins), days, PLTEXT_S(days), hours, - PLTEXT_S(hours), mins, PLTEXT_S(mins)); - if (user->level >= WIZ) { - vwrite_user(user, "Last site : %s\n", u->last_site); - } - newmail = mail_sizes(u->name, 1); - if (newmail) { - vwrite_user(user, "%s~RS has unread mail (%d).\n", u->recap, newmail); - } - write_user(user, - "+----- ~OL~FCProfile~RS --------------------------------------------------------------+\n\n"); - sprintf(filename, "%s/%s/%s.P", USERFILES, USERPROFILES, u->name); - fp = fopen(filename, "r"); - if (!fp) { - write_user(user, "User has not yet witten a profile.\n\n"); - } else { - fclose(fp); - more(user, user->socket, filename); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - done_retrieve(u); - return; - } - idle = (int) (time(0) - u->last_input) / 60; - if (u->malloc_start) { - vwrite_user(user, "Ignoring all: ~FCUsing Line Editor\n"); - } else { - vwrite_user(user, "Ignoring all: %s\n", noyes[u->ignall]); - } - strftime(text2, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", - localtime(&u->last_login)); - vwrite_user(user, - "On since : %s\nOn for : %d day%s, %d hour%s, %d minute%s\n", - text2, days2, PLTEXT_S(days2), hours2, PLTEXT_S(hours2), mins2, - PLTEXT_S(mins2)); - if (u->afk) { - vwrite_user(user, "Idle for : %d minute%s ~BR(AFK)\n", idle, - PLTEXT_S(idle)); - if (*u->afk_mesg) { - vwrite_user(user, "AFK message : %s\n", u->afk_mesg); - } - } else { - vwrite_user(user, "Idle for : %d minute%s\n", idle, PLTEXT_S(idle)); - } - vwrite_user(user, "Total login : %d day%s, %d hour%s, %d minute%s\n", days, - PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins)); - if (u->socket >= 0) { - if (user->level >= WIZ) { - vwrite_user(user, "Site : %-40.40s Port : %s\n", u->site, - u->site_port); - } -#ifdef NETLINKS - if (!u->room) { - vwrite_user(user, "Home service: %s\n", u->netlink->service); - } -#endif - } - newmail = mail_sizes(u->name, 1); - if (newmail) { - vwrite_user(user, "%s~RS has unread mail (%d).\n", u->recap, newmail); - } - write_user(user, - "+----- ~OL~FCProfile~RS --------------------------------------------------------------+\n\n"); - sprintf(filename, "%s/%s/%s.P", USERFILES, USERPROFILES, u->name); - fp = fopen(filename, "r"); - if (!fp) { - write_user(user, "User has not yet written a profile.\n\n"); - } else { - fclose(fp); - more(user, user->socket, filename); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Examine a user + */ +void +examine(UR_OBJECT user) +{ + char filename[80], text2[ARR_SIZE]; + FILE *fp; + UR_OBJECT u; + int on, days, hours, mins, timelen, days2, hours2, mins2, idle, cnt, + newmail; + int lastdays, lasthours, lastmins; + + if (word_count < 2) { + u = user; + on = 1; + } else { + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + } + + days = u->total_login / 86400; + hours = (u->total_login % 86400) / 3600; + mins = (u->total_login % 3600) / 60; + timelen = (int) (time(0) - u->last_login); + days2 = timelen / 86400; + hours2 = (timelen % 86400) / 3600; + mins2 = (timelen % 3600) / 60; + + write_user(user, + "+----------------------------------------------------------------------------+\n"); + sprintf(text2, "%s~RS %s", u->recap, u->desc); + cnt = 45 + teslen(text2, 45); + vwrite_user(user, "Name : %-*.*s~RS Level : %s\n", cnt, cnt, text2, + user_level[u->level].name); + if (!on) { + lastdays = u->last_login_len / 86400; + lasthours = (u->last_login_len % 86400) / 3600; + lastmins = (u->last_login_len % 3600) / 60; + + strftime(text2, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", + localtime(&u->last_login)); + vwrite_user(user, "Last login : %s\n", text2); + vwrite_user(user, "Which was : %d day%s, %d hour%s, %d minute%s ago\n", + days2, PLTEXT_S(days2), hours2, PLTEXT_S(hours2), mins2, + PLTEXT_S(mins2)); + vwrite_user(user, + "Was on for : %d day%s, %d hour%s, %d minute%s\nTotal login: %d day%s, %d hour%s, %d minute%s\n", + lastdays, PLTEXT_S(lastdays), lasthours, PLTEXT_S(lasthours), + lastmins, PLTEXT_S(lastmins), days, PLTEXT_S(days), hours, + PLTEXT_S(hours), mins, PLTEXT_S(mins)); + if (user->level >= WIZ) { + vwrite_user(user, "Last site : %s\n", u->last_site); + } + newmail = mail_sizes(u->name, 1); + if (newmail) { + vwrite_user(user, "%s~RS has unread mail (%d).\n", u->recap, newmail); + } + write_user(user, + "+----- ~OL~FCProfile~RS --------------------------------------------------------------+\n\n"); + sprintf(filename, "%s/%s/%s.P", USERFILES, USERPROFILES, u->name); + fp = fopen(filename, "r"); + if (!fp) { + write_user(user, "User has not yet witten a profile.\n\n"); + } else { + fclose(fp); + more(user, user->socket, filename); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + done_retrieve(u); + return; + } + idle = (int) (time(0) - u->last_input) / 60; + if (u->malloc_start) { + vwrite_user(user, "Ignoring all: ~FCUsing Line Editor\n"); + } else { + vwrite_user(user, "Ignoring all: %s\n", noyes[u->ignall]); + } + strftime(text2, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", + localtime(&u->last_login)); + vwrite_user(user, + "On since : %s\nOn for : %d day%s, %d hour%s, %d minute%s\n", + text2, days2, PLTEXT_S(days2), hours2, PLTEXT_S(hours2), mins2, + PLTEXT_S(mins2)); + if (u->afk) { + vwrite_user(user, "Idle for : %d minute%s ~BR(AFK)\n", idle, + PLTEXT_S(idle)); + if (*u->afk_mesg) { + vwrite_user(user, "AFK message : %s\n", u->afk_mesg); + } + } else { + vwrite_user(user, "Idle for : %d minute%s\n", idle, PLTEXT_S(idle)); + } + vwrite_user(user, "Total login : %d day%s, %d hour%s, %d minute%s\n", days, + PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins)); + if (u->socket >= 0) { + if (user->level >= WIZ) { + vwrite_user(user, "Site : %-40.40s Port : %s\n", u->site, + u->site_port); + } +#ifdef NETLINKS + if (!u->room) { + vwrite_user(user, "Home service: %s\n", u->netlink->service); + } +#endif + } + newmail = mail_sizes(u->name, 1); + if (newmail) { + vwrite_user(user, "%s~RS has unread mail (%d).\n", u->recap, newmail); + } + write_user(user, + "+----- ~OL~FCProfile~RS --------------------------------------------------------------+\n\n"); + sprintf(filename, "%s/%s/%s.P", USERFILES, USERPROFILES, u->name); + fp = fopen(filename, "r"); + if (!fp) { + write_user(user, "User has not yet written a profile.\n\n"); + } else { + fclose(fp); + more(user, user->socket, filename); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); +} diff --git a/src/commands/expires.c b/src/commands/expires.c index 453edbf..ceba7b9 100644 --- a/src/commands/expires.c +++ b/src/commands/expires.c @@ -1,45 +1,45 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set a user to either expire after a set time, or never expire - */ -void -user_expires(UR_OBJECT user) -{ - UR_OBJECT u; - - if (word_count < 2) { - write_user(user, "Usage: expire \n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - /* process */ - if (!u->expire) { - u->expire = 1; - vwrite_user(user, - "You have set it so %s will expire when a purge is run.\n", - u->name); - sprintf(text, "%s enables expiration with purge.\n", user->name); - add_history(u->name, 0, "%s", text); - write_syslog(SYSLOG, 1, "%s enabled expiration on %s.\n", user->name, - u->name); - } else { - u->expire = 0; - vwrite_user(user, - "You have set it so %s will no longer expire when a purge is run.\n", - u->name); - sprintf(text, "%s disables expiration with purge.\n", user->name); - add_history(u->name, 0, "%s", text); - write_syslog(SYSLOG, 1, "%s disabled expiration on %s.\n", user->name, - u->name); - } - save_user_details(u, retrieve_user_type == 1); - done_retrieve(u); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set a user to either expire after a set time, or never expire + */ +void +user_expires(UR_OBJECT user) +{ + UR_OBJECT u; + + if (word_count < 2) { + write_user(user, "Usage: expire \n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + /* process */ + if (!u->expire) { + u->expire = 1; + vwrite_user(user, + "You have set it so %s will expire when a purge is run.\n", + u->name); + sprintf(text, "%s enables expiration with purge.\n", user->name); + add_history(u->name, 0, "%s", text); + write_syslog(SYSLOG, 1, "%s enabled expiration on %s.\n", user->name, + u->name); + } else { + u->expire = 0; + vwrite_user(user, + "You have set it so %s will no longer expire when a purge is run.\n", + u->name); + sprintf(text, "%s disables expiration with purge.\n", user->name); + add_history(u->name, 0, "%s", text); + write_syslog(SYSLOG, 1, "%s disabled expiration on %s.\n", user->name, + u->name); + } + save_user_details(u, retrieve_user_type == 1); + done_retrieve(u); +} diff --git a/src/commands/fix.c b/src/commands/fix.c index 9e64cbc..1108026 100644 --- a/src/commands/fix.c +++ b/src/commands/fix.c @@ -1,58 +1,58 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Change whether a rooms access is fixed or not - */ -void -change_room_fix(UR_OBJECT user, int fix) -{ - RM_OBJECT rm; - const char *name; - - if (word_count < 2) { - rm = user->room; - } else { - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - } - if (fix) { - if (is_fixed_room(rm)) { - if (rm == user->room) { - write_user(user, "This room's access is already fixed.\n"); - } else { - write_user(user, "That room's access is already fixed.\n"); - } - return; - } - } else { - if (!is_fixed_room(rm)) { - if (rm == user->room) { - write_user(user, "This room's access is already unfixed.\n"); - } else { - write_user(user, "That room's access is already unfixed.\n"); - } - return; - } - } - rm->access ^= FIXED; - reset_access(rm); - write_syslog(SYSLOG, 1, "%s %s access to room %s.\n", user->name, - is_fixed_room(rm) ? "FIXED" : "UNFIXED", rm->name); - name = user->vis ? user->recap : invisname; - if (user->room == rm) { - vwrite_room_except(rm, user, "%s~RS has %s~RS access for this room.\n", - name, is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); - } else { - vwrite_room(rm, "This room's access has been %s~RS.\n", - is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); - } - vwrite_user(user, "Access for room %s is now %s~RS.\n", rm->name, - is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Change whether a rooms access is fixed or not + */ +void +change_room_fix(UR_OBJECT user, int fix) +{ + RM_OBJECT rm; + const char *name; + + if (word_count < 2) { + rm = user->room; + } else { + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + } + if (fix) { + if (is_fixed_room(rm)) { + if (rm == user->room) { + write_user(user, "This room's access is already fixed.\n"); + } else { + write_user(user, "That room's access is already fixed.\n"); + } + return; + } + } else { + if (!is_fixed_room(rm)) { + if (rm == user->room) { + write_user(user, "This room's access is already unfixed.\n"); + } else { + write_user(user, "That room's access is already unfixed.\n"); + } + return; + } + } + rm->access ^= FIXED; + reset_access(rm); + write_syslog(SYSLOG, 1, "%s %s access to room %s.\n", user->name, + is_fixed_room(rm) ? "FIXED" : "UNFIXED", rm->name); + name = user->vis ? user->recap : invisname; + if (user->room == rm) { + vwrite_room_except(rm, user, "%s~RS has %s~RS access for this room.\n", + name, is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); + } else { + vwrite_room(rm, "This room's access has been %s~RS.\n", + is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); + } + vwrite_user(user, "Access for room %s is now %s~RS.\n", rm->name, + is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED"); +} diff --git a/src/commands/flagged.c b/src/commands/flagged.c index c297773..557b03c 100644 --- a/src/commands/flagged.c +++ b/src/commands/flagged.c @@ -1,49 +1,49 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * See if user is banned - */ -void -show_flagged_users(UR_OBJECT user) -{ - FU_OBJECT fu; - int count; - - if (!user->fu_first) { - write_user(user, "You do not have any flagged users.\n"); - return; - } - count = 0; - for (fu = user->fu_first; fu; fu = fu->next) { - *text = '\0'; - if (!count++) { - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCYour flagged user details are as follows~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } - if (fu->flags & fufROOMKEY) { - strcat(text, "my room key | "); - } else { - strcat(text, " | "); - } - if (fu->flags & fufFRIEND) { - strcat(text, "friend | "); - } else { - strcat(text, " | "); - } - if (fu->flags & fufIGNORE) { - strcat(text, "ignoring"); - } else { - strcat(text, " "); - } - vwrite_user(user, "| %-20s %53s |\n", fu->name, text); - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * See if user is banned + */ +void +show_flagged_users(UR_OBJECT user) +{ + FU_OBJECT fu; + int count; + + if (!user->fu_first) { + write_user(user, "You do not have any flagged users.\n"); + return; + } + count = 0; + for (fu = user->fu_first; fu; fu = fu->next) { + *text = '\0'; + if (!count++) { + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCYour flagged user details are as follows~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } + if (fu->flags & fufROOMKEY) { + strcat(text, "my room key | "); + } else { + strcat(text, " | "); + } + if (fu->flags & fufFRIEND) { + strcat(text, "friend | "); + } else { + strcat(text, " | "); + } + if (fu->flags & fufIGNORE) { + strcat(text, "ignoring"); + } else { + strcat(text, " "); + } + vwrite_user(user, "| %-20s %53s |\n", fu->name, text); + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); +} diff --git a/src/commands/fmail.c b/src/commands/fmail.c index ef45cbb..91b65c4 100644 --- a/src/commands/fmail.c +++ b/src/commands/fmail.c @@ -1,125 +1,125 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * allows a user to email specific messages to themselves - */ -void -forward_specific_mail(UR_OBJECT user) -{ - char w1[ARR_SIZE], line[ARR_SIZE], filenamei[80], filenameo[80], - subject[80], *s; - FILE *fpi, *fpo; - int valid, cnt, total, smail_number, tmp1, tmp2; - - if (word_count < 2) { - write_user(user, "Usage: fmail all|\n"); - return; - } - total = mail_sizes(user->name, 0); - if (!total) { - write_user(user, "You currently have no mail.\n"); - return; - } - if (!user->mail_verified) { - write_user(user, "You have not yet verified your email address.\n"); - return; - } - sprintf(subject, "Manual forwarding of smail (%s)", user->name); - /* send all smail */ - if (!strcasecmp(word[1], "all")) { - sprintf(filenameo, "%s/%s.FWD", MAILSPOOL, user->name); - fpo = fopen(filenameo, "w"); - if (!fpo) { - write_syslog(SYSLOG, 0, - "Unable to open forward mail file in forward_specific_mail()\n"); - write_user(user, "Sorry, could not forward any mail to you.\n"); - return; - } - sprintf(filenamei, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); - fpi = fopen(filenamei, "r"); - if (!fpi) { - write_user(user, "Sorry, could not forward any mail to you.\n"); - write_syslog(SYSLOG, 0, - "Unable to open %s's mailbox in forward_specific_mail()\n", - user->name); - fclose(fpo); - return; - } - fprintf(fpo, "From: %s\n", TALKER_NAME); - fprintf(fpo, "To: %s <%s>\n\n", user->name, user->email); - fscanf(fpi, "%d %d\r", &tmp1, &tmp2); - for (s = fgets(line, ARR_SIZE - 1, fpi); s; - s = fgets(line, ARR_SIZE - 1, fpi)) { - fprintf(fpo, "%s", colour_com_strip(s)); - } - fputs(talker_signature, fpo); - fclose(fpi); - fclose(fpo); - send_forward_email(user->email, filenameo, subject); - write_user(user, - "You have now sent ~OL~FRall~RS your smails to your email account.\n"); - return; - } - /* send just a specific smail */ - smail_number = atoi(word[1]); - if (!smail_number) { - write_user(user, "Usage: fmail all/\n"); - return; - } - if (smail_number > total) { - vwrite_user(user, "You only have %d message%s in your mailbox.\n", total, - PLTEXT_S(total)); - return; - } - sprintf(filenameo, "%s/%s.FWD", MAILSPOOL, user->name); - fpo = fopen(filenameo, "w"); - if (!fpo) { - write_syslog(SYSLOG, 0, - "Unable to open forward mail file in forward_specific_mail()\n"); - write_user(user, "Sorry, could not forward any mail to you.\n"); - return; - } - sprintf(filenamei, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); - fpi = fopen(filenamei, "r"); - if (!fpi) { - write_user(user, "Sorry, could not forward any mail to you.\n"); - write_syslog(SYSLOG, 0, - "Unable to open %s's mailbox in forward_specific_mail()\n", - user->name); - fclose(fpo); - return; - } - fprintf(fpo, "From: %s\n", TALKER_NAME); - fprintf(fpo, "To: %s <%s>\n\n", user->name, user->email); - valid = cnt = 1; - fscanf(fpi, "%d %d\r", &tmp1, &tmp2); - for (s = fgets(line, ARR_SIZE - 1, fpi); s; - s = fgets(line, ARR_SIZE - 1, fpi)) { - if (*s == '\n') { - valid = 1; - } - sscanf(s, "%s", w1); - if (valid && !strcmp(colour_com_strip(w1), "From:")) { - valid = 0; - if (smail_number == cnt++) { - break; - } - } - } - for (; s; s = fgets(line, ARR_SIZE - 1, fpi)) { - if (*s == '\n') { - break; - } - fprintf(fpo, "%s", colour_com_strip(s)); - } - fputs(talker_signature, fpo); - fclose(fpi); - fclose(fpo); - send_forward_email(user->email, filenameo, subject); - vwrite_user(user, - "You have now sent smail number ~FM~OL%d~RS to your email account.\n", - smail_number); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * allows a user to email specific messages to themselves + */ +void +forward_specific_mail(UR_OBJECT user) +{ + char w1[ARR_SIZE], line[ARR_SIZE], filenamei[80], filenameo[80], + subject[80], *s; + FILE *fpi, *fpo; + int valid, cnt, total, smail_number, tmp1, tmp2; + + if (word_count < 2) { + write_user(user, "Usage: fmail all|\n"); + return; + } + total = mail_sizes(user->name, 0); + if (!total) { + write_user(user, "You currently have no mail.\n"); + return; + } + if (!user->mail_verified) { + write_user(user, "You have not yet verified your email address.\n"); + return; + } + sprintf(subject, "Manual forwarding of smail (%s)", user->name); + /* send all smail */ + if (!strcasecmp(word[1], "all")) { + sprintf(filenameo, "%s/%s.FWD", MAILSPOOL, user->name); + fpo = fopen(filenameo, "w"); + if (!fpo) { + write_syslog(SYSLOG, 0, + "Unable to open forward mail file in forward_specific_mail()\n"); + write_user(user, "Sorry, could not forward any mail to you.\n"); + return; + } + sprintf(filenamei, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); + fpi = fopen(filenamei, "r"); + if (!fpi) { + write_user(user, "Sorry, could not forward any mail to you.\n"); + write_syslog(SYSLOG, 0, + "Unable to open %s's mailbox in forward_specific_mail()\n", + user->name); + fclose(fpo); + return; + } + fprintf(fpo, "From: %s\n", TALKER_NAME); + fprintf(fpo, "To: %s <%s>\n\n", user->name, user->email); + fscanf(fpi, "%d %d\r", &tmp1, &tmp2); + for (s = fgets(line, ARR_SIZE - 1, fpi); s; + s = fgets(line, ARR_SIZE - 1, fpi)) { + fprintf(fpo, "%s", colour_com_strip(s)); + } + fputs(talker_signature, fpo); + fclose(fpi); + fclose(fpo); + send_forward_email(user->email, filenameo, subject); + write_user(user, + "You have now sent ~OL~FRall~RS your smails to your email account.\n"); + return; + } + /* send just a specific smail */ + smail_number = atoi(word[1]); + if (!smail_number) { + write_user(user, "Usage: fmail all/\n"); + return; + } + if (smail_number > total) { + vwrite_user(user, "You only have %d message%s in your mailbox.\n", total, + PLTEXT_S(total)); + return; + } + sprintf(filenameo, "%s/%s.FWD", MAILSPOOL, user->name); + fpo = fopen(filenameo, "w"); + if (!fpo) { + write_syslog(SYSLOG, 0, + "Unable to open forward mail file in forward_specific_mail()\n"); + write_user(user, "Sorry, could not forward any mail to you.\n"); + return; + } + sprintf(filenamei, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); + fpi = fopen(filenamei, "r"); + if (!fpi) { + write_user(user, "Sorry, could not forward any mail to you.\n"); + write_syslog(SYSLOG, 0, + "Unable to open %s's mailbox in forward_specific_mail()\n", + user->name); + fclose(fpo); + return; + } + fprintf(fpo, "From: %s\n", TALKER_NAME); + fprintf(fpo, "To: %s <%s>\n\n", user->name, user->email); + valid = cnt = 1; + fscanf(fpi, "%d %d\r", &tmp1, &tmp2); + for (s = fgets(line, ARR_SIZE - 1, fpi); s; + s = fgets(line, ARR_SIZE - 1, fpi)) { + if (*s == '\n') { + valid = 1; + } + sscanf(s, "%s", w1); + if (valid && !strcmp(colour_com_strip(w1), "From:")) { + valid = 0; + if (smail_number == cnt++) { + break; + } + } + } + for (; s; s = fgets(line, ARR_SIZE - 1, fpi)) { + if (*s == '\n') { + break; + } + fprintf(fpo, "%s", colour_com_strip(s)); + } + fputs(talker_signature, fpo); + fclose(fpi); + fclose(fpo); + send_forward_email(user->email, filenameo, subject); + vwrite_user(user, + "You have now sent smail number ~FM~OL%d~RS to your email account.\n", + smail_number); +} diff --git a/src/commands/force.c b/src/commands/force.c index a2d6aca..db2c4fd 100644 --- a/src/commands/force.c +++ b/src/commands/force.c @@ -1,52 +1,52 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Force a user to do something - * adapted from Ogham: "Oh God Here's Another MUD" (c) Neil Robertson - */ -void -force(UR_OBJECT user, char *inpstr) -{ - UR_OBJECT u; - int w; - - if (word_count < 3) { - write_user(user, "Usage: force \n"); - return; - } - *word[1] = toupper(*word[1]); - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "There is an easier way to do something yourself.\n"); - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot force a user of the same or higher level as yourself.\n"); - return; - } - inpstr = remove_first(inpstr); - write_syslog(SYSLOG, 0, "%s FORCED %s to: \"%s\"\n", user->name, u->name, - inpstr); - /* shift words down to pass to exec_com */ - word_count -= 2; - for (w = 0; w < word_count; ++w) { - strcpy(word[w], word[w + 2]); - } - *word[w++] = '\0'; - *word[w++] = '\0'; - vwrite_user(u, "%s~RS forces you to: \"%s\"\n", user->recap, inpstr); - vwrite_user(user, "You force %s~RS to: \"%s\"\n", u->recap, inpstr); - if (!exec_com(u, inpstr, COUNT)) { - vwrite_user(user, "Unable to execute the command for %s~RS.\n", u->recap); - } - prompt(u); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Force a user to do something + * adapted from Ogham: "Oh God Here's Another MUD" (c) Neil Robertson + */ +void +force(UR_OBJECT user, char *inpstr) +{ + UR_OBJECT u; + int w; + + if (word_count < 3) { + write_user(user, "Usage: force \n"); + return; + } + *word[1] = toupper(*word[1]); + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "There is an easier way to do something yourself.\n"); + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot force a user of the same or higher level as yourself.\n"); + return; + } + inpstr = remove_first(inpstr); + write_syslog(SYSLOG, 0, "%s FORCED %s to: \"%s\"\n", user->name, u->name, + inpstr); + /* shift words down to pass to exec_com */ + word_count -= 2; + for (w = 0; w < word_count; ++w) { + strcpy(word[w], word[w + 2]); + } + *word[w++] = '\0'; + *word[w++] = '\0'; + vwrite_user(u, "%s~RS forces you to: \"%s\"\n", user->recap, inpstr); + vwrite_user(user, "You force %s~RS to: \"%s\"\n", u->recap, inpstr); + if (!exec_com(u, inpstr, COUNT)) { + vwrite_user(user, "Unable to execute the command for %s~RS.\n", u->recap); + } + prompt(u); +} diff --git a/src/commands/friend_emote.c b/src/commands/friend_emote.c index 5baa60a..8458879 100644 --- a/src/commands/friend_emote.c +++ b/src/commands/friend_emote.c @@ -1,52 +1,52 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Emote something to all the people on the suers friends list - */ -void -friend_emote(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: femote \n"; - const char *name; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot emote.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - /* check to see if use has friends listed */ - if (!count_friends(user)) { - write_user(user, "You have no friends listed.\n"); - return; - } - /* sort out swearing */ - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - name = user->vis ? user->recap : invisname; - sprintf(text, "~OL~FG>~RS [~FGFriend~RS] %s~RS%s%s\n", name, - *inpstr != '\'' ? " " : "", inpstr); - write_friends(user, text, 1); - record_tell(user, user, text); - write_user(user, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Emote something to all the people on the suers friends list + */ +void +friend_emote(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: femote \n"; + const char *name; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot emote.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + /* check to see if use has friends listed */ + if (!count_friends(user)) { + write_user(user, "You have no friends listed.\n"); + return; + } + /* sort out swearing */ + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + name = user->vis ? user->recap : invisname; + sprintf(text, "~OL~FG>~RS [~FGFriend~RS] %s~RS%s%s\n", name, + *inpstr != '\'' ? " " : "", inpstr); + write_friends(user, text, 1); + record_tell(user, user, text); + write_user(user, text); +} diff --git a/src/commands/friend_say.c b/src/commands/friend_say.c index 479c7e2..2f45a08 100644 --- a/src/commands/friend_say.c +++ b/src/commands/friend_say.c @@ -1,59 +1,59 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Say user speech to all people listed on users friends list - */ -void -friend_say(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: fsay \n"; - const char *type; - const char *name; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot speak.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - /* check to see if use has friends listed */ - if (!count_friends(user)) { - write_user(user, "You have no friends listed.\n"); - return; - } - /* sort our swearing */ - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - type = smiley_type(inpstr); - if (!type) { - type = "say"; - } - name = user->vis ? user->recap : invisname; - sprintf(text, "~OL~FG>~RS [~FGFriend~RS] %s~RS ~FG%ss~RS: %s\n", name, - type, inpstr); - write_friends(user, text, 1); - sprintf(text, "~OL~FG>~RS [~FGFriend~RS] You ~FG%s~RS: %s\n", type, - inpstr); - record_tell(user, user, text); - write_user(user, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Say user speech to all people listed on users friends list + */ +void +friend_say(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: fsay \n"; + const char *type; + const char *name; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot speak.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + /* check to see if use has friends listed */ + if (!count_friends(user)) { + write_user(user, "You have no friends listed.\n"); + return; + } + /* sort our swearing */ + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + type = smiley_type(inpstr); + if (!type) { + type = "say"; + } + name = user->vis ? user->recap : invisname; + sprintf(text, "~OL~FG>~RS [~FGFriend~RS] %s~RS ~FG%ss~RS: %s\n", name, + type, inpstr); + write_friends(user, text, 1); + sprintf(text, "~OL~FG>~RS [~FGFriend~RS] You ~FG%s~RS: %s\n", type, + inpstr); + record_tell(user, user, text); + write_user(user, text); +} diff --git a/src/commands/friends.c b/src/commands/friends.c index 7597371..ee283b7 100644 --- a/src/commands/friends.c +++ b/src/commands/friends.c @@ -1,100 +1,100 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * take a users name and add it to friends list - */ -void -friends(UR_OBJECT user) -{ - int found, cnt; - FU_OBJECT fu; - UR_OBJECT u; - char text2[ARR_SIZE]; - - found = cnt = 0; - *text2 = '\0'; - /* just display the friend details */ - if (word_count < 2) { - if (!count_friends(user)) { - write_user(user, "You have no names on your friends list.\n"); - return; - } - for (fu = user->fu_first; fu; fu = fu->next) { - if (fu->flags & fufFRIEND) { - if (!found++) { - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~FC~OLNames on your friends list are as follows~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } - switch (++cnt) { - case 1: - if (get_user(fu->name)) { - sprintf(text, "| %-25s ~FY~OLONLINE~RS ", fu->name); - } else { - sprintf(text, "| %-25s ", fu->name); - } - strcat(text2, text); - break; - default: - if (get_user(fu->name)) { - sprintf(text, " %-25s ~FY~OLONLINE~RS |\n", fu->name); - } else { - sprintf(text, " %-25s |\n", fu->name); - } - strcat(text2, text); - write_user(user, text2); - cnt = 0; - *text2 = '\0'; - break; - } - } - } - if (cnt == 1) { - strcat(text2, " |\n"); - write_user(user, text2); - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - if (!user->alert) { - write_user(user, - "| ~FCYou are currently not being alerted~RS |\n"); - } else { - write_user(user, - "| ~OL~FCYou are currently being alerted~RS |\n"); - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - return; - } - /* add or remove friends */ - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - if (user_is_friend(user, u)) { - if (!unsetbit_flagged_user_entry(user, u->name, fufFRIEND)) { - vwrite_user(user, - "Sorry, but %s could not be removed from your friends list at this time.\n", - u->name); - } else { - vwrite_user(user, "You have now removed %s from your friends list.\n", - u->name); - } - } else { - if (!setbit_flagged_user_entry(user, u->name, fufFRIEND)) { - vwrite_user(user, - "Sorry, but %s could not be added to your friends list at this time.\n", - u->name); - } else { - vwrite_user(user, "You have now added %s to your friends list.\n", - u->name); - } - } - done_retrieve(u); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * take a users name and add it to friends list + */ +void +friends(UR_OBJECT user) +{ + int found, cnt; + FU_OBJECT fu; + UR_OBJECT u; + char text2[ARR_SIZE]; + + found = cnt = 0; + *text2 = '\0'; + /* just display the friend details */ + if (word_count < 2) { + if (!count_friends(user)) { + write_user(user, "You have no names on your friends list.\n"); + return; + } + for (fu = user->fu_first; fu; fu = fu->next) { + if (fu->flags & fufFRIEND) { + if (!found++) { + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~FC~OLNames on your friends list are as follows~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } + switch (++cnt) { + case 1: + if (get_user(fu->name)) { + sprintf(text, "| %-25s ~FY~OLONLINE~RS ", fu->name); + } else { + sprintf(text, "| %-25s ", fu->name); + } + strcat(text2, text); + break; + default: + if (get_user(fu->name)) { + sprintf(text, " %-25s ~FY~OLONLINE~RS |\n", fu->name); + } else { + sprintf(text, " %-25s |\n", fu->name); + } + strcat(text2, text); + write_user(user, text2); + cnt = 0; + *text2 = '\0'; + break; + } + } + } + if (cnt == 1) { + strcat(text2, " |\n"); + write_user(user, text2); + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + if (!user->alert) { + write_user(user, + "| ~FCYou are currently not being alerted~RS |\n"); + } else { + write_user(user, + "| ~OL~FCYou are currently being alerted~RS |\n"); + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + return; + } + /* add or remove friends */ + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + if (user_is_friend(user, u)) { + if (!unsetbit_flagged_user_entry(user, u->name, fufFRIEND)) { + vwrite_user(user, + "Sorry, but %s could not be removed from your friends list at this time.\n", + u->name); + } else { + vwrite_user(user, "You have now removed %s from your friends list.\n", + u->name); + } + } else { + if (!setbit_flagged_user_entry(user, u->name, fufFRIEND)) { + vwrite_user(user, + "Sorry, but %s could not be added to your friends list at this time.\n", + u->name); + } else { + vwrite_user(user, "You have now added %s to your friends list.\n", + u->name); + } + } + done_retrieve(u); +} diff --git a/src/commands/fsmail.c b/src/commands/fsmail.c index b97811e..414681b 100644 --- a/src/commands/fsmail.c +++ b/src/commands/fsmail.c @@ -1,57 +1,57 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Send mail message to all people on your friends list - */ -void -friend_smail(UR_OBJECT user, char *inpstr) -{ - FU_OBJECT fu; - - if (inpstr) { - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot mail anyone.\n"); - return; - } - /* check to see if use has friends listed */ - if (!count_friends(user)) { - write_user(user, "You have no friends listed.\n"); - return; - } - if (word_count < 2) { - /* go to the editor to smail */ -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - write_user(user, - "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".fsmail \" method instead.\n"); - return; - } -#endif - write_user(user, - "\n~BB*** Writing mail message to all your friends ***\n\n"); - user->misc_op = 24; - editor(user, NULL); - } - /* do smail - no editor */ - strcat(inpstr, "\n"); - } else { - /* now do smail - out of editor */ - if (*user->malloc_end-- != '\n') { - *user->malloc_end-- = '\n'; - } - inpstr = user->malloc_start; - } - for (fu = user->fu_first; fu; fu = fu->next) { - if (fu->flags & fufFRIEND) { - send_mail(user, fu->name, inpstr, 2); - } - } - write_user(user, "Mail sent to all people on your friends list.\n"); - write_syslog(SYSLOG, 1, - "%s sent mail to all people on their friends list.\n", - user->name); +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Send mail message to all people on your friends list + */ +void +friend_smail(UR_OBJECT user, char *inpstr) +{ + FU_OBJECT fu; + + if (inpstr) { + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot mail anyone.\n"); + return; + } + /* check to see if use has friends listed */ + if (!count_friends(user)) { + write_user(user, "You have no friends listed.\n"); + return; + } + if (word_count < 2) { + /* go to the editor to smail */ +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + write_user(user, + "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".fsmail \" method instead.\n"); + return; + } +#endif + write_user(user, + "\n~BB*** Writing mail message to all your friends ***\n\n"); + user->misc_op = 24; + editor(user, NULL); + } + /* do smail - no editor */ + strcat(inpstr, "\n"); + } else { + /* now do smail - out of editor */ + if (*user->malloc_end-- != '\n') { + *user->malloc_end-- = '\n'; + } + inpstr = user->malloc_start; + } + for (fu = user->fu_first; fu; fu = fu->next) { + if (fu->flags & fufFRIEND) { + send_mail(user, fu->name, inpstr, 2); + } + } + write_user(user, "Mail sent to all people on your friends list.\n"); + write_syslog(SYSLOG, 1, + "%s sent mail to all people on their friends list.\n", + user->name); } \ No newline at end of file diff --git a/src/commands/gcom.c b/src/commands/gcom.c index ce0f761..04dcf6d 100644 --- a/src/commands/gcom.c +++ b/src/commands/gcom.c @@ -1,125 +1,125 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * stop a user from using a certain command - */ -void -user_gcom(UR_OBJECT user) -{ - CMD_OBJECT cmd; - UR_OBJECT u; - size_t i, x; - - if (word_count < 2) { - write_user(user, "Usage: gcom []\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "You cannot give yourself any commands.\n"); - return; - } - /* if no command is given, then just view given commands */ - if (word_count < 3) { - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, "~OL~FCGiven commands for user~RS \"%s~RS\"\n", - u->recap); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - x = 0; - for (i = 0; i < MAX_GCOMS; ++i) { - if (u->gcoms[i] == -1) { - continue; - } - for (cmd = first_command; cmd; cmd = cmd->next) { - if (cmd->id == u->gcoms[i]) { - break; - } - } - if (!cmd) { - /* XXX: Maybe emit some sort of error? */ - continue; - } - vwrite_user(user, "~OL%s~RS (level %d)\n", cmd->name, cmd->level); - ++x; - } - if (!x) { - write_user(user, "User has no given commands.\n"); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot give commands to a user with the same or higher level as yourself.\n"); - return; - } - /* FIXME: command search order is different than command_table/exec_com() - * because it uses the alpha sorted command list instead! */ - i = strlen(word[2]); - for (cmd = first_command; cmd; cmd = cmd->next) { - if (!strncmp(word[2], cmd->name, i)) { - break; - } - } - if (!cmd) { - write_user(user, "That command does not exist.\n"); - return; - } - if (u->level >= cmd->level) { - vwrite_user(user, "%s can already use that command.\n", u->name); - return; - } - if (user->level < cmd->level) { - write_user(user, - "You cannot use that command, so you cannot give it to others.\n"); - return; - } - /* check to see if the user has previously been banned from using the command */ - if (has_xcom(u, cmd->id)) { - write_user(user, - "You cannot give a command to a user that already has it banned.\n"); - return; - } - if (has_gcom(u, cmd->id)) { - /* user already has the command given, so ungive it */ - if (!set_xgcom(user, u, cmd->id, 0, 0)) { - /* XXX: Maybe emit some sort of error? */ - return; - } - vwrite_user(user, "You have removed the given command \"%s\" for %s~RS\n", - word[2], u->recap); - vwrite_user(u, - "Access to the given command \"%s\" has now been taken away from you.\n", - word[2]); - sprintf(text, "%s ~FRUNGCOM~RS'd the command \"%s\"\n", user->name, - word[2]); - add_history(u->name, 1, "%s", text); - write_syslog(SYSLOG, 1, "%s UNGCOM'd the command \"%s\" for %s\n", - user->name, word[2], u->name); - } else { - /* user does not have the command given, so give it */ - if (!set_xgcom(user, u, cmd->id, 0, 1)) { - /* XXX: Maybe emit some sort of error? */ - return; - } - vwrite_user(user, "You have given the \"%s\" command for %s\n", word[2], - u->name); - vwrite_user(u, "You have been given access to the command \"%s\".\n", - word[2]); - sprintf(text, "%s ~FGGCOM~RS'd the command \"%s\"\n", user->name, - word[2]); - add_history(u->name, 1, "%s", text); - write_syslog(SYSLOG, 1, "%s GCOM'd the command \"%s\" for %s\n", - user->name, word[2], u->name); - } -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * stop a user from using a certain command + */ +void +user_gcom(UR_OBJECT user) +{ + CMD_OBJECT cmd; + UR_OBJECT u; + size_t i, x; + + if (word_count < 2) { + write_user(user, "Usage: gcom []\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "You cannot give yourself any commands.\n"); + return; + } + /* if no command is given, then just view given commands */ + if (word_count < 3) { + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, "~OL~FCGiven commands for user~RS \"%s~RS\"\n", + u->recap); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + x = 0; + for (i = 0; i < MAX_GCOMS; ++i) { + if (u->gcoms[i] == -1) { + continue; + } + for (cmd = first_command; cmd; cmd = cmd->next) { + if (cmd->id == u->gcoms[i]) { + break; + } + } + if (!cmd) { + /* XXX: Maybe emit some sort of error? */ + continue; + } + vwrite_user(user, "~OL%s~RS (level %d)\n", cmd->name, cmd->level); + ++x; + } + if (!x) { + write_user(user, "User has no given commands.\n"); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot give commands to a user with the same or higher level as yourself.\n"); + return; + } + /* FIXME: command search order is different than command_table/exec_com() + * because it uses the alpha sorted command list instead! */ + i = strlen(word[2]); + for (cmd = first_command; cmd; cmd = cmd->next) { + if (!strncmp(word[2], cmd->name, i)) { + break; + } + } + if (!cmd) { + write_user(user, "That command does not exist.\n"); + return; + } + if (u->level >= cmd->level) { + vwrite_user(user, "%s can already use that command.\n", u->name); + return; + } + if (user->level < cmd->level) { + write_user(user, + "You cannot use that command, so you cannot give it to others.\n"); + return; + } + /* check to see if the user has previously been banned from using the command */ + if (has_xcom(u, cmd->id)) { + write_user(user, + "You cannot give a command to a user that already has it banned.\n"); + return; + } + if (has_gcom(u, cmd->id)) { + /* user already has the command given, so ungive it */ + if (!set_xgcom(user, u, cmd->id, 0, 0)) { + /* XXX: Maybe emit some sort of error? */ + return; + } + vwrite_user(user, "You have removed the given command \"%s\" for %s~RS\n", + word[2], u->recap); + vwrite_user(u, + "Access to the given command \"%s\" has now been taken away from you.\n", + word[2]); + sprintf(text, "%s ~FRUNGCOM~RS'd the command \"%s\"\n", user->name, + word[2]); + add_history(u->name, 1, "%s", text); + write_syslog(SYSLOG, 1, "%s UNGCOM'd the command \"%s\" for %s\n", + user->name, word[2], u->name); + } else { + /* user does not have the command given, so give it */ + if (!set_xgcom(user, u, cmd->id, 0, 1)) { + /* XXX: Maybe emit some sort of error? */ + return; + } + vwrite_user(user, "You have given the \"%s\" command for %s\n", word[2], + u->name); + vwrite_user(u, "You have been given access to the command \"%s\".\n", + word[2]); + sprintf(text, "%s ~FGGCOM~RS'd the command \"%s\"\n", user->name, + word[2]); + add_history(u->name, 1, "%s", text); + write_syslog(SYSLOG, 1, "%s GCOM'd the command \"%s\" for %s\n", + user->name, word[2], u->name); + } +} diff --git a/src/commands/go.c b/src/commands/go.c index f7dc19d..e5091d7 100644 --- a/src/commands/go.c +++ b/src/commands/go.c @@ -1,68 +1,68 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Move to another room - */ -void -go(UR_OBJECT user) -{ - RM_OBJECT rm; - int i; - - if (user->lroom == 2) { - write_user(user, "You have been shackled and cannot move.\n"); - return; - } - if (word_count < 2) { - rm = get_room_full(amsys->default_warp); - if (!rm) { - write_user(user, "You cannot warp to the main room at this time.\n"); - return; - } - if (user->room == rm) { - vwrite_user(user, "You are already in the %s!\n", rm->name); - return; - } - move_user(user, rm, 1); - return; - } -#ifdef NETLINKS - release_nl(user); - if (transfer_nl(user)) { - return; - } -#endif - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - if (rm == user->room) { - vwrite_user(user, "You are already in the %s!\n", rm->name); - return; - } - /* See if link from current room */ - for (i = 0; i < MAX_LINKS; ++i) { - if (user->room->link[i] == rm) { - break; - } - } - if (i < MAX_LINKS) { - move_user(user, rm, 0); - return; - } - if (is_personal_room(rm)) { - write_user(user, - "To go to another user's home you must \".visit\" them.\n"); - return; - } - if (user->level < WIZ) { - vwrite_user(user, "The %s is not adjoined to here.\n", rm->name); - return; - } - move_user(user, rm, 1); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Move to another room + */ +void +go(UR_OBJECT user) +{ + RM_OBJECT rm; + int i; + + if (user->lroom == 2) { + write_user(user, "You have been shackled and cannot move.\n"); + return; + } + if (word_count < 2) { + rm = get_room_full(amsys->default_warp); + if (!rm) { + write_user(user, "You cannot warp to the main room at this time.\n"); + return; + } + if (user->room == rm) { + vwrite_user(user, "You are already in the %s!\n", rm->name); + return; + } + move_user(user, rm, 1); + return; + } +#ifdef NETLINKS + release_nl(user); + if (transfer_nl(user)) { + return; + } +#endif + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + if (rm == user->room) { + vwrite_user(user, "You are already in the %s!\n", rm->name); + return; + } + /* See if link from current room */ + for (i = 0; i < MAX_LINKS; ++i) { + if (user->room->link[i] == rm) { + break; + } + } + if (i < MAX_LINKS) { + move_user(user, rm, 0); + return; + } + if (is_personal_room(rm)) { + write_user(user, + "To go to another user's home you must \".visit\" them.\n"); + return; + } + if (user->level < WIZ) { + vwrite_user(user, "The %s is not adjoined to here.\n", rm->name); + return; + } + move_user(user, rm, 1); +} diff --git a/src/commands/greet.c b/src/commands/greet.c index f0c3d0a..682405e 100644 --- a/src/commands/greet.c +++ b/src/commands/greet.c @@ -1,440 +1,440 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * print out greeting in large letters - */ -void -greet(UR_OBJECT user, char *inpstr) -{ - static const int biglet[26][5][5] = { - { - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}}, - { - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}}, - { - {0, 1, 1, 1, 1}, - {1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0}, - {0, 1, 1, 1, 1}}, - { - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}}, - { - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 0}, - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}}, - { - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 0}, - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0}}, - { - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 0}, - {1, 0, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}}, - { - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}}, - { - {0, 1, 1, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 1, 1, 0}}, - { - {0, 0, 0, 0, 1}, - {0, 0, 0, 0, 1}, - {0, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}}, - { - {1, 0, 0, 0, 1}, - {1, 0, 0, 1, 0}, - {1, 0, 1, 0, 0}, - {1, 0, 0, 1, 0}, - {1, 0, 0, 0, 1}}, - { - {1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}}, - { - {1, 0, 0, 0, 1}, - {1, 1, 0, 1, 1}, - {1, 0, 1, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}}, - { - {1, 0, 0, 0, 1}, - {1, 1, 0, 0, 1}, - {1, 0, 1, 0, 1}, - {1, 0, 0, 1, 1}, - {1, 0, 0, 0, 1}}, - { - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}}, - { - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 0}, - {1, 0, 0, 0, 0}}, - { - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 0, 1, 0, 1}, - {1, 0, 0, 1, 1}, - {0, 1, 1, 1, 0}}, - { - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}, - {1, 0, 0, 1, 0}, - {1, 0, 0, 0, 1}}, - { - {0, 1, 1, 1, 1}, - {1, 0, 0, 0, 0}, - {0, 1, 1, 1, 0}, - {0, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}}, - { - {1, 1, 1, 1, 1}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}}, - { - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 1}}, - { - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {0, 1, 0, 1, 0}, - {0, 1, 0, 1, 0}, - {0, 0, 1, 0, 0}}, - { - {1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 1, 0, 1}, - {1, 1, 0, 1, 1}, - {1, 0, 0, 0, 1}}, - { - {1, 0, 0, 0, 1}, - {0, 1, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 1, 0}, - {1, 0, 0, 0, 1}}, - { - {1, 0, 0, 0, 1}, - {0, 1, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}}, - { - {1, 1, 1, 1, 1}, - {0, 0, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 0, 0}, - {1, 1, 1, 1, 1}} - }; - static const int bigsym[32][5][5] = { - { - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0}}, - { - {0, 1, 0, 1, 0}, - {0, 1, 0, 1, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}}, - { - {0, 1, 0, 1, 0}, - {1, 1, 1, 1, 1}, - {0, 1, 0, 1, 0}, - {1, 1, 1, 1, 1}, - {0, 1, 0, 1, 0}}, - { - {0, 1, 1, 1, 1}, - {1, 0, 1, 0, 0}, - {0, 1, 1, 1, 0}, - {0, 0, 1, 0, 1}, - {1, 1, 1, 1, 0}}, - { - {1, 1, 0, 0, 1}, - {1, 1, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 1, 1}, - {1, 0, 0, 1, 1}}, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}}, - { - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}}, - { - {0, 0, 1, 1, 0}, - {0, 1, 0, 0, 0}, - {0, 1, 0, 0, 0}, - {0, 1, 0, 0, 0}, - {0, 0, 1, 1, 0}}, - { - {0, 1, 1, 0, 0}, - {0, 0, 0, 1, 0}, - {0, 0, 0, 1, 0}, - {0, 0, 0, 1, 0}, - {0, 1, 1, 0, 0}}, - { - {1, 0, 1, 0, 1}, - {0, 1, 1, 1, 0}, - {1, 1, 1, 1, 1}, - {0, 1, 1, 1, 0}, - {1, 0, 1, 0, 1}}, - { - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {1, 1, 1, 1, 1}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}}, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 1, 0, 0, 0}, - {1, 1, 0, 0, 0}}, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}}, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {1, 1, 0, 0, 0}, - {1, 1, 0, 0, 0}}, - { - {0, 0, 0, 0, 1}, - {0, 0, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 0, 0}, - {1, 0, 0, 0, 0}}, - { - {0, 1, 1, 1, 0}, - {1, 0, 0, 1, 1}, - {1, 0, 1, 0, 1}, - {1, 1, 0, 0, 1}, - {0, 1, 1, 1, 0}}, - { - {0, 0, 1, 0, 0}, - {0, 1, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 1, 1, 0}}, - { - {1, 1, 1, 1, 0}, - {0, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}}, - { - {1, 1, 1, 1, 0}, - {0, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}, - {0, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}}, - { - {0, 0, 1, 1, 0}, - {0, 1, 0, 0, 0}, - {1, 0, 0, 1, 0}, - {1, 1, 1, 1, 1}, - {0, 0, 0, 1, 0}}, - { - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 0}, - {1, 1, 1, 1, 0}, - {0, 0, 0, 0, 1}, - {1, 1, 1, 1, 0}}, - { - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 0}, - {1, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}}, - { - {1, 1, 1, 1, 1}, - {0, 0, 0, 0, 1}, - {0, 0, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 0, 0}}, - { - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}, - {1, 0, 0, 0, 1}, - {0, 1, 1, 1, 0}}, - { - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 1}, - {0, 0, 0, 0, 1}, - {0, 0, 0, 0, 1}}, - { - {0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0}}, - { - {0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 0, 0}}, - { - {0, 0, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 0, 1, 0}}, - { - {0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0}}, - { - {0, 1, 0, 0, 0}, - {0, 0, 1, 0, 0}, - {0, 0, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 0, 0}}, - { - {0, 1, 1, 1, 1}, - {0, 0, 0, 0, 1}, - {0, 0, 1, 1, 1}, - {0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0}}, - { - {0, 1, 0, 0, 0}, - {1, 0, 1, 1, 1}, - {1, 0, 1, 0, 1}, - {1, 0, 1, 1, 1}, - {0, 1, 1, 1, 0}} - }; - static const char usage[] = "Usage: greet \n"; - static const char *const clr[] ={"~OL~FR", "~OL~FY", "~OL~FG", "~OL~FC", "~OL~FB", "~OL~FM"}; - char pbuff[ARR_SIZE], temp[8]; - int slen, lc, c, i, j; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot greet.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_private_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - slen = strlen(inpstr); - if (slen > 11) { - write_user(user, "You can only have up to 11 letters in the greet.\n"); - return; - } - write_monitor(user, user->room, 0); - write_room(user->room, "\n"); - for (i = 0; i < 5; ++i) { - *pbuff = '\0'; - *temp = '\0'; - for (c = 0; c < slen; ++c) { - /* check to see if it is a character a-z */ - if (isalpha(inpstr[c])) { - lc = tolower(inpstr[c]) - 'a'; - if (lc >= 0 && lc < 26) { - for (j = 0; j < 5; ++j) { - if (biglet[lc][i][j]) { - sprintf(temp, "%s#", clr[rand() % SIZEOF(clr)]); - strcat(pbuff, temp); - } else { - strcat(pbuff, " "); - } - } - strcat(pbuff, " "); - } - } - /* check if it is a character from ! to @ */ - if (ispunct(inpstr[c]) || isdigit(inpstr[c])) { - lc = inpstr[c] - '!'; - if (lc >= 0 && lc < 32) { - for (j = 0; j < 5; ++j) { - if (bigsym[lc][i][j]) { - sprintf(temp, "%s#", clr[rand() % SIZEOF(clr)]); - strcat(pbuff, temp); - } else { - strcat(pbuff, " "); - } - } - strcat(pbuff, " "); - } - } - } - vwrite_room(user->room, "%s\n", pbuff); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * print out greeting in large letters + */ +void +greet(UR_OBJECT user, char *inpstr) +{ + static const int biglet[26][5][5] = { + { + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}}, + { + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}}, + { + {0, 1, 1, 1, 1}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {0, 1, 1, 1, 1}}, + { + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}}, + { + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}}, + { + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}}, + { + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}}, + { + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}}, + { + {0, 1, 1, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 1, 1, 0}}, + { + {0, 0, 0, 0, 1}, + {0, 0, 0, 0, 1}, + {0, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}}, + { + {1, 0, 0, 0, 1}, + {1, 0, 0, 1, 0}, + {1, 0, 1, 0, 0}, + {1, 0, 0, 1, 0}, + {1, 0, 0, 0, 1}}, + { + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}}, + { + {1, 0, 0, 0, 1}, + {1, 1, 0, 1, 1}, + {1, 0, 1, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}}, + { + {1, 0, 0, 0, 1}, + {1, 1, 0, 0, 1}, + {1, 0, 1, 0, 1}, + {1, 0, 0, 1, 1}, + {1, 0, 0, 0, 1}}, + { + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}}, + { + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}}, + { + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 0, 1, 0, 1}, + {1, 0, 0, 1, 1}, + {0, 1, 1, 1, 0}}, + { + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}, + {1, 0, 0, 1, 0}, + {1, 0, 0, 0, 1}}, + { + {0, 1, 1, 1, 1}, + {1, 0, 0, 0, 0}, + {0, 1, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}}, + { + {1, 1, 1, 1, 1}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}}, + { + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}}, + { + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {0, 1, 0, 1, 0}, + {0, 1, 0, 1, 0}, + {0, 0, 1, 0, 0}}, + { + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 1, 0, 1}, + {1, 1, 0, 1, 1}, + {1, 0, 0, 0, 1}}, + { + {1, 0, 0, 0, 1}, + {0, 1, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 1, 0}, + {1, 0, 0, 0, 1}}, + { + {1, 0, 0, 0, 1}, + {0, 1, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}}, + { + {1, 1, 1, 1, 1}, + {0, 0, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 0, 0}, + {1, 1, 1, 1, 1}} + }; + static const int bigsym[32][5][5] = { + { + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0}}, + { + {0, 1, 0, 1, 0}, + {0, 1, 0, 1, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}}, + { + {0, 1, 0, 1, 0}, + {1, 1, 1, 1, 1}, + {0, 1, 0, 1, 0}, + {1, 1, 1, 1, 1}, + {0, 1, 0, 1, 0}}, + { + {0, 1, 1, 1, 1}, + {1, 0, 1, 0, 0}, + {0, 1, 1, 1, 0}, + {0, 0, 1, 0, 1}, + {1, 1, 1, 1, 0}}, + { + {1, 1, 0, 0, 1}, + {1, 1, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 1, 1}, + {1, 0, 0, 1, 1}}, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}}, + { + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}}, + { + {0, 0, 1, 1, 0}, + {0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0}, + {0, 0, 1, 1, 0}}, + { + {0, 1, 1, 0, 0}, + {0, 0, 0, 1, 0}, + {0, 0, 0, 1, 0}, + {0, 0, 0, 1, 0}, + {0, 1, 1, 0, 0}}, + { + {1, 0, 1, 0, 1}, + {0, 1, 1, 1, 0}, + {1, 1, 1, 1, 1}, + {0, 1, 1, 1, 0}, + {1, 0, 1, 0, 1}}, + { + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {1, 1, 1, 1, 1}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}}, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0}, + {1, 1, 0, 0, 0}}, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}}, + { + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {1, 1, 0, 0, 0}, + {1, 1, 0, 0, 0}}, + { + {0, 0, 0, 0, 1}, + {0, 0, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 0, 0}, + {1, 0, 0, 0, 0}}, + { + {0, 1, 1, 1, 0}, + {1, 0, 0, 1, 1}, + {1, 0, 1, 0, 1}, + {1, 1, 0, 0, 1}, + {0, 1, 1, 1, 0}}, + { + {0, 0, 1, 0, 0}, + {0, 1, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 1, 1, 0}}, + { + {1, 1, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}}, + { + {1, 1, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}}, + { + {0, 0, 1, 1, 0}, + {0, 1, 0, 0, 0}, + {1, 0, 0, 1, 0}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 1, 0}}, + { + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {1, 1, 1, 1, 0}}, + { + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}}, + { + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 1}, + {0, 0, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 0, 0}}, + { + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}, + {1, 0, 0, 0, 1}, + {0, 1, 1, 1, 0}}, + { + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 1}, + {0, 0, 0, 0, 1}}, + { + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0}}, + { + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 0, 0}}, + { + {0, 0, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 0, 1, 0}}, + { + {0, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}}, + { + {0, 1, 0, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 0, 0, 1, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 0, 0}}, + { + {0, 1, 1, 1, 1}, + {0, 0, 0, 0, 1}, + {0, 0, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0}}, + { + {0, 1, 0, 0, 0}, + {1, 0, 1, 1, 1}, + {1, 0, 1, 0, 1}, + {1, 0, 1, 1, 1}, + {0, 1, 1, 1, 0}} + }; + static const char usage[] = "Usage: greet \n"; + static const char *const clr[] ={"~OL~FR", "~OL~FY", "~OL~FG", "~OL~FC", "~OL~FB", "~OL~FM"}; + char pbuff[ARR_SIZE], temp[8]; + int slen, lc, c, i, j; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot greet.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_private_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + slen = strlen(inpstr); + if (slen > 11) { + write_user(user, "You can only have up to 11 letters in the greet.\n"); + return; + } + write_monitor(user, user->room, 0); + write_room(user->room, "\n"); + for (i = 0; i < 5; ++i) { + *pbuff = '\0'; + *temp = '\0'; + for (c = 0; c < slen; ++c) { + /* check to see if it is a character a-z */ + if (isalpha(inpstr[c])) { + lc = tolower(inpstr[c]) - 'a'; + if (lc >= 0 && lc < 26) { + for (j = 0; j < 5; ++j) { + if (biglet[lc][i][j]) { + sprintf(temp, "%s#", clr[rand() % SIZEOF(clr)]); + strcat(pbuff, temp); + } else { + strcat(pbuff, " "); + } + } + strcat(pbuff, " "); + } + } + /* check if it is a character from ! to @ */ + if (ispunct(inpstr[c]) || isdigit(inpstr[c])) { + lc = inpstr[c] - '!'; + if (lc >= 0 && lc < 32) { + for (j = 0; j < 5; ++j) { + if (bigsym[lc][i][j]) { + sprintf(temp, "%s#", clr[rand() % SIZEOF(clr)]); + strcat(pbuff, temp); + } else { + strcat(pbuff, " "); + } + } + strcat(pbuff, " "); + } + } + } + vwrite_room(user->room, "%s\n", pbuff); + } +} diff --git a/src/commands/grepusers.c b/src/commands/grepusers.c index 37094a0..37e0bc7 100644 --- a/src/commands/grepusers.c +++ b/src/commands/grepusers.c @@ -1,84 +1,84 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * This command allows you to do a search for any user names that match - * a particular pattern - */ -void -grep_users(UR_OBJECT user) -{ - int found, x; - char name[USER_NAME_LEN + 1], pat[ARR_SIZE]; - UD_OBJECT entry; - - if (word_count < 2) { - write_user(user, "Usage: grepu \n"); - return; - } - if (strstr(word[1], "**")) { - write_user(user, "You cannot have ** in your pattern.\n"); - return; - } - if (strstr(word[1], "?*")) { - write_user(user, "You cannot have ?* in your pattern.\n"); - return; - } - if (strstr(word[1], "*?")) { - write_user(user, "You cannot have *? in your pattern.\n"); - return; - } - start_pager(user); - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - sprintf(text, "| ~FC~OLUser grep for pattern:~RS ~OL%-51s~RS |\n", word[1]); - write_user(user, text); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - x = 0; - found = 0; - *pat = '\0'; - strcpy(pat, word[1]); - strtolower(pat); - for (entry = first_user_entry; entry; entry = entry->next) { - strcpy(name, entry->name); - *name = tolower(*name); - if (pattern_match(name, pat)) { - if (!x) { - vwrite_user(user, "| %-*s ~FC%-20s~RS ", USER_NAME_LEN, - entry->name, user_level[entry->level].name); - } else { - vwrite_user(user, " %-*s ~FC%-20s~RS |\n", USER_NAME_LEN, - entry->name, user_level[entry->level].name); - } - x = !x; - ++found; - } - } - if (x) { - write_user(user, " |\n"); - } - if (!found) { - write_user(user, - "| |\n"); - write_user(user, - "| ~OL~FRNo users have that pattern~RS |\n"); - write_user(user, - "| |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - stop_pager(user); - return; - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - align_string(0, 78, 1, "|", - " ~OL%d~RS user%s had the pattern ~OL%s~RS ", - found, PLTEXT_S(found), word[1])); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - stop_pager(user); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * This command allows you to do a search for any user names that match + * a particular pattern + */ +void +grep_users(UR_OBJECT user) +{ + int found, x; + char name[USER_NAME_LEN + 1], pat[ARR_SIZE]; + UD_OBJECT entry; + + if (word_count < 2) { + write_user(user, "Usage: grepu \n"); + return; + } + if (strstr(word[1], "**")) { + write_user(user, "You cannot have ** in your pattern.\n"); + return; + } + if (strstr(word[1], "?*")) { + write_user(user, "You cannot have ?* in your pattern.\n"); + return; + } + if (strstr(word[1], "*?")) { + write_user(user, "You cannot have *? in your pattern.\n"); + return; + } + start_pager(user); + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + sprintf(text, "| ~FC~OLUser grep for pattern:~RS ~OL%-51s~RS |\n", word[1]); + write_user(user, text); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + x = 0; + found = 0; + *pat = '\0'; + strcpy(pat, word[1]); + strtolower(pat); + for (entry = first_user_entry; entry; entry = entry->next) { + strcpy(name, entry->name); + *name = tolower(*name); + if (pattern_match(name, pat)) { + if (!x) { + vwrite_user(user, "| %-*s ~FC%-20s~RS ", USER_NAME_LEN, + entry->name, user_level[entry->level].name); + } else { + vwrite_user(user, " %-*s ~FC%-20s~RS |\n", USER_NAME_LEN, + entry->name, user_level[entry->level].name); + } + x = !x; + ++found; + } + } + if (x) { + write_user(user, " |\n"); + } + if (!found) { + write_user(user, + "| |\n"); + write_user(user, + "| ~OL~FRNo users have that pattern~RS |\n"); + write_user(user, + "| |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + stop_pager(user); + return; + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + align_string(ALIGN_LEFT, 78, 1, "|", + " ~OL%d~RS user%s had the pattern ~OL%s~RS ", + found, PLTEXT_S(found), word[1])); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + stop_pager(user); +} diff --git a/src/commands/help.c b/src/commands/help.c index 54b4b8f..2050f07 100644 --- a/src/commands/help.c +++ b/src/commands/help.c @@ -1,135 +1,378 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show the list of commands, credits, and display the helpfiles for the given command - */ -void -help(UR_OBJECT user) -{ - char filename[80]; - const struct cmd_entry *com, *c; - size_t len; - int found; - - if (word_count < 2 || !strcasecmp(word[1], "commands")) { - switch (user->cmd_type) { - case 0: - help_commands_level(user); - break; - case 1: - help_commands_function(user); - break; - } - return; - } - if (!strcasecmp(word[1], "credits")) { - help_amnuts_credits(user); - return; - } - if (!strcasecmp(word[1], "nuts")) { - help_nuts_credits(user); - return; - } - len = strlen(word[1]); - com = NULL; - found = 0; - *text = '\0'; - for (c = command_table; c->name; ++c) { - if (!strncasecmp(c->name, word[1], len)) { - if (strlen(c->name) == len) { - break; - } - /* FIXME: take into account xgcoms, command list dynamic level, etc. */ - if (user->level < (enum lvl_value) c->level) { - continue; - } - strcat(text, found++ % 8 ? " " : "\n ~OL"); - strcat(text, c->name); - com = c; - } - } - if (c->name) { - found = 1; - com = c; - } - if (found > 1) { - strcat(text, found % 8 ? "\n\n" : "\n"); - vwrite_user(user, - "~FR~OLCommand name is not unique. \"~FC%s~RS~OL~FR\" also matches:\n\n", - word[1]); - write_user(user, text); - *text = '\0'; - return; - } - *text = '\0'; - if (!found) { - write_user(user, "Sorry, there is no help on that topic.\n"); - return; - } - if (word_count < 3) { - sprintf(filename, "%s/%s", HELPFILES, com->name); - } else { - if (com == command_table + SET) { - const struct set_entry *attr, *a; - - len = strlen(word[2]); - attr = NULL; - found = 0; - *text = '\0'; - for (a = setstr; a->type; ++a) { - if (!strncasecmp(a->type, word[2], len)) { - if (strlen(a->type) == len) { - break; - } - strcat(text, found++ % 8 ? " " : "\n ~OL"); - strcat(text, a->type); - attr = a; - } - } - if (a->type) { - found = 1; - attr = a; - } - if (found > 1) { - strcat(text, found % 8 ? "\n\n" : "\n"); - vwrite_user(user, - "~FR~OLAttribute name is not unique. \"~FT%s~RS~OL~FR\" also matches:\n", - word[2]); - write_user(user, text); - *text = '\0'; - return; - } - *text = '\0'; - if (!found) { - write_user(user, "Sorry, there is no help on that topic.\n"); - return; - } - if (word_count < 4) { - sprintf(filename, "%s/%s_%s", HELPFILES, com->name, attr->type); - } else { - sprintf(filename, "%s/%s", HELPFILES, com->name); - } - } else { - com = command_table + HELP; - sprintf(filename, "%s/%s", HELPFILES, com->name); - } - } - switch (more(user, user->socket, filename)) { - case 0: - write_user(user, "Sorry, there is no help on that topic.\n"); - break; - case 1: - user->misc_op = 2; - break; - case 2: - /* FIXME: take into account xgcoms, command list dynamic level, etc. */ - vwrite_user(user, "~OLLevel :~RS %s and above\n", - user_level[com->level].name); - break; - } -} - + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show the list of commands, credits, and display the help files for the given command + */ +void +help(UR_OBJECT user) +{ + char filename[80]; + const struct cmd_entry *com, *c; + size_t len; + int found; + + if (word_count < 2 || !strcasecmp(word[1], "commands")) { + switch (user->cmd_type) { + case 0: + help_commands_level(user); + break; + case 1: + help_commands_function(user); + break; + } + return; + } + if (!strcasecmp(word[1], "credits")) { + help_amnuts_credits(user); + return; + } + if (!strcasecmp(word[1], "nuts")) { + help_nuts_credits(user); + return; + } + len = strlen(word[1]); + com = NULL; + found = 0; + *text = '\0'; + for (c = command_table; c->name; ++c) { + if (!strncasecmp(c->name, word[1], len)) { + if (strlen(c->name) == len) { + break; + } + /* FIXME: take into account xgcoms, command list dynamic level, etc. */ + if (user->level < (enum lvl_value) c->level) { + continue; + } + strcat(text, found++ % 8 ? " " : "\n ~OL"); + strcat(text, c->name); + com = c; + } + } + if (c->name) { + found = 1; + com = c; + } + if (found > 1) { + strcat(text, found % 8 ? "\n\n" : "\n"); + vwrite_user(user, + "~FR~OLCommand name is not unique. \"~FC%s~RS~OL~FR\" also matches:\n\n", + word[1]); + write_user(user, text); + *text = '\0'; + return; + } + *text = '\0'; + if (!found) { + write_user(user, "Sorry, there is no help on that topic.\n"); + return; + } + if (word_count < 3) { + sprintf(filename, "%s/%s", HELPFILES, com->name); + } else { + if (com == command_table + SET) { + const struct set_entry *attr, *a; + + len = strlen(word[2]); + attr = NULL; + found = 0; + *text = '\0'; + for (a = setstr; a->type; ++a) { + if (!strncasecmp(a->type, word[2], len)) { + if (strlen(a->type) == len) { + break; + } + strcat(text, found++ % 8 ? " " : "\n ~OL"); + strcat(text, a->type); + attr = a; + } + } + if (a->type) { + found = 1; + attr = a; + } + if (found > 1) { + strcat(text, found % 8 ? "\n\n" : "\n"); + vwrite_user(user, + "~FR~OLAttribute name is not unique. \"~FT%s~RS~OL~FR\" also matches:\n", + word[2]); + write_user(user, text); + *text = '\0'; + return; + } + *text = '\0'; + if (!found) { + write_user(user, "Sorry, there is no help on that topic.\n"); + return; + } + if (word_count < 4) { + sprintf(filename, "%s/%s_%s", HELPFILES, com->name, attr->type); + } else { + sprintf(filename, "%s/%s", HELPFILES, com->name); + } + } else { + com = command_table + HELP; + sprintf(filename, "%s/%s", HELPFILES, com->name); + } + } + switch (more(user, user->socket, filename)) { + case 0: + write_user(user, "Sorry, there is no help on that topic.\n"); + break; + case 1: + user->misc_op = 2; + break; + case 2: + /* FIXME: take into account xgcoms, command list dynamic level, etc. */ + vwrite_user(user, "~OLLevel :~RS %s and above\n", + user_level[com->level].name); + break; + } +} + + +/* + * Show the command available listed by level + */ +void +help_commands_level(UR_OBJECT user) +{ + int cnt, total, highlight; + enum lvl_value lvl; + sds temp, temp1; + CMD_OBJECT cmd; + + start_pager(user); + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "| All commands start with a \".\" (when in ~FYspeech~RS mode) and can be abbreviated |\n"); + write_user(user, + "| Remember, a \".\" by itself will repeat your last command or speech |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + align_string(ALIGN_CENTRE, 78, 1, "|", + " Commands available to you (level ~OL%s~RS) ", + user_level[user->level].name)); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + total = 0; + for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { + if (user->level < lvl) { + break; + } + cnt = 0; + *text = '\0'; + sprintf(text, " ~FG~OL%-1.1s)~RS ~FC", user_level[lvl].name); + highlight = 1; + /* scroll through all commands, format and print */ + for (cmd = first_command; cmd; cmd = cmd->next) { + temp1 = sdsempty(); + if (cmd->level != lvl) { + continue; + } + if (has_xcom(user, cmd->id)) { + temp1 = sdscatfmt(sdsempty(), "~FR%s~RS%s %s", cmd->name, highlight ? "~FC" : "", + cmd->alias); + } else { + temp1 = sdscatfmt(sdsempty(), "%s %s", cmd->name, cmd->alias); + } + if (++cnt == 5) { + strcat(text, temp1); + strcat(text, "~RS"); + write_user(user, align_string(ALIGN_LEFT, 78, 1, "|", "%s", text)); + cnt = 0; + highlight = 0; + *text = '\0'; + } else { + temp = sdscatprintf(sdsempty(), "%-*s ", 11 + (int) teslen(temp1, 0), temp1); + strcat(text, temp); + sdsfree(temp); + } + if (!cnt) { + strcat(text, " "); + } + sdsfree(temp1); + } + if (cnt > 0 && cnt < 5) + write_user(user, align_string(ALIGN_LEFT, 78, 1, "|", "%s", text)); + } + /* count up total number of commands for user level */ + for (cmd = first_command; cmd; cmd = cmd->next) { + if (cmd->level > user->level) { + continue; + } + ++total; + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + align_string(ALIGN_LEFT, 78, 1, "|", + " There is a total of ~OL%d~RS command%s that you can use ", + total, PLTEXT_S(total))); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + stop_pager(user); +} + +/* + * Show the command available listed by function + */ +void +help_commands_function(UR_OBJECT user) +{ + sds temp, temp1; + CMD_OBJECT cmd; + int cnt, total, function, found; + + start_pager(user); + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "| All commands start with a \".\" (when in ~FYspeech~RS mode) and can be abbreviated |\n"); + write_user(user, + "| Remember, a \".\" by itself will repeat your last command or speech |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + align_string(ALIGN_CENTRE, 78, 1, "|", + " Commands available to you (level ~OL%s~RS) ", + user_level[user->level].name)); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + /* scroll through all the commands listing by function */ + total = 0; + for (function = 0; command_types[function]; ++function) { + cnt = 0; + found = 0; + *text = '\0'; + /* scroll through all commands, format and print */ + for (cmd = first_command; cmd; cmd = cmd->next) { + temp1 = sdsempty(); + if (cmd->level > user->level || cmd->function != function) { + continue; + } + if (!found++) { + write_user(user, + align_string(ALIGN_LEFT, 78, 1, "|", " ~OL~FG%s~RS ", + command_types[function])); + strcpy(text, " "); + } + if (has_xcom(user, cmd->id)) { + temp1 = sdscatfmt(sdsempty(), "~FR%s~RS %s", cmd->name, cmd->alias); + } else { + temp1 = sdscatfmt(sdsempty(), "%s %s", cmd->name, cmd->alias); + } + if (++cnt == 5) { + strcat(text, temp1); + strcat(text, "~RS"); + write_user(user, align_string(ALIGN_LEFT, 78, 1, "|", "%s", text)); + cnt = 0; + *text = '\0'; + } else { + temp = sdscatprintf(sdsempty(), "%-*s ", 11 + (int) teslen(temp1, 0), temp1); + strcat(text, temp); + sdsfree(temp); + } + if (!cnt) { + strcat(text, " "); + } + sdsfree(temp1); + } + if (cnt > 0 && cnt < 5) + write_user(user, align_string(ALIGN_LEFT, 78, 1, "|", "%s", text)); + } + /* count up total number of commands for user level */ + for (cmd = first_command; cmd; cmd = cmd->next) { + if (cmd->level > user->level) { + continue; + } + ++total; + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + align_string(ALIGN_LEFT, 78, 1, "|", + " There is a total of ~OL%d~RS command%s that you can use ", + total, PLTEXT_S(total))); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + stop_pager(user); +} + +/* + * Show NUTS credits + */ +void +help_nuts_credits(UR_OBJECT user) +{ + write_user(user, + "\n~BB*** NUTS Credits :) (for Amnuts credits, see \".help credits\") ***\n\n"); + vwrite_user(user, + "~BRNUTS version %s, Copyright (C) Neil Robertson 1996.\n\n", + NUTSVER); + write_user(user, + "~BM ~BB ~BC ~BG ~BY ~BR \n"); + write_user(user, + "NUTS stands for Neil's Unix Talk Server, a program which started out as a\n"); + write_user(user, + "university project in autumn 1992 and has progressed from thereon. In no\n"); + write_user(user, + "particular order thanks go to the following people who helped me develop or\n"); + write_user(user, "debug this code in one way or another over the years:\n"); + write_user(user, + " ~FCDarren Seryck, Steve Guest, Dave Temple, Satish Bedi, Tim Bernhardt,\n"); + write_user(user, + " ~FCKien Tran, Jesse Walton, Pak Chan, Scott MacKenzie and Bryan McPhail.\n"); + write_user(user, + "Also thanks must go to anyone else who has emailed me with ideas and/or bug\n"); + write_user(user, + "reports and all the people who have used NUTS over the intervening years.\n"); + write_user(user, + "I know I have said this before but this time I really mean it--this is the final\n"); + write_user(user, + "version of NUTS 3. In a few years NUTS 4 may spring forth but in the meantime\n"); + write_user(user, "that, as they say, is that. :)\n\n"); + write_user(user, + "If you wish to email me my address is \"~FGneil@ogham.demon.co.uk~RS\" and should\n"); + write_user(user, + "remain so for the forseeable future.\n\nNeil Robertson - November 1996.\n"); + write_user(user, + "~BM ~BB ~BC ~BG ~BY ~BR \n\n"); +} + +/* + * Show the credits. Add your own credits here if you wish but PLEASE leave + * my credits intact. Thanks. + */ +void +help_amnuts_credits(UR_OBJECT user) +{ + write_user(user, + "~BM ~BB ~BC ~BG ~BY ~BR \n\n"); + vwrite_user(user, + "~OL~FCAmnuts version %s~RS, Copyright (C) Andrew Collington, 2003\n", + AMNUTSVER); + write_user(user, + "Brought to you by the Amnuts Development Group (Andy, Ardant and Uzume)\n\n"); + write_user(user, + "Amnuts stands for ~OLA~RSndy's ~OLM~RSodified ~OLNUTS~RS, a Unix talker server written in C.\n\n"); + write_user(user, + "Many thanks to everyone who has helped out with Amnuts. Special thanks go to\n"); + write_user(user, + "Ardant, Uzume, Arny (of Paris fame), Silver (of PG+ fame), and anyone else who\n"); + write_user(user, + "has contributed at all to the development of Amnuts.\n\n"); + write_user(user, + "If you are interested, you can purchase Amnuts t-shirts, mugs, mousemats, and\n"); + write_user(user, + "more, from http://www.cafepress.com/amnuts/\n\nWe hope you enjoy the talker!\n\n"); + write_user(user, + " -- The Amnuts Development Group\n\n(for NUTS credits, see \".help nuts\")\n"); + write_user(user, + "\n~BM ~BB ~BC ~BG ~BY ~BR \n\n"); +} diff --git a/src/commands/history.c b/src/commands/history.c index dbdac42..69ba87b 100644 --- a/src/commands/history.c +++ b/src/commands/history.c @@ -1,40 +1,40 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * shows the history file of a given user - */ -void -user_history(UR_OBJECT user) -{ - char filename[80], name[USER_NAME_LEN + 1]; - UR_OBJECT u; - - if (word_count < 2) { - write_user(user, "Usage: history \n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - strcpy(name, u->name); - done_retrieve(u); - /* show file */ - sprintf(filename, "%s/%s/%s.H", USERFILES, USERHISTORYS, name); - vwrite_user(user, - "~FG*** The history of user ~OL%s~RS~FG is as follows ***\n\n", - name); - switch (more(user, user->socket, filename)) { - case 0: - sprintf(text, "%s has no previously recorded history.\n\n", name); - write_user(user, text); - break; - case 1: - user->misc_op = 2; - break; - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * shows the history file of a given user + */ +void +user_history(UR_OBJECT user) +{ + char filename[80], name[USER_NAME_LEN + 1]; + UR_OBJECT u; + + if (word_count < 2) { + write_user(user, "Usage: history \n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + strcpy(name, u->name); + done_retrieve(u); + /* show file */ + sprintf(filename, "%s/%s/%s.H", USERFILES, USERHISTORYS, name); + vwrite_user(user, + "~FG*** The history of user ~OL%s~RS~FG is as follows ***\n\n", + name); + switch (more(user, user->socket, filename)) { + case 0: + sprintf(text, "%s has no previously recorded history.\n\n", name); + write_user(user, text); + break; + case 1: + user->misc_op = 2; + break; + } +} diff --git a/src/commands/home.c b/src/commands/home.c index f19c667..dfc80be 100644 --- a/src/commands/home.c +++ b/src/commands/home.c @@ -1,36 +1,36 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -#ifdef NETLINKS - -/* - * Return to home site - */ -void -home(UR_OBJECT user) -{ - if (user->room) { - write_user(user, "You are already on your home system.\n"); - return; - } - write_user(user, "~FB~OLYou traverse cyberspace...\n"); - write_syslog(NETLOG, 1, "NETLINK: %s returned from %s.\n", user->name, - user->netlink->service); - release_nl(user); - if (user->vis) { - vwrite_room_except(user->room, user, "%s~RS %s\n", user->recap, - user->in_phrase); - } else { - write_room_except(user->room, invisenter, user); - } - look(user); -} - -#else - -#define NO_NETLINKS - -#endif + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +#ifdef NETLINKS + +/* + * Return to home site + */ +void +home(UR_OBJECT user) +{ + if (user->room) { + write_user(user, "You are already on your home system.\n"); + return; + } + write_user(user, "~FB~OLYou traverse cyberspace...\n"); + write_syslog(NETLOG, 1, "NETLINK: %s returned from %s.\n", user->name, + user->netlink->service); + release_nl(user); + if (user->vis) { + vwrite_room_except(user->room, user, "%s~RS %s\n", user->recap, + user->in_phrase); + } else { + write_room_except(user->room, invisenter, user); + } + look(user); +} + +#else + +#define NO_NETLINKS + +#endif diff --git a/src/commands/ignlist.c b/src/commands/ignlist.c index e15daa7..29d1af8 100644 --- a/src/commands/ignlist.c +++ b/src/commands/ignlist.c @@ -1,41 +1,41 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * displays what the user is currently listening to/ignoring - */ -void -show_ignlist(UR_OBJECT user) -{ - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCYour ignore states are as follows~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - if (user->ignall) { - write_user(user, - "| You are currently ignoring ~OL~FReverything~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - return; - } - vwrite_user(user, - "| Ignoring shouts : ~OL%-3s~RS Ignoring tells : ~OL%-3s~RS Ignoring logons : ~OL%-3s~RS |\n", - noyes[user->ignshouts], noyes[user->igntells], - noyes[user->ignlogons]); - vwrite_user(user, - "| Ignoring pictures : ~OL%-3s~RS Ignoring greets : ~OL%-3s~RS Ignoring beeps : ~OL%-3s~RS |\n", - noyes[user->ignpics], noyes[user->igngreets], - noyes[user->ignbeeps]); - if (user->level >= (enum lvl_value) command_table[IGNWIZ].level) { - vwrite_user(user, - "| Ignoring wiztells : ~OL%-3s~RS |\n", - noyes[user->ignwiz]); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * displays what the user is currently listening to/ignoring + */ +void +show_ignlist(UR_OBJECT user) +{ + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCYour ignore states are as follows~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + if (user->ignall) { + write_user(user, + "| You are currently ignoring ~OL~FReverything~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + return; + } + vwrite_user(user, + "| Ignoring shouts : ~OL%-3s~RS Ignoring tells : ~OL%-3s~RS Ignoring logons : ~OL%-3s~RS |\n", + noyes[user->ignshouts], noyes[user->igntells], + noyes[user->ignlogons]); + vwrite_user(user, + "| Ignoring pictures : ~OL%-3s~RS Ignoring greets : ~OL%-3s~RS Ignoring beeps : ~OL%-3s~RS |\n", + noyes[user->ignpics], noyes[user->igngreets], + noyes[user->ignbeeps]); + if (user->level >= (enum lvl_value) command_table[IGNWIZ].level) { + vwrite_user(user, + "| Ignoring wiztells : ~OL%-3s~RS |\n", + noyes[user->ignwiz]); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); +} diff --git a/src/commands/ignuser.c b/src/commands/ignuser.c index fbc7083..1a52990 100644 --- a/src/commands/ignuser.c +++ b/src/commands/ignuser.c @@ -1,49 +1,49 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * set to ignore/listen to a user - */ -void -set_igusers(UR_OBJECT user) -{ - UR_OBJECT u; - - if (word_count < 2) { - show_igusers(user); - return; - } - /* add or remove ignores */ - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - - if (user == u) { - write_user(user, "You cannot ignore yourself!\n"); - return; - } - /* do it */ - if (check_igusers(user, u)) { - if (unsetbit_flagged_user_entry(user, u->name, fufIGNORE)) { - vwrite_user(user, "You will once again listen to %s.\n", u->name); - } else { - vwrite_user(user, - "Sorry, but you could not unignore %s at this time.\n", - u->name); - } - } else { - if (setbit_flagged_user_entry(user, u->name, fufIGNORE)) { - vwrite_user(user, "You will now ignore speech from %s.\n", u->name); - } else { - vwrite_user(user, "Sorry, but you could not ignore %s at this time.\n", - u->name); - } - } - /* finish up */ - done_retrieve(u); -} - + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * set to ignore/listen to a user + */ +void +set_igusers(UR_OBJECT user) +{ + UR_OBJECT u; + + if (word_count < 2) { + show_igusers(user); + return; + } + /* add or remove ignores */ + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + + if (user == u) { + write_user(user, "You cannot ignore yourself!\n"); + return; + } + /* do it */ + if (check_igusers(user, u)) { + if (unsetbit_flagged_user_entry(user, u->name, fufIGNORE)) { + vwrite_user(user, "You will once again listen to %s.\n", u->name); + } else { + vwrite_user(user, + "Sorry, but you could not unignore %s at this time.\n", + u->name); + } + } else { + if (setbit_flagged_user_entry(user, u->name, fufIGNORE)) { + vwrite_user(user, "You will now ignore speech from %s.\n", u->name); + } else { + vwrite_user(user, "Sorry, but you could not ignore %s at this time.\n", + u->name); + } + } + /* finish up */ + done_retrieve(u); +} + diff --git a/src/commands/invite.c b/src/commands/invite.c index 3462188..54b4969 100644 --- a/src/commands/invite.c +++ b/src/commands/invite.c @@ -1,50 +1,50 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Invite a user into a private room - */ -void -invite(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - const char *name; - - if (word_count < 2) { - write_user(user, "Invite who?\n"); - return; - } - rm = user->room; - if (!is_private_room(rm)) { - write_user(user, "This room is currently public.\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, - "Inviting yourself to somewhere is the third sign of madness.\n"); - return; - } - if (u->room == rm) { - vwrite_user(user, "%s~RS is already here!\n", u->recap); - return; - } - if (u->invite_room == rm) { - vwrite_user(user, "%s~RS has already been invited into here.\n", - u->recap); - return; - } - vwrite_user(user, "You invite %s~RS in.\n", u->recap); - name = user->vis || u->level >= user->level ? user->recap : invisname; - vwrite_user(u, "%s~RS has invited you into the %s.\n", name, rm->name); - u->invite_room = rm; - strcpy(u->invite_by, user->name); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Invite a user into a private room + */ +void +invite(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + const char *name; + + if (word_count < 2) { + write_user(user, "Invite who?\n"); + return; + } + rm = user->room; + if (!is_private_room(rm)) { + write_user(user, "This room is currently public.\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, + "Inviting yourself to somewhere is the third sign of madness.\n"); + return; + } + if (u->room == rm) { + vwrite_user(user, "%s~RS is already here!\n", u->recap); + return; + } + if (u->invite_room == rm) { + vwrite_user(user, "%s~RS has already been invited into here.\n", + u->recap); + return; + } + vwrite_user(user, "You invite %s~RS in.\n", u->recap); + name = user->vis || u->level >= user->level ? user->recap : invisname; + vwrite_user(u, "%s~RS has invited you into the %s.\n", name, rm->name); + u->invite_room = rm; + strcpy(u->invite_by, user->name); +} diff --git a/src/commands/join.c b/src/commands/join.c index 43f7f5e..9c94172 100644 --- a/src/commands/join.c +++ b/src/commands/join.c @@ -1,52 +1,52 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Join a user in another room - */ -void -join(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - - if (word_count < 2) { - write_user(user, "Usage: join \n"); - return; - } - if (user->lroom == 2) { - write_user(user, "You have been shackled and cannot move.\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (user == u) { - write_user(user, - "You really want join yourself? What would the neighbours think?\n"); - return; - } - rm = u->room; -#ifdef NETLINKS - if (!rm) { - vwrite_user(user, - "%s~RS is currently off site so you cannot join them.\n", - u->recap); - return; - } -#endif - if (rm == user->room) { - vwrite_user(user, "You are already with %s~RS in the %s~RS.\n", u->recap, - rm->show_name); - return; - } - move_user(user, rm, 0); - vwrite_user(user, - "~FC~OLYou have joined~RS %s~RS ~FC~OLin the~RS %s~RS~FC~OL.\n", - u->recap, u->room->show_name); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Join a user in another room + */ +void +join(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + + if (word_count < 2) { + write_user(user, "Usage: join \n"); + return; + } + if (user->lroom == 2) { + write_user(user, "You have been shackled and cannot move.\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (user == u) { + write_user(user, + "You really want join yourself? What would the neighbours think?\n"); + return; + } + rm = u->room; +#ifdef NETLINKS + if (!rm) { + vwrite_user(user, + "%s~RS is currently off site so you cannot join them.\n", + u->recap); + return; + } +#endif + if (rm == user->room) { + vwrite_user(user, "You are already with %s~RS in the %s~RS.\n", u->recap, + rm->show_name); + return; + } + move_user(user, rm, 0); + vwrite_user(user, + "~FC~OLYou have joined~RS %s~RS ~FC~OLin the~RS %s~RS~FC~OL.\n", + u->recap, u->room->show_name); } \ No newline at end of file diff --git a/src/commands/kill_user.c b/src/commands/kill_user.c index 9e07b62..1994d2d 100644 --- a/src/commands/kill_user.c +++ b/src/commands/kill_user.c @@ -1,74 +1,74 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Kill a user - bump them off the talker - */ -void -kill_user(UR_OBJECT user) -{ - - struct kill_mesgs_struct { - const char *victim_msg; - const char *room_msg; - }; - static const struct kill_mesgs_struct kill_mesgs[] = { - {"You are killed\n", "%s is killed\n"}, - {"You have been totally splatted\n", "A hammer splats %s\n"}, - {"The Hedgehog Of Doom runs over you with a car.\n", - "The Hedgehog Of Doom runs over %s with a car.\n"}, - {"The Inquisitor deletes the worthless, prunes away the wastrels... ie, YOU!", "The Inquisitor prunes away %s.\n"}, - {NULL, NULL}, - }; - UR_OBJECT victim; - const char *name; - int msg; - - if (word_count < 2) { - write_user(user, "Usage: kill \n"); - return; - } - victim = get_user_name(user, word[1]); - if (!victim) { - write_user(user, notloggedon); - return; - } - if (user == victim) { - write_user(user, - "Trying to commit suicide this way is the sixth sign of madness.\n"); - return; - } - if (victim->level >= user->level) { - write_user(user, - "You cannot kill a user of equal or higher level than yourself.\n"); - vwrite_user(victim, "%s~RS tried to kill you!\n", user->recap); - return; - } - write_syslog(SYSLOG, 1, "%s KILLED %s.\n", user->name, victim->name); - write_user(user, "~FM~OLYou chant an evil incantation...\n"); - name = user->vis ? user->bw_recap : invisname; - vwrite_room_except(user->room, user, - "~FM~OL%s chants an evil incantation...\n", name); - /* - display random kill message. if you only want one message to be displayed - then only have one message listed in kill_mesgs[]. - */ - for (msg = 0; kill_mesgs[msg].victim_msg; ++msg) { - ; - } - if (msg) { - msg = rand() % msg; - write_user(victim, kill_mesgs[msg].victim_msg); - vwrite_room_except(victim->room, victim, kill_mesgs[msg].room_msg, - victim->bw_recap); - } - sprintf(text, "~FRKilled~RS by %s.\n", user->name); - add_history(victim->name, 1, "%s", text); - disconnect_user(victim); - write_monitor(user, NULL, 0); - write_room(NULL, - "~FM~OLYou hear insane laughter from beyond the grave...\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Kill a user - bump them off the talker + */ +void +kill_user(UR_OBJECT user) +{ + + struct kill_mesgs_struct { + const char *victim_msg; + const char *room_msg; + }; + static const struct kill_mesgs_struct kill_mesgs[] = { + {"You are killed\n", "%s is killed\n"}, + {"You have been totally splatted\n", "A hammer splats %s\n"}, + {"The Hedgehog Of Doom runs over you with a car.\n", + "The Hedgehog Of Doom runs over %s with a car.\n"}, + {"The Inquisitor deletes the worthless, prunes away the wastrels... ie, YOU!", "The Inquisitor prunes away %s.\n"}, + {NULL, NULL}, + }; + UR_OBJECT victim; + const char *name; + int msg; + + if (word_count < 2) { + write_user(user, "Usage: kill \n"); + return; + } + victim = get_user_name(user, word[1]); + if (!victim) { + write_user(user, notloggedon); + return; + } + if (user == victim) { + write_user(user, + "Trying to commit suicide this way is the sixth sign of madness.\n"); + return; + } + if (victim->level >= user->level) { + write_user(user, + "You cannot kill a user of equal or higher level than yourself.\n"); + vwrite_user(victim, "%s~RS tried to kill you!\n", user->recap); + return; + } + write_syslog(SYSLOG, 1, "%s KILLED %s.\n", user->name, victim->name); + write_user(user, "~FM~OLYou chant an evil incantation...\n"); + name = user->vis ? user->bw_recap : invisname; + vwrite_room_except(user->room, user, + "~FM~OL%s chants an evil incantation...\n", name); + /* + display random kill message. if you only want one message to be displayed + then only have one message listed in kill_mesgs[]. + */ + for (msg = 0; kill_mesgs[msg].victim_msg; ++msg) { + ; + } + if (msg) { + msg = rand() % msg; + write_user(victim, kill_mesgs[msg].victim_msg); + vwrite_room_except(victim->room, victim, kill_mesgs[msg].room_msg, + victim->bw_recap); + } + sprintf(text, "~FRKilled~RS by %s.\n", user->name); + add_history(victim->name, 1, "%s", text); + disconnect_user(victim); + write_monitor(user, NULL, 0); + write_room(NULL, + "~FM~OLYou hear insane laughter from beyond the grave...\n"); +} diff --git a/src/commands/last.c b/src/commands/last.c index f1b7018..54b4f39 100644 --- a/src/commands/last.c +++ b/src/commands/last.c @@ -1,92 +1,92 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Shows when a user was last logged on - */ -void -show_last_login(UR_OBJECT user) -{ - char line[ARR_SIZE], tmp[ARR_SIZE]; - UR_OBJECT u; - int timelen, days, hours, mins, i, cnt; - - if (word_count > 2) { - write_user(user, "Usage: last []\n"); - return; - } - - /* if checking last on a user */ - if (word_count == 2) { - /* get user */ - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - /* error checking */ - if (u == user) { - write_user(user, "You are already logged on!\n"); - return; - } - if (retrieve_user_type == 1) { - vwrite_user(user, "%s~RS is currently logged on.\n", u->recap); - return; - } - /* show details */ - timelen = (int) (time(0) - u->last_login); - days = timelen / 86400; - hours = (timelen % 86400) / 3600; - mins = (timelen % 3600) / 60; - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - cnt = 52 + teslen(u->recap, 52); - vwrite_user(user, "| ~FC~OLLast login details of~RS %-*.*s~RS |\n", - cnt, cnt, u->recap); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - strftime(tmp, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", - localtime(&u->last_login)); - vwrite_user(user, "| Was last logged in %-55s |\n", tmp); - sprintf(tmp, "Which was %d day%s, %d hour%s and %d minute%s ago", days, - PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins)); - vwrite_user(user, "| %-74s |\n", tmp); - sprintf(tmp, "Was on for %d hour%s and %d minute%s", - u->last_login_len / 3600, PLTEXT_S(u->last_login_len / 3600), - (u->last_login_len % 3600) / 60, - PLTEXT_S((u->last_login_len % 3600) / 60)); - vwrite_user(user, "| %-74s |\n", tmp); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - done_retrieve(u); - return; - } - /* if checking all of the last users to log on */ - /* get each line of the logins and check if that user is still on & print out the result. */ - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~FC~OLThe last users to have logged in~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - for (i = 0; i < LASTLOGON_NUM; ++i) { - if (!*last_login_info[i].name) { - continue; - } - u = get_user(last_login_info[i].name); - if (last_login_info[i].on && (u && !u->vis && user->level < WIZ)) { - continue; - } - sprintf(line, "%s %s", last_login_info[i].name, last_login_info[i].time); - if (last_login_info[i].on) { - sprintf(text, "| %-67s ~OL~FYONLINE~RS |\n", line); - } else { - sprintf(text, "| %-74s |\n", line); - } - write_user(user, text); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Shows when a user was last logged on + */ +void +show_last_login(UR_OBJECT user) +{ + char line[ARR_SIZE], tmp[ARR_SIZE]; + UR_OBJECT u; + int timelen, days, hours, mins, i, cnt; + + if (word_count > 2) { + write_user(user, "Usage: last []\n"); + return; + } + + /* if checking last on a user */ + if (word_count == 2) { + /* get user */ + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + /* error checking */ + if (u == user) { + write_user(user, "You are already logged on!\n"); + return; + } + if (retrieve_user_type == 1) { + vwrite_user(user, "%s~RS is currently logged on.\n", u->recap); + return; + } + /* show details */ + timelen = (int) (time(0) - u->last_login); + days = timelen / 86400; + hours = (timelen % 86400) / 3600; + mins = (timelen % 3600) / 60; + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + cnt = 52 + teslen(u->recap, 52); + vwrite_user(user, "| ~FC~OLLast login details of~RS %-*.*s~RS |\n", + cnt, cnt, u->recap); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + strftime(tmp, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", + localtime(&u->last_login)); + vwrite_user(user, "| Was last logged in %-55s |\n", tmp); + sprintf(tmp, "Which was %d day%s, %d hour%s and %d minute%s ago", days, + PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins)); + vwrite_user(user, "| %-74s |\n", tmp); + sprintf(tmp, "Was on for %d hour%s and %d minute%s", + u->last_login_len / 3600, PLTEXT_S(u->last_login_len / 3600), + (u->last_login_len % 3600) / 60, + PLTEXT_S((u->last_login_len % 3600) / 60)); + vwrite_user(user, "| %-74s |\n", tmp); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + done_retrieve(u); + return; + } + /* if checking all of the last users to log on */ + /* get each line of the logins and check if that user is still on & print out the result. */ + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~FC~OLThe last users to have logged in~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + for (i = 0; i < LASTLOGON_NUM; ++i) { + if (!*last_login_info[i].name) { + continue; + } + u = get_user(last_login_info[i].name); + if (last_login_info[i].on && (u && !u->vis && user->level < WIZ)) { + continue; + } + sprintf(line, "%s %s", last_login_info[i].name, last_login_info[i].time); + if (last_login_info[i].on) { + sprintf(text, "| %-67s ~OL~FYONLINE~RS |\n", line); + } else { + sprintf(text, "| %-74s |\n", line); + } + write_user(user, text); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); +} diff --git a/src/commands/letmein.c b/src/commands/letmein.c index 885f44b..cf8d672 100644 --- a/src/commands/letmein.c +++ b/src/commands/letmein.c @@ -1,46 +1,46 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Ask to be let into a private room - */ -void -letmein(UR_OBJECT user) -{ - RM_OBJECT rm; - int i; - - if (word_count < 2) { - write_user(user, "Knock on what door?\n"); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - if (rm == user->room) { - vwrite_user(user, "You are already in the %s!\n", rm->name); - return; - } - for (i = 0; i < MAX_LINKS; ++i) - if (user->room->link[i] == rm) { - break; - } - if (i >= MAX_LINKS) { - vwrite_user(user, "The %s is not adjoined to here.\n", rm->name); - return; - } - if (!is_private_room(rm)) { - vwrite_user(user, "The %s is currently public.\n", rm->name); - return; - } - vwrite_user(user, "You knock asking to be let into the %s.\n", rm->name); - vwrite_room_except(user->room, user, - "%s~RS knocks asking to be let into the %s.\n", - user->recap, rm->name); - vwrite_room(rm, "%s~RS knocks asking to be let in.\n", user->recap); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Ask to be let into a private room + */ +void +letmein(UR_OBJECT user) +{ + RM_OBJECT rm; + int i; + + if (word_count < 2) { + write_user(user, "Knock on what door?\n"); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + if (rm == user->room) { + vwrite_user(user, "You are already in the %s!\n", rm->name); + return; + } + for (i = 0; i < MAX_LINKS; ++i) + if (user->room->link[i] == rm) { + break; + } + if (i >= MAX_LINKS) { + vwrite_user(user, "The %s is not adjoined to here.\n", rm->name); + return; + } + if (!is_private_room(rm)) { + vwrite_user(user, "The %s is currently public.\n", rm->name); + return; + } + vwrite_user(user, "You knock asking to be let into the %s.\n", rm->name); + vwrite_room_except(user->room, user, + "%s~RS knocks asking to be let into the %s.\n", + user->recap, rm->name); + vwrite_room(rm, "%s~RS knocks asking to be let in.\n", user->recap); +} diff --git a/src/commands/listbans.c b/src/commands/listbans.c index c1ebdb5..ef6fa54 100644 --- a/src/commands/listbans.c +++ b/src/commands/listbans.c @@ -1,75 +1,75 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * List banned sites or users - */ -void -listbans(UR_OBJECT user) -{ - char filename[80]; - int i; - - strtolower(word[1]); - if (!strcmp(word[1], "sites")) { - write_user(user, "\n~BB*** Banned sites and domains ***\n\n"); - sprintf(filename, "%s/%s", DATAFILES, SITEBAN); - switch (more(user, user->socket, filename)) { - case 0: - write_user(user, "There are no banned sites and domains.\n\n"); - return; - case 1: - user->misc_op = 2; - break; - } - return; - } - if (!strcmp(word[1], "users")) { - write_user(user, "\n~BB*** Banned users ***\n\n"); - sprintf(filename, "%s/%s", DATAFILES, USERBAN); - switch (more(user, user->socket, filename)) { - case 0: - write_user(user, "There are no banned users.\n\n"); - return; - case 1: - user->misc_op = 2; - break; - } - return; - } - if (!strcmp(word[1], "swears")) { - write_user(user, "\n~BB*** Banned swear words ***\n\n"); - for (i = 0; swear_words[i]; ++i) { - write_user(user, swear_words[i]); - write_user(user, "\n"); - } - if (!i) { - write_user(user, "There are no banned swear words.\n"); - } - if (amsys->ban_swearing) { - write_user(user, "\n"); - } else { - write_user(user, "\n(Swearing ban is currently off)\n\n"); - } - return; - } - if (strcmp(word[1], "new")) { - write_user(user, - "\n~BB*** New users banned from sites and domains **\n\n"); - sprintf(filename, "%s/%s", DATAFILES, NEWBAN); - switch (more(user, user->socket, filename)) { - case 0: - write_user(user, - "There are no sites and domains where new users have been banned.\n\n"); - return; - case 1: - user->misc_op = 2; - break; - } - return; - } - write_user(user, "Usage: lban sites|users|new|swears\n"); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * List banned sites or users + */ +void +listbans(UR_OBJECT user) +{ + char filename[80]; + int i; + + strtolower(word[1]); + if (!strcmp(word[1], "sites")) { + write_user(user, "\n~BB*** Banned sites and domains ***\n\n"); + sprintf(filename, "%s/%s", DATAFILES, SITEBAN); + switch (more(user, user->socket, filename)) { + case 0: + write_user(user, "There are no banned sites and domains.\n\n"); + return; + case 1: + user->misc_op = 2; + break; + } + return; + } + if (!strcmp(word[1], "users")) { + write_user(user, "\n~BB*** Banned users ***\n\n"); + sprintf(filename, "%s/%s", DATAFILES, USERBAN); + switch (more(user, user->socket, filename)) { + case 0: + write_user(user, "There are no banned users.\n\n"); + return; + case 1: + user->misc_op = 2; + break; + } + return; + } + if (!strcmp(word[1], "swears")) { + write_user(user, "\n~BB*** Banned swear words ***\n\n"); + for (i = 0; swear_words[i]; ++i) { + write_user(user, swear_words[i]); + write_user(user, "\n"); + } + if (!i) { + write_user(user, "There are no banned swear words.\n"); + } + if (amsys->ban_swearing) { + write_user(user, "\n"); + } else { + write_user(user, "\n(Swearing ban is currently off)\n\n"); + } + return; + } + if (strcmp(word[1], "new")) { + write_user(user, + "\n~BB*** New users banned from sites and domains **\n\n"); + sprintf(filename, "%s/%s", DATAFILES, NEWBAN); + switch (more(user, user->socket, filename)) { + case 0: + write_user(user, + "There are no sites and domains where new users have been banned.\n\n"); + return; + case 1: + user->misc_op = 2; + break; + } + return; + } + write_user(user, "Usage: lban sites|users|new|swears\n"); } \ No newline at end of file diff --git a/src/commands/listen.c b/src/commands/listen.c index f90ae63..9a9c32b 100644 --- a/src/commands/listen.c +++ b/src/commands/listen.c @@ -1,56 +1,56 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Allows a user to listen to everything again - */ -void -user_listen(UR_OBJECT user) -{ - int yes; - - yes = 0; - if (user->ignall) { - user->ignall = 0; - ++yes; - } - if (user->igntells) { - user->igntells = 0; - ++yes; - } - if (user->ignshouts) { - user->ignshouts = 0; - ++yes; - } - if (user->ignpics) { - user->ignpics = 0; - ++yes; - } - if (user->ignlogons) { - user->ignlogons = 0; - ++yes; - } - if (user->ignwiz) { - user->ignwiz = 0; - ++yes; - } - if (user->igngreets) { - user->igngreets = 0; - ++yes; - } - if (user->ignbeeps) { - user->ignbeeps = 0; - ++yes; - } - if (!yes) { - write_user(user, "You are already listening to everything.\n"); - return; - } - write_user(user, "You listen to everything again.\n"); - if (user->vis) { - vwrite_room_except(user->room, user, - "%s~RS is now listening to you all again.\n", user->recap); - } -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Allows a user to listen to everything again + */ +void +user_listen(UR_OBJECT user) +{ + int yes; + + yes = 0; + if (user->ignall) { + user->ignall = 0; + ++yes; + } + if (user->igntells) { + user->igntells = 0; + ++yes; + } + if (user->ignshouts) { + user->ignshouts = 0; + ++yes; + } + if (user->ignpics) { + user->ignpics = 0; + ++yes; + } + if (user->ignlogons) { + user->ignlogons = 0; + ++yes; + } + if (user->ignwiz) { + user->ignwiz = 0; + ++yes; + } + if (user->igngreets) { + user->igngreets = 0; + ++yes; + } + if (user->ignbeeps) { + user->ignbeeps = 0; + ++yes; + } + if (!yes) { + write_user(user, "You are already listening to everything.\n"); + return; + } + write_user(user, "You listen to everything again.\n"); + if (user->vis) { + vwrite_room_except(user->room, user, + "%s~RS is now listening to you all again.\n", user->recap); + } +} diff --git a/src/commands/lmail.c b/src/commands/lmail.c index 8dd84ce..b49c00c 100644 --- a/src/commands/lmail.c +++ b/src/commands/lmail.c @@ -1,93 +1,93 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Send mail message to everyone - */ -void -level_mail(UR_OBJECT user, char *inpstr) -{ - if (inpstr) { - static const char usage[] = "Usage: lmail |wizzes|all []\n"; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot mail anyone.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - strtoupper(word[1]); - user->lmail_lev = get_level(word[1]); - if (user->lmail_lev == NUM_LEVELS) { - if (!strcmp(word[1], "WIZZES")) { - user->lmail_lev = WIZ; - } else if (!strcmp(word[1], "ALL")) { - user->lmail_lev = JAILED; - } else { - write_user(user, usage); - return; - } - user->lmail_all = !0; - } else { - user->lmail_all = 0; - } - if (word_count < 3) { -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - write_user(user, - "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".lmail |wizzes|all \" method instead.\n"); - return; - } -#endif - if (!user->lmail_all) { - vwrite_user(user, - "\n~FG*** Writing broadcast level mail message to all the %ss ***\n\n", - user_level[user->lmail_lev].name); - } else { - if (user->lmail_lev == WIZ) { - write_user(user, - "\n~FG*** Writing broadcast level mail message to all the Wizzes ***\n\n"); - } else { - write_user(user, - "\n~FG*** Writing broadcast level mail message to everyone ***\n\n"); - } - } - user->misc_op = 9; - editor(user, NULL); - return; - } - strcat(inpstr, "\n"); /* XXX: risky but hopefully it will be ok */ - inpstr = remove_first(inpstr); - } else { - inpstr = user->malloc_start; - } - if (!send_broadcast_mail(user, inpstr, user->lmail_lev, user->lmail_all)) { - write_user(user, "There does not seem to be anyone to send mail to.\n"); - user->lmail_all = 0; - user->lmail_lev = NUM_LEVELS; - return; - } - if (!user->lmail_all) { - vwrite_user(user, "You have sent mail to all the %ss.\n", - user_level[user->lmail_lev].name); - write_syslog(SYSLOG, 1, "%s sent mail to all the %ss.\n", user->name, - user_level[user->lmail_lev].name); - } else { - if (user->lmail_lev == WIZ) { - write_user(user, "You have sent mail to all the Wizzes.\n"); - write_syslog(SYSLOG, 1, "%s sent mail to all the Wizzes.\n", - user->name); - } else { - write_user(user, "You have sent mail to all the users.\n"); - write_syslog(SYSLOG, 1, "%s sent mail to all the users.\n", user->name); - } - } - user->lmail_all = 0; - user->lmail_lev = NUM_LEVELS; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Send mail message to everyone + */ +void +level_mail(UR_OBJECT user, char *inpstr) +{ + if (inpstr) { + static const char usage[] = "Usage: lmail |wizzes|all []\n"; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot mail anyone.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + strtoupper(word[1]); + user->lmail_lev = get_level(word[1]); + if (user->lmail_lev == NUM_LEVELS) { + if (!strcmp(word[1], "WIZZES")) { + user->lmail_lev = WIZ; + } else if (!strcmp(word[1], "ALL")) { + user->lmail_lev = JAILED; + } else { + write_user(user, usage); + return; + } + user->lmail_all = !0; + } else { + user->lmail_all = 0; + } + if (word_count < 3) { +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + write_user(user, + "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".lmail |wizzes|all \" method instead.\n"); + return; + } +#endif + if (!user->lmail_all) { + vwrite_user(user, + "\n~FG*** Writing broadcast level mail message to all the %ss ***\n\n", + user_level[user->lmail_lev].name); + } else { + if (user->lmail_lev == WIZ) { + write_user(user, + "\n~FG*** Writing broadcast level mail message to all the Wizzes ***\n\n"); + } else { + write_user(user, + "\n~FG*** Writing broadcast level mail message to everyone ***\n\n"); + } + } + user->misc_op = 9; + editor(user, NULL); + return; + } + strcat(inpstr, "\n"); /* XXX: risky but hopefully it will be ok */ + inpstr = remove_first(inpstr); + } else { + inpstr = user->malloc_start; + } + if (!send_broadcast_mail(user, inpstr, user->lmail_lev, user->lmail_all)) { + write_user(user, "There does not seem to be anyone to send mail to.\n"); + user->lmail_all = 0; + user->lmail_lev = NUM_LEVELS; + return; + } + if (!user->lmail_all) { + vwrite_user(user, "You have sent mail to all the %ss.\n", + user_level[user->lmail_lev].name); + write_syslog(SYSLOG, 1, "%s sent mail to all the %ss.\n", user->name, + user_level[user->lmail_lev].name); + } else { + if (user->lmail_lev == WIZ) { + write_user(user, "You have sent mail to all the Wizzes.\n"); + write_syslog(SYSLOG, 1, "%s sent mail to all the Wizzes.\n", + user->name); + } else { + write_user(user, "You have sent mail to all the users.\n"); + write_syslog(SYSLOG, 1, "%s sent mail to all the users.\n", user->name); + } + } + user->lmail_all = 0; + user->lmail_lev = NUM_LEVELS; +} diff --git a/src/commands/logging.c b/src/commands/logging.c index 6199444..35b10f3 100644 --- a/src/commands/logging.c +++ b/src/commands/logging.c @@ -1,163 +1,163 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Turn on and off each individual system log, or globally on and off - */ -void -logging(UR_OBJECT user) -{ - char temp[ARR_SIZE]; - int cnt; - - if (word_count < 2) { - write_user(user, "Usage: logging -l|-s|-r|-n|-e|-on|-off\n"); - return; - } - strtolower(word[1]); - /* deal with listing the log status first */ - if (!strcmp(word[1], "-l")) { - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCSystem log status~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - sprintf(temp, - "General system log : ~OL%s~RS Account request logs : ~OL%s~RS Netlinks log : ~OL%s~RS", - amsys->logging & SYSLOG ? "ON " : "OFF", - amsys->logging & REQLOG ? "ON " : "OFF", - amsys->logging & NETLOG ? "ON " : "OFF"); - cnt = 74 + teslen(temp, 74); - vwrite_user(user, "| %-*.*s |\n", cnt, cnt, temp); - sprintf(temp, " Error log : ~OL%s~RS", - amsys->logging & ERRLOG ? "ON " : "OFF"); - cnt = 74 + teslen(temp, 74); - vwrite_user(user, "| %-*.*s |\n", cnt, cnt, temp); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - /* (un)set syslog bit */ - if (!strcmp(word[1], "-s")) { - /* if already on */ - if (amsys->logging & SYSLOG) { - write_syslog(SYSLOG, 1, "%s switched general system logging OFF.\n", - user->name); - } - amsys->logging ^= SYSLOG; - /* if now on */ - if (amsys->logging & SYSLOG) { - write_syslog(SYSLOG, 1, "%s switched general system logging ON.\n", - user->name); - } - vwrite_user(user, "You have now turned the general system logging %s.\n", - amsys->logging & SYSLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); - return; - } - /* (un)set reqlog bit */ - if (!strcmp(word[1], "-r")) { - /* if already on */ - if (amsys->logging & REQLOG) { - write_syslog(REQLOG, 1, "%s switched account request logging OFF.\n", - user->name); - } - amsys->logging ^= REQLOG; - /* if now on */ - if (amsys->logging & REQLOG) { - write_syslog(REQLOG, 1, "%s switched account request logging ON.\n", - user->name); - } - vwrite_user(user, "You have now turned the account request logging %s.\n", - amsys->logging & REQLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); - return; - } - /* (un)set netlog bit */ - if (!strcmp(word[1], "-n")) { -#ifdef NETLINKS - /* if already on */ - if (amsys->logging & NETLOG) { - write_syslog(NETLOG, 1, "%s switched netlink logging OFF.\n", - user->name); - } - amsys->logging ^= NETLOG; - /* if now on */ - if (amsys->logging & NETLOG) { - write_syslog(NETLOG, 1, "%s switched netlink logging ON.\n", - user->name); - } - vwrite_user(user, "You have now turned the netlink logging %s.\n", - amsys->logging & NETLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); -#else - write_user(user, "Netlinks are not currently active.\n"); -#endif - return; - } - /* (un)set errlog bit */ - if (!strcmp(word[1], "-e")) { - /* if already on */ - if (amsys->logging & ERRLOG) { - write_syslog(ERRLOG, 1, "%s switched error logging OFF.\n", user->name); - } - amsys->logging ^= ERRLOG; - /* if on already */ - if (amsys->logging & ERRLOG) { - write_syslog(REQLOG, 1, "%s switched error logging ON.\n", user->name); - } - vwrite_user(user, "You have now turned the error logging %s.\n", - amsys->logging & ERRLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); - return; - } - /* set all bit */ - if (!strcmp(word[1], "-on")) { - if (!(amsys->logging & SYSLOG)) { - amsys->logging |= SYSLOG; - write_syslog(SYSLOG, 1, "%s switched general system logging ON.\n", - user->name); - } - if (!(amsys->logging & REQLOG)) { - amsys->logging |= REQLOG; - write_syslog(REQLOG, 1, "%s switched acount request logging ON.\n", - user->name); - } - if (!(amsys->logging & NETLOG)) { - amsys->logging |= NETLOG; - write_syslog(NETLOG, 1, "%s switched netlink logging ON.\n", - user->name); - } - if (!(amsys->logging & ERRLOG)) { - amsys->logging |= ERRLOG; - write_syslog(ERRLOG, 1, "%s switched error logging ON.\n", user->name); - } - write_user(user, "You have now turned all logging ~OL~FGON~RS.\n"); - return; - } - /* unset all bit */ - if (!strcmp(word[1], "-off")) { - if (amsys->logging & SYSLOG) { - write_syslog(SYSLOG, 1, "%s switched general system logging OFF.\n", - user->name); - amsys->logging &= ~SYSLOG; - } - if (amsys->logging & REQLOG) { - write_syslog(REQLOG, 1, "%s switched acount request logging OFF.\n", - user->name); - amsys->logging &= ~REQLOG; - } - if (amsys->logging & NETLOG) { - write_syslog(NETLOG, 1, "%s switched netlink logging OFF.\n", - user->name); - amsys->logging &= ~NETLOG; - } - if (amsys->logging & ERRLOG) { - write_syslog(ERRLOG, 1, "%s switched error logging OFF.\n", user->name); - amsys->logging &= ~ERRLOG; - } - write_user(user, "You have now turned all logging ~OL~FROFF~RS.\n"); - return; - } - write_user(user, "Usage: logging -l|-s|-r|-n|-e|-on|-off\n"); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Turn on and off each individual system log, or globally on and off + */ +void +logging(UR_OBJECT user) +{ + char temp[ARR_SIZE]; + int cnt; + + if (word_count < 2) { + write_user(user, "Usage: logging -l|-s|-r|-n|-e|-on|-off\n"); + return; + } + strtolower(word[1]); + /* deal with listing the log status first */ + if (!strcmp(word[1], "-l")) { + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCSystem log status~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + sprintf(temp, + "General system log : ~OL%s~RS Account request logs : ~OL%s~RS Netlinks log : ~OL%s~RS", + amsys->logging & SYSLOG ? "ON " : "OFF", + amsys->logging & REQLOG ? "ON " : "OFF", + amsys->logging & NETLOG ? "ON " : "OFF"); + cnt = 74 + teslen(temp, 74); + vwrite_user(user, "| %-*.*s |\n", cnt, cnt, temp); + sprintf(temp, " Error log : ~OL%s~RS", + amsys->logging & ERRLOG ? "ON " : "OFF"); + cnt = 74 + teslen(temp, 74); + vwrite_user(user, "| %-*.*s |\n", cnt, cnt, temp); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + /* (un)set syslog bit */ + if (!strcmp(word[1], "-s")) { + /* if already on */ + if (amsys->logging & SYSLOG) { + write_syslog(SYSLOG, 1, "%s switched general system logging OFF.\n", + user->name); + } + amsys->logging ^= SYSLOG; + /* if now on */ + if (amsys->logging & SYSLOG) { + write_syslog(SYSLOG, 1, "%s switched general system logging ON.\n", + user->name); + } + vwrite_user(user, "You have now turned the general system logging %s.\n", + amsys->logging & SYSLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); + return; + } + /* (un)set reqlog bit */ + if (!strcmp(word[1], "-r")) { + /* if already on */ + if (amsys->logging & REQLOG) { + write_syslog(REQLOG, 1, "%s switched account request logging OFF.\n", + user->name); + } + amsys->logging ^= REQLOG; + /* if now on */ + if (amsys->logging & REQLOG) { + write_syslog(REQLOG, 1, "%s switched account request logging ON.\n", + user->name); + } + vwrite_user(user, "You have now turned the account request logging %s.\n", + amsys->logging & REQLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); + return; + } + /* (un)set netlog bit */ + if (!strcmp(word[1], "-n")) { +#ifdef NETLINKS + /* if already on */ + if (amsys->logging & NETLOG) { + write_syslog(NETLOG, 1, "%s switched netlink logging OFF.\n", + user->name); + } + amsys->logging ^= NETLOG; + /* if now on */ + if (amsys->logging & NETLOG) { + write_syslog(NETLOG, 1, "%s switched netlink logging ON.\n", + user->name); + } + vwrite_user(user, "You have now turned the netlink logging %s.\n", + amsys->logging & NETLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); +#else + write_user(user, "Netlinks are not currently active.\n"); +#endif + return; + } + /* (un)set errlog bit */ + if (!strcmp(word[1], "-e")) { + /* if already on */ + if (amsys->logging & ERRLOG) { + write_syslog(ERRLOG, 1, "%s switched error logging OFF.\n", user->name); + } + amsys->logging ^= ERRLOG; + /* if on already */ + if (amsys->logging & ERRLOG) { + write_syslog(REQLOG, 1, "%s switched error logging ON.\n", user->name); + } + vwrite_user(user, "You have now turned the error logging %s.\n", + amsys->logging & ERRLOG ? "~OL~FGON~RS" : "~OL~FROFF~RS"); + return; + } + /* set all bit */ + if (!strcmp(word[1], "-on")) { + if (!(amsys->logging & SYSLOG)) { + amsys->logging |= SYSLOG; + write_syslog(SYSLOG, 1, "%s switched general system logging ON.\n", + user->name); + } + if (!(amsys->logging & REQLOG)) { + amsys->logging |= REQLOG; + write_syslog(REQLOG, 1, "%s switched acount request logging ON.\n", + user->name); + } + if (!(amsys->logging & NETLOG)) { + amsys->logging |= NETLOG; + write_syslog(NETLOG, 1, "%s switched netlink logging ON.\n", + user->name); + } + if (!(amsys->logging & ERRLOG)) { + amsys->logging |= ERRLOG; + write_syslog(ERRLOG, 1, "%s switched error logging ON.\n", user->name); + } + write_user(user, "You have now turned all logging ~OL~FGON~RS.\n"); + return; + } + /* unset all bit */ + if (!strcmp(word[1], "-off")) { + if (amsys->logging & SYSLOG) { + write_syslog(SYSLOG, 1, "%s switched general system logging OFF.\n", + user->name); + amsys->logging &= ~SYSLOG; + } + if (amsys->logging & REQLOG) { + write_syslog(REQLOG, 1, "%s switched acount request logging OFF.\n", + user->name); + amsys->logging &= ~REQLOG; + } + if (amsys->logging & NETLOG) { + write_syslog(NETLOG, 1, "%s switched netlink logging OFF.\n", + user->name); + amsys->logging &= ~NETLOG; + } + if (amsys->logging & ERRLOG) { + write_syslog(ERRLOG, 1, "%s switched error logging OFF.\n", user->name); + amsys->logging &= ~ERRLOG; + } + write_user(user, "You have now turned all logging ~OL~FROFF~RS.\n"); + return; + } + write_user(user, "Usage: logging -l|-s|-r|-n|-e|-on|-off\n"); } \ No newline at end of file diff --git a/src/commands/look.c b/src/commands/look.c index 4bef36c..f621370 100644 --- a/src/commands/look.c +++ b/src/commands/look.c @@ -1,103 +1,105 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Display details of room - */ -void -look(UR_OBJECT user) -{ - char temp[81]; - RM_OBJECT rm; - UR_OBJECT u; - int i, exits, users; - - rm = user->room; - - if (is_private_room(rm)) { - vwrite_user(user, "\n~FCRoom: ~FR%s\n\n", - is_personal_room(rm) ? rm->show_name : rm->name); - } else { - vwrite_user(user, "\n~FCRoom: ~FG%s\n\n", - is_personal_room(rm) ? rm->show_name : rm->name); - } - if (user->show_rdesc) { - write_user(user, user->room->desc); - } - exits = 0; - strcpy(text, "\n~FCExits are:"); - for (i = 0; i < MAX_LINKS; ++i) { - if (!rm->link[i]) { - break; - } - if (is_private_room(rm->link[i])) { - sprintf(temp, " ~FR%s", rm->link[i]->name); - } else { - sprintf(temp, " ~FG%s", rm->link[i]->name); - } - strcat(text, temp); - ++exits; - } -#ifdef NETLINKS - if (rm->netlink && rm->netlink->stage == UP) { - if (rm->netlink->allow == IN) { - sprintf(temp, " ~FR%s*", rm->netlink->service); - } else { - sprintf(temp, " ~FG%s*", rm->netlink->service); - } - strcat(text, temp); - } else -#endif - if (!exits) { - strcpy(text, "\n~FCThere are no exits."); - } - strcat(text, "\n\n"); - write_user(user, text); - users = 0; - for (u = user_first; u; u = u->next) { - if (u->room != rm || u == user || (!u->vis && u->level > user->level)) { - continue; - } - if (!users++) { - write_user(user, "~FG~OLYou can see:\n"); - } - vwrite_user(user, " %s%s~RS %s~RS %s\n", u->vis ? " " : "~FR*~RS", - u->recap, u->desc, u->afk ? "~BR(AFK)" : ""); - } - if (!users) { - write_user(user, "~FGYou are all alone here.\n"); - } - write_user(user, "\n"); - strcpy(text, "Access is "); - if (is_personal_room(rm)) { - strcat(text, "personal "); - if (is_private_room(rm)) { - strcat(text, "~FR(locked)~RS"); - } else { - strcat(text, "~FG(unlocked)~RS"); - } - } else { - if (is_fixed_room(rm)) { - strcat(text, "~FRfixed~RS to "); - } else { - strcat(text, "set to "); - } - if (is_private_room(rm)) { - strcat(text, "~FRPRIVATE~RS"); - } else { - strcat(text, "~FGPUBLIC~RS"); - } - } - sprintf(temp, " and there %s ~OL~FM%d~RS message%s on the board.\n", - PLTEXT_IS(rm->mesg_cnt), rm->mesg_cnt, PLTEXT_S(rm->mesg_cnt)); - strcat(text, temp); - write_user(user, text); - if (*rm->topic) { - vwrite_user(user, "~FG~OLCurrent topic:~RS %s\n", rm->topic); - } else { - write_user(user, "~FGNo topic has been set yet.\n"); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Display details of room + */ +void +look(UR_OBJECT user) +{ + sds temp, text = sdsempty(); + RM_OBJECT rm; + UR_OBJECT u; + int i, exits, users; + + rm = user->room; + + if (is_private_room(rm)) { + vwrite_user(user, "\n~FCRoom: ~FR%s\n\n", + is_personal_room(rm) ? rm->show_name : rm->name); + } else { + vwrite_user(user, "\n~FCRoom: ~FG%s\n\n", + is_personal_room(rm) ? rm->show_name : rm->name); + } + if (user->show_rdesc) { + write_user(user, user->room->desc); + } + exits = 0; + text = sdscpy(text, "\n~FCExits are:"); + for (i = 0; i < MAX_LINKS; ++i) { + if (!rm->link[i]) { + break; + } + if (is_private_room(rm->link[i])) { + temp = sdscatfmt(sdsempty(), " ~FR%s", rm->link[i]->name); + } else { + temp = sdscatfmt(sdsempty(), " ~FG%s", rm->link[i]->name); + } + text = sdscat(text, temp); + ++exits; + } +#ifdef NETLINKS + if (rm->netlink && rm->netlink->stage == UP) { + if (rm->netlink->allow == IN) { + temp = sdscatfmt(sdsempty(), " ~FR%s*", rm->netlink->service); + } else { + temp = sdscatfmt(sdsempty(), " ~FG%s*", rm->netlink->service); + } + text = sdscat(text, temp); + } else +#endif + if (!exits) { + text = sdscpy(text, "\n~FCThere are no exits."); + } + text = sdscat(text, "\n\n"); + write_user(user, text); + users = 0; + for (u = user_first; u; u = u->next) { + if (u->room != rm || u == user || (!u->vis && u->level > user->level)) { + continue; + } + if (!users++) { + write_user(user, "~FG~OLYou can see:\n"); + } + vwrite_user(user, " %s%s~RS %s~RS %s\n", u->vis ? " " : "~FR*~RS", + u->recap, u->desc, u->afk ? "~BR(AFK)" : ""); + } + if (!users) { + write_user(user, "~FGYou are all alone here.\n"); + } + write_user(user, "\n"); + text = sdscpy(text, "Access is "); + if (is_personal_room(rm)) { + strcat(text, "personal "); + if (is_private_room(rm)) { + text = sdscat(text, "~FR(locked)~RS"); + } else { + text = sdscat(text, "~FG(unlocked)~RS"); + } + } else { + if (is_fixed_room(rm)) { + text = sdscat(text, "~FRfixed~RS to "); + } else { + text = sdscat(text, "set to "); + } + if (is_private_room(rm)) { + text = sdscat(text, "~FRPRIVATE~RS"); + } else { + text = sdscat(text, "~FGPUBLIC~RS"); + } + } + temp = sdscatprintf(sdsempty(), " and there %s ~OL~FM%d~RS message%s on the board.\n", + PLTEXT_IS(rm->mesg_cnt), rm->mesg_cnt, PLTEXT_S(rm->mesg_cnt)); + text = sdscat(text, temp); + write_user(user, text); + if (*rm->topic) { + vwrite_user(user, "~FG~OLCurrent topic:~RS %s\n", rm->topic); + } else { + write_user(user, "~FGNo topic has been set yet.\n"); + } + sdsfree(text); + sdsfree(temp); +} diff --git a/src/commands/macros.c b/src/commands/macros.c index fbc1b1e..3b63b49 100644 --- a/src/commands/macros.c +++ b/src/commands/macros.c @@ -1,26 +1,26 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Display user macros - */ -void -macros(UR_OBJECT user) -{ - int i; - -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - write_user(user, - "Due to software limitations, remote users cannot have macros.\n"); - return; - } -#endif - write_user(user, "Your current macros:\n"); - for (i = 0; i < 10; ++i) { - vwrite_user(user, " ~OL%d)~RS %s\n", i, user->macros[i]); - } + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Display user macros + */ +void +macros(UR_OBJECT user) +{ + int i; + +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + write_user(user, + "Due to software limitations, remote users cannot have macros.\n"); + return; + } +#endif + write_user(user, "Your current macros:\n"); + for (i = 0; i < 10; ++i) { + vwrite_user(user, " ~OL%d)~RS %s\n", i, user->macros[i]); + } } \ No newline at end of file diff --git a/src/commands/mail_from.c b/src/commands/mail_from.c index a02ddae..3b56313 100644 --- a/src/commands/mail_from.c +++ b/src/commands/mail_from.c @@ -1,43 +1,43 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show list of people your mail is from without seeing the whole lot - */ -void -mail_from(UR_OBJECT user) -{ - char w1[ARR_SIZE], line[ARR_SIZE], filename[80], *s; - FILE *fp; - int valid, cnt, tmp1, tmp2, nmail; - - sprintf(filename, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); - fp = fopen(filename, "r"); - if (!fp) { - write_user(user, "You have no mail.\n"); - return; - } - write_user(user, "\n~BB*** Mail from ***\n\n"); - valid = 1; - cnt = 0; - fscanf(fp, "%d %d\r", &tmp1, &tmp2); - for (s = fgets(line, ARR_SIZE - 1, fp); s; - s = fgets(line, ARR_SIZE - 1, fp)) { - if (*s == '\n') { - valid = 1; - } - sscanf(s, "%s", w1); - if (valid && !strcmp(colour_com_strip(w1), "From:")) { - vwrite_user(user, "~FC%2d)~RS %s", ++cnt, remove_first(s)); - valid = 0; - } - } - fclose(fp); - nmail = mail_sizes(user->name, 1); - vwrite_user(user, - "\nTotal of ~OL%d~RS message%s, ~OL%d~RS of which %s new.\n\n", - cnt, PLTEXT_S(cnt), nmail, PLTEXT_IS(nmail)); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show list of people your mail is from without seeing the whole lot + */ +void +mail_from(UR_OBJECT user) +{ + char w1[ARR_SIZE], line[ARR_SIZE], filename[80], *s; + FILE *fp; + int valid, cnt, tmp1, tmp2, nmail; + + sprintf(filename, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); + fp = fopen(filename, "r"); + if (!fp) { + write_user(user, "You have no mail.\n"); + return; + } + write_user(user, "\n~BB*** Mail from ***\n\n"); + valid = 1; + cnt = 0; + fscanf(fp, "%d %d\r", &tmp1, &tmp2); + for (s = fgets(line, ARR_SIZE - 1, fp); s; + s = fgets(line, ARR_SIZE - 1, fp)) { + if (*s == '\n') { + valid = 1; + } + sscanf(s, "%s", w1); + if (valid && !strcmp(colour_com_strip(w1), "From:")) { + vwrite_user(user, "~FC%2d)~RS %s", ++cnt, remove_first(s)); + valid = 0; + } + } + fclose(fp); + nmail = mail_sizes(user->name, 1); + vwrite_user(user, + "\nTotal of ~OL%d~RS message%s, ~OL%d~RS of which %s new.\n\n", + cnt, PLTEXT_S(cnt), nmail, PLTEXT_IS(nmail)); +} diff --git a/src/commands/minlogin.c b/src/commands/minlogin.c index 26cd49a..d7091ee 100644 --- a/src/commands/minlogin.c +++ b/src/commands/minlogin.c @@ -1,91 +1,91 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set minlogin level - */ -void -minlogin(UR_OBJECT user) -{ - static const char usage[] = "Usage: minlogin -a|-n|\n"; - const char *levstr; - const char *name; - UR_OBJECT u, next; - int cnt; - enum lvl_value lvl; - - if (word_count < 2) { - write_user(user, usage); - if (amsys->stop_logins) { - write_user(user, "Currently set to ALL\n"); - } else if (amsys->minlogin_level == NUM_LEVELS) { - write_user(user, "Currently set to NONE\n"); - } else { - vwrite_user(user, "Currently set to %s\n", - user_level[amsys->minlogin_level].name); - } - return; - } - if (!strcasecmp(word[1], "-a")) { - amsys->stop_logins = 1; - write_user(user, "You have now stopped all logins on the user port.\n"); - return; - } - if (!strcasecmp(word[1], "-n")) { - amsys->stop_logins = 0; - amsys->minlogin_level = NUM_LEVELS; - write_user(user, "You have now removed the minlogin level.\n"); - return; - } - lvl = get_level(word[1]); - if (lvl == NUM_LEVELS) { - write_user(user, usage); - if (amsys->stop_logins) { - write_user(user, "Currently set to ALL\n"); - } else if (amsys->minlogin_level == NUM_LEVELS) { - write_user(user, "Currently set to NONE\n"); - } else { - vwrite_user(user, "Currently set to %s\n", - user_level[amsys->minlogin_level].name); - } - return; - } else { - levstr = user_level[lvl].name; - } - if (lvl > user->level) { - write_user(user, - "You cannot set minlogin to a higher level than your own.\n"); - return; - } - if (amsys->minlogin_level == lvl) { - write_user(user, "It is already set to that level.\n"); - return; - } - amsys->minlogin_level = lvl; - vwrite_user(user, "Minlogin level set to: ~OL%s.\n", levstr); - name = user->vis ? user->name : invisname; - vwrite_room_except(NULL, user, "%s has set the minlogin level to: ~OL%s.\n", - name, levstr); - write_syslog(SYSLOG, 1, "%s set the minlogin level to %s.\n", user->name, - levstr); - /* Now boot off anyone below that level */ - cnt = 0; - if (amsys->boot_off_min) { - for (u = user_first; u; u = next) { - next = u->next; - if (!u->login && u->type != CLONE_TYPE && u->level < lvl) { - write_user(u, - "\n~FY~OLYour level is now below the minlogin level, disconnecting you...\n"); - disconnect_user(u); - ++cnt; - } - } - } - if (cnt) { - vwrite_user(user, "Total of ~OL%d~RS users were disconnected.\n", cnt); - } - destructed = 0; + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set minlogin level + */ +void +minlogin(UR_OBJECT user) +{ + static const char usage[] = "Usage: minlogin -a|-n|\n"; + const char *levstr; + const char *name; + UR_OBJECT u, next; + int cnt; + enum lvl_value lvl; + + if (word_count < 2) { + write_user(user, usage); + if (amsys->stop_logins) { + write_user(user, "Currently set to ALL\n"); + } else if (amsys->minlogin_level == NUM_LEVELS) { + write_user(user, "Currently set to NONE\n"); + } else { + vwrite_user(user, "Currently set to %s\n", + user_level[amsys->minlogin_level].name); + } + return; + } + if (!strcasecmp(word[1], "-a")) { + amsys->stop_logins = 1; + write_user(user, "You have now stopped all logins on the user port.\n"); + return; + } + if (!strcasecmp(word[1], "-n")) { + amsys->stop_logins = 0; + amsys->minlogin_level = NUM_LEVELS; + write_user(user, "You have now removed the minlogin level.\n"); + return; + } + lvl = get_level(word[1]); + if (lvl == NUM_LEVELS) { + write_user(user, usage); + if (amsys->stop_logins) { + write_user(user, "Currently set to ALL\n"); + } else if (amsys->minlogin_level == NUM_LEVELS) { + write_user(user, "Currently set to NONE\n"); + } else { + vwrite_user(user, "Currently set to %s\n", + user_level[amsys->minlogin_level].name); + } + return; + } else { + levstr = user_level[lvl].name; + } + if (lvl > user->level) { + write_user(user, + "You cannot set minlogin to a higher level than your own.\n"); + return; + } + if (amsys->minlogin_level == lvl) { + write_user(user, "It is already set to that level.\n"); + return; + } + amsys->minlogin_level = lvl; + vwrite_user(user, "Minlogin level set to: ~OL%s.\n", levstr); + name = user->vis ? user->name : invisname; + vwrite_room_except(NULL, user, "%s has set the minlogin level to: ~OL%s.\n", + name, levstr); + write_syslog(SYSLOG, 1, "%s set the minlogin level to %s.\n", user->name, + levstr); + /* Now boot off anyone below that level */ + cnt = 0; + if (amsys->boot_off_min) { + for (u = user_first; u; u = next) { + next = u->next; + if (!u->login && u->type != CLONE_TYPE && u->level < lvl) { + write_user(u, + "\n~FY~OLYour level is now below the minlogin level, disconnecting you...\n"); + disconnect_user(u); + ++cnt; + } + } + } + if (cnt) { + vwrite_user(user, "Total of ~OL%d~RS users were disconnected.\n", cnt); + } + destructed = 0; } \ No newline at end of file diff --git a/src/commands/mkinvis.c b/src/commands/mkinvis.c index df9fb78..360c9d6 100644 --- a/src/commands/mkinvis.c +++ b/src/commands/mkinvis.c @@ -1,42 +1,42 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Force a user to become invisible - */ -void -make_invis(UR_OBJECT user) -{ - UR_OBJECT user2; - - if (word_count < 2) { - write_user(user, "Usage: makeinvis \n"); - return; - } - user2 = get_user_name(user, word[1]); - if (!user2) { - write_user(user, notloggedon); - return; - } - if (user == user2) { - write_user(user, "There is an easier way to make yourself invisible!\n"); - return; - } - if (!user2->vis) { - vwrite_user(user, "%s~RS is already invisible.\n", user2->recap); - return; - } - if (user2->level > user->level) { - vwrite_user(user, "%s~RS cannot be forced invisible.\n", user2->recap); - return; - } - user2->vis = 0; - vwrite_user(user, "You force %s~RS to become invisible.\n", user2->recap); - write_user(user2, "You have been forced to become invisible.\n"); - vwrite_room_except(user2->room, user2, - "You see %s~RS mysteriously disappear into the shadows!\n", - user2->recap); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Force a user to become invisible + */ +void +make_invis(UR_OBJECT user) +{ + UR_OBJECT user2; + + if (word_count < 2) { + write_user(user, "Usage: makeinvis \n"); + return; + } + user2 = get_user_name(user, word[1]); + if (!user2) { + write_user(user, notloggedon); + return; + } + if (user == user2) { + write_user(user, "There is an easier way to make yourself invisible!\n"); + return; + } + if (!user2->vis) { + vwrite_user(user, "%s~RS is already invisible.\n", user2->recap); + return; + } + if (user2->level > user->level) { + vwrite_user(user, "%s~RS cannot be forced invisible.\n", user2->recap); + return; + } + user2->vis = 0; + vwrite_user(user, "You force %s~RS to become invisible.\n", user2->recap); + write_user(user2, "You have been forced to become invisible.\n"); + vwrite_room_except(user2->room, user2, + "You see %s~RS mysteriously disappear into the shadows!\n", + user2->recap); +} diff --git a/src/commands/mkvis.c b/src/commands/mkvis.c index 3aae1f1..efc5f19 100644 --- a/src/commands/mkvis.c +++ b/src/commands/mkvis.c @@ -1,43 +1,43 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Force a user to become visible - */ -void -make_vis(UR_OBJECT user) -{ - UR_OBJECT user2; - - if (word_count < 2) { - write_user(user, "Usage: makevis \n"); - return; - } - user2 = get_user_name(user, word[1]); - if (!user2) { - write_user(user, notloggedon); - return; - } - if (user == user2) { - write_user(user, "There is an easier way to make yourself visible!\n"); - return; - } - if (user2->vis) { - vwrite_user(user, "%s~RS is already visible.\n", user2->recap); - return; - } - if (user2->level > user->level) { - vwrite_user(user, "%s~RS cannot be forced visible.\n", user2->recap); - return; - } - user2->vis = 1; - vwrite_user(user, "You force %s~RS to become visible.\n", user2->recap); - write_user(user2, "You have been forced to become visible.\n"); - vwrite_room_except(user2->room, user2, - "You see %s~RS mysteriously emerge from the shadows!\n", - user2->recap); -} - + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Force a user to become visible + */ +void +make_vis(UR_OBJECT user) +{ + UR_OBJECT user2; + + if (word_count < 2) { + write_user(user, "Usage: makevis \n"); + return; + } + user2 = get_user_name(user, word[1]); + if (!user2) { + write_user(user, notloggedon); + return; + } + if (user == user2) { + write_user(user, "There is an easier way to make yourself visible!\n"); + return; + } + if (user2->vis) { + vwrite_user(user, "%s~RS is already visible.\n", user2->recap); + return; + } + if (user2->level > user->level) { + vwrite_user(user, "%s~RS cannot be forced visible.\n", user2->recap); + return; + } + user2->vis = 1; + vwrite_user(user, "You force %s~RS to become visible.\n", user2->recap); + write_user(user2, "You have been forced to become visible.\n"); + vwrite_room_except(user2->room, user2, + "You see %s~RS mysteriously emerge from the shadows!\n", + user2->recap); +} + diff --git a/src/commands/morph.c b/src/commands/morph.c index 586e6b3..99cee2c 100644 --- a/src/commands/morph.c +++ b/src/commands/morph.c @@ -2,6 +2,9 @@ #include "globals.h" #include "commands.h" #include "prototypes.h" +#ifndef __SDS_H +#include "../vendors/sds/sds.h" +#endif /* * Change a user name from their existing one to whatever @@ -126,7 +129,7 @@ change_user_name(UR_OBJECT user) /* change last_login info so that old name if offline */ record_last_logout(oldname); record_last_login(newname); - /* all memory occurences should be done. now do files */ + /* all memory occurrences should be done. now do files */ oldfile = sdscatfmt(sdsempty(), "%s/%s.D", USERFILES, oldname); newfile = sdscatfmt(sdsempty(), "%s/%s.D", USERFILES, newname); rename(oldfile, newfile); diff --git a/src/commands/move.c b/src/commands/move.c index 67b23e0..6ef49b4 100644 --- a/src/commands/move.c +++ b/src/commands/move.c @@ -1,68 +1,68 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Wizard moves a user to another room - */ -void -move(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - const char *name; - - if (word_count < 2) { - write_user(user, "Usage: move []\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u->login) { - write_user(user, "That user is not logged in.\n"); - return; - } - if (word_count < 3) { - rm = user->room; - } else { - rm = get_room(word[2]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - } - if (user == u) { - write_user(user, - "Trying to move yourself this way is the fourth sign of madness.\n"); - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot move a user of equal or higher level than yourself.\n"); - return; - } - if (rm == u->room) { - vwrite_user(user, "%s~RS is already in the %s.\n", u->recap, rm->name); - return; - }; - if (!has_room_access(user, rm)) { - vwrite_user(user, - "The %s is currently private, %s~RS cannot be moved there.\n", - rm->name, u->recap); - return; - } - write_user(user, "~FC~OLYou chant an ancient spell...\n"); - name = user->vis ? user->recap : invisname; - if (!user->vis) { - write_monitor(user, user->room, 0); - } - vwrite_room_except(user->room, user, - "%s~RS ~FC~OLchants an ancient spell...\n", name); - move_user(u, rm, 2); - prompt(u); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Wizard moves a user to another room + */ +void +move(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + const char *name; + + if (word_count < 2) { + write_user(user, "Usage: move []\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u->login) { + write_user(user, "That user is not logged in.\n"); + return; + } + if (word_count < 3) { + rm = user->room; + } else { + rm = get_room(word[2]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + } + if (user == u) { + write_user(user, + "Trying to move yourself this way is the fourth sign of madness.\n"); + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot move a user of equal or higher level than yourself.\n"); + return; + } + if (rm == u->room) { + vwrite_user(user, "%s~RS is already in the %s.\n", u->recap, rm->name); + return; + }; + if (!has_room_access(user, rm)) { + vwrite_user(user, + "The %s is currently private, %s~RS cannot be moved there.\n", + rm->name, u->recap); + return; + } + write_user(user, "~FC~OLYou chant an ancient spell...\n"); + name = user->vis ? user->recap : invisname; + if (!user->vis) { + write_monitor(user, user->room, 0); + } + vwrite_room_except(user->room, user, + "%s~RS ~FC~OLchants an ancient spell...\n", name); + move_user(u, rm, 2); + prompt(u); +} diff --git a/src/commands/mutter.c b/src/commands/mutter.c index a74c1bd..6b3de5c 100644 --- a/src/commands/mutter.c +++ b/src/commands/mutter.c @@ -1,71 +1,71 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Tell something to everyone but one person - */ -void -mutter(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: mutter \n"; - const char *type; - const char *name, *n; - UR_OBJECT u; - - if (word_count < 3) { - write_user(user, usage); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "Talking about yourself is a sign of madness!\n"); - return; - } - if (user->room != u->room || (!u->vis && user->level < u->level)) { - vwrite_user(user, "You cannot see %s~RS, so speak freely of them.\n", - u->recap); - return; - } - inpstr = remove_first(inpstr); - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_private_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - type = smiley_type(inpstr); - if (!type) { - type = "mutter"; - } - if (!user->vis) { - write_monitor(user, user->room, 0); - } - name = user->vis ? user->recap : invisname; - n = u->vis ? u->recap : invisname; - sprintf(text, "(NOT %s~RS) %s~RS ~FC%ss~RS: %s\n", n, name, type, - inpstr); -#if !!0 - record(user->room, text); -#endif - write_room_except_both(user->room, text, user, u); - vwrite_user(user, "(NOT %s~RS) You ~FC%s~RS: %s\n", u->recap, type, - inpstr); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Tell something to everyone but one person + */ +void +mutter(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: mutter \n"; + const char *type; + const char *name, *n; + UR_OBJECT u; + + if (word_count < 3) { + write_user(user, usage); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "Talking about yourself is a sign of madness!\n"); + return; + } + if (user->room != u->room || (!u->vis && user->level < u->level)) { + vwrite_user(user, "You cannot see %s~RS, so speak freely of them.\n", + u->recap); + return; + } + inpstr = remove_first(inpstr); + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_private_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + type = smiley_type(inpstr); + if (!type) { + type = "mutter"; + } + if (!user->vis) { + write_monitor(user, user->room, 0); + } + name = user->vis ? user->recap : invisname; + n = u->vis ? u->recap : invisname; + sprintf(text, "(NOT %s~RS) %s~RS ~FC%ss~RS: %s\n", n, name, type, + inpstr); +#if !!0 + record(user->room, text); +#endif + write_room_except_both(user->room, text, user, u); + vwrite_user(user, "(NOT %s~RS) You ~FC%s~RS: %s\n", u->recap, type, + inpstr); +} diff --git a/src/commands/muzzle.c b/src/commands/muzzle.c index 9879e63..5d739c5 100644 --- a/src/commands/muzzle.c +++ b/src/commands/muzzle.c @@ -1,65 +1,65 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Muzzle an annoying user so he cant speak, emote, echo, write, smail - * or bcast. Muzzles have levels from WIZ to GOD so for instance a wiz - * cannot remove a muzzle set by a god - */ -void -muzzle(UR_OBJECT user) -{ - UR_OBJECT u; - int on; - - if (word_count < 2) { - write_user(user, "Usage: muzzle \n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - /* error checks */ - if (u == user) { - write_user(user, - "Trying to muzzle yourself is the ninth sign of madness.\n"); - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot muzzle a user of equal or higher level than yourself.\n"); - done_retrieve(u); - return; - } - if (u->muzzled >= user->level) { - vwrite_user(user, "%s~RS is already muzzled.\n", u->recap); - done_retrieve(u); - return; - } - /* do the muzzle */ - u->muzzled = user->level; - vwrite_user(user, "~FR~OL%s now has a muzzle of level: ~RS~OL%s.\n", - u->bw_recap, user_level[user->level].name); - write_syslog(SYSLOG, 1, "%s muzzled %s (level %d).\n", user->name, u->name, - user->level); - add_history(u->name, 1, "Level %d (%s) ~FRmuzzle~RS put on by %s.\n", - user->level, user_level[user->level].name, user->name); - sprintf(text, "~FR~OLYou have been muzzled!\n"); - if (!on) { - send_mail(user, u->name, text, 0); - } else { - write_user(u, text); - } - /* finish up */ - if (!on) { - strcpy(u->site, u->last_site); - u->socket = -2; - } - save_user_details(u, on); - done_retrieve(u); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Muzzle an annoying user so he cant speak, emote, echo, write, smail + * or bcast. Muzzles have levels from WIZ to GOD so for instance a wiz + * cannot remove a muzzle set by a god + */ +void +muzzle(UR_OBJECT user) +{ + UR_OBJECT u; + int on; + + if (word_count < 2) { + write_user(user, "Usage: muzzle \n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + /* error checks */ + if (u == user) { + write_user(user, + "Trying to muzzle yourself is the ninth sign of madness.\n"); + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot muzzle a user of equal or higher level than yourself.\n"); + done_retrieve(u); + return; + } + if (u->muzzled >= user->level) { + vwrite_user(user, "%s~RS is already muzzled.\n", u->recap); + done_retrieve(u); + return; + } + /* do the muzzle */ + u->muzzled = user->level; + vwrite_user(user, "~FR~OL%s now has a muzzle of level: ~RS~OL%s.\n", + u->bw_recap, user_level[user->level].name); + write_syslog(SYSLOG, 1, "%s muzzled %s (level %d).\n", user->name, u->name, + user->level); + add_history(u->name, 1, "Level %d (%s) ~FRmuzzle~RS put on by %s.\n", + user->level, user_level[user->level].name, user->name); + sprintf(text, "~FR~OLYou have been muzzled!\n"); + if (!on) { + send_mail(user, u->name, text, 0); + } else { + write_user(u, text); + } + /* finish up */ + if (!on) { + strcpy(u->site, u->last_site); + u->socket = -2; + } + save_user_details(u, on); + done_retrieve(u); } \ No newline at end of file diff --git a/src/commands/myclones.c b/src/commands/myclones.c index df6a4a4..eb61892 100644 --- a/src/commands/myclones.c +++ b/src/commands/myclones.c @@ -1,31 +1,31 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show users own clones - */ -void -myclones(UR_OBJECT user) -{ - UR_OBJECT u; - int cnt; - - cnt = 0; - for (u = user_first; u; u = u->next) { - if (u->type != CLONE_TYPE || u->owner != user) { - continue; - } - if (!cnt++) { - write_user(user, "\n~BB*** Rooms you have clones in ***\n\n"); - } - vwrite_user(user, " %s\n", u->room->name); - } - if (!cnt) { - write_user(user, "You have no clones.\n"); - } else { - vwrite_user(user, "\nTotal of ~OL%d~RS clone%s.\n\n", cnt, PLTEXT_S(cnt)); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show users own clones + */ +void +myclones(UR_OBJECT user) +{ + UR_OBJECT u; + int cnt; + + cnt = 0; + for (u = user_first; u; u = u->next) { + if (u->type != CLONE_TYPE || u->owner != user) { + continue; + } + if (!cnt++) { + write_user(user, "\n~BB*** Rooms you have clones in ***\n\n"); + } + vwrite_user(user, " %s\n", u->room->name); + } + if (!cnt) { + write_user(user, "You have no clones.\n"); + } else { + vwrite_user(user, "\nTotal of ~OL%d~RS clone%s.\n\n", cnt, PLTEXT_S(cnt)); + } +} diff --git a/src/commands/myroom.c b/src/commands/myroom.c index 2507388..7504f4c 100644 --- a/src/commands/myroom.c +++ b/src/commands/myroom.c @@ -1,94 +1,94 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * lets a user enter their own room. It creates the room if !exists - */ -void -personal_room(UR_OBJECT user) -{ - char rmname[ROOM_NAME_LEN + 1], filename[80]; - UR_OBJECT u; - RM_OBJECT rm; - - if (!amsys->personal_rooms) { - write_user(user, "Personal room functions are currently disabled.\n"); - return; - } - sprintf(rmname, "(%s)", user->name); - strtolower(rmname); - rm = get_room_full(rmname); - /* if the user wants to delete their room */ - if (word_count >= 2) { - if (strcmp(word[1], "-d")) { - write_user(user, "Usage: myroom [-d]\n"); - return; - } - /* move to the user out of the room if they are in it */ - if (!rm) { - write_user(user, "You do not have a personal room built.\n"); - return; - } - if (room_visitor_count(rm)) { - write_user(user, - "You cannot destroy your room if any people are in it.\n"); - return; - } - write_user(user, - "~OL~FRYou whistle a sharp spell and watch your room crumble into dust.\n"); - /* remove invites */ - for (u = user_first; u; u = u->next) { - if (u->invite_room == rm) { - u->invite_room = NULL; - } - } - /* remove all the key flags */ - write_user(user, "~OL~FRAll keys to your room crumble to ashes.\n"); - all_unsetbit_flagged_user_entry(user, fufROOMKEY); - /* destroy */ - destruct_room(rm); - /* delete the files */ - sprintf(filename, "%s/%s/%s.R", USERFILES, USERROOMS, user->name); - remove(filename); - sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, user->name); - remove(filename); - sprintf(filename, "%s/%s/%s.K", USERFILES, USERROOMS, user->name); - remove(filename); - write_syslog(SYSLOG, 1, "%s destructed their personal room.\n", - user->name); - return; - } - /* if the user is moving to their room */ - if (user->lroom == 2) { - write_user(user, "You have been shackled and cannot move.\n"); - return; - } - /* if room does not exist then create it */ - if (!rm) { - rm = create_room(); - if (!rm) { - write_user(user, - "Sorry, but your room cannot be created at this time.\n"); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Cannot create room for in personal_room()\n"); - return; - } - write_user(user, "\nYour room does not exists. Building it now...\n\n"); - /* check to see if the room was just unloaded from memory first */ - if (!personal_room_store(user->name, 0, rm)) { - write_syslog(SYSLOG, 1, "%s creates their own room.\n", user->name); - if (!personal_room_store(user->name, 1, rm)) { - write_syslog(SYSLOG | ERRLOG, 1, - "ERROR: Unable to save personal room status in personal_room()\n"); - } - } - } - /* if room just created then should not go in his block */ - if (user->room == rm) { - write_user(user, "You are already in your own room!\n"); - return; - } - move_user(user, rm, 1); +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * lets a user enter their own room. It creates the room if !exists + */ +void +personal_room(UR_OBJECT user) +{ + char rmname[ROOM_NAME_LEN + 1], filename[80]; + UR_OBJECT u; + RM_OBJECT rm; + + if (!amsys->personal_rooms) { + write_user(user, "Personal room functions are currently disabled.\n"); + return; + } + sprintf(rmname, "(%s)", user->name); + strtolower(rmname); + rm = get_room_full(rmname); + /* if the user wants to delete their room */ + if (word_count >= 2) { + if (strcmp(word[1], "-d")) { + write_user(user, "Usage: myroom [-d]\n"); + return; + } + /* move to the user out of the room if they are in it */ + if (!rm) { + write_user(user, "You do not have a personal room built.\n"); + return; + } + if (room_visitor_count(rm)) { + write_user(user, + "You cannot destroy your room if any people are in it.\n"); + return; + } + write_user(user, + "~OL~FRYou whistle a sharp spell and watch your room crumble into dust.\n"); + /* remove invites */ + for (u = user_first; u; u = u->next) { + if (u->invite_room == rm) { + u->invite_room = NULL; + } + } + /* remove all the key flags */ + write_user(user, "~OL~FRAll keys to your room crumble to ashes.\n"); + all_unsetbit_flagged_user_entry(user, fufROOMKEY); + /* destroy */ + destruct_room(rm); + /* delete the files */ + sprintf(filename, "%s/%s/%s.R", USERFILES, USERROOMS, user->name); + remove(filename); + sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, user->name); + remove(filename); + sprintf(filename, "%s/%s/%s.K", USERFILES, USERROOMS, user->name); + remove(filename); + write_syslog(SYSLOG, 1, "%s destructed their personal room.\n", + user->name); + return; + } + /* if the user is moving to their room */ + if (user->lroom == 2) { + write_user(user, "You have been shackled and cannot move.\n"); + return; + } + /* if room does not exist then create it */ + if (!rm) { + rm = create_room(); + if (!rm) { + write_user(user, + "Sorry, but your room cannot be created at this time.\n"); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Cannot create room for in personal_room()\n"); + return; + } + write_user(user, "\nYour room does not exists. Building it now...\n\n"); + /* check to see if the room was just unloaded from memory first */ + if (!personal_room_store(user->name, 0, rm)) { + write_syslog(SYSLOG, 1, "%s creates their own room.\n", user->name); + if (!personal_room_store(user->name, 1, rm)) { + write_syslog(SYSLOG | ERRLOG, 1, + "ERROR: Unable to save personal room status in personal_room()\n"); + } + } + } + /* if room just created then should not go in his block */ + if (user->room == rm) { + write_user(user, "You are already in your own room!\n"); + return; + } + move_user(user, rm, 1); } \ No newline at end of file diff --git a/src/commands/myroom_admin.c b/src/commands/myroom_admin.c index 9bdb6a1..f680658 100644 --- a/src/commands/myroom_admin.c +++ b/src/commands/myroom_admin.c @@ -2,6 +2,9 @@ #include "globals.h" #include "commands.h" #include "prototypes.h" +#ifndef __SDS_H +#include "../vendors/sds/sds.h" +#endif /* * this function allows admin to control personal rooms diff --git a/src/commands/myroom_bgone.c b/src/commands/myroom_bgone.c index 9ce0cd6..63e1c75 100644 --- a/src/commands/myroom_bgone.c +++ b/src/commands/myroom_bgone.c @@ -1,66 +1,66 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * allow a user to bump others from their personal room - */ -void -personal_room_bgone(UR_OBJECT user) -{ - RM_OBJECT rm; - UR_OBJECT u; - - if (!amsys->personal_rooms) { - write_user(user, "Personal room functions are currently disabled.\n"); - return; - } - if (word_count < 2) { - write_user(user, "Usage: mybgone /all\n"); - return; - } - if (strcmp(user->room->owner, user->name)) { - write_user(user, - "You have to be in your personal room to bounce people from it.\n"); - return; - } - /* get room to bounce people to */ - rm = get_room_full(amsys->default_warp); - if (!rm) { - write_user(user, - "No one can be bounced from your personal room at this time.\n"); - return; - } - strtolower(word[1]); - /* bounce everyone out - except GODS */ - if (!strcmp(word[1], "all")) { - for (u = user_first; u; u = u->next) { - if (u == user || u->room != user->room || u->level == GOD) { - continue; - } - vwrite_user(user, "%s~RS is forced to leave the room.\n", u->recap); - write_user(u, "You are being forced to leave the room.\n"); - move_user(u, rm, 0); - } - return; - } - /* send out just the one user */ - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u->room != user->room) { - vwrite_user(user, "%s~RS is not in your personal room.\n", u->recap); - return; - } - if (u->level == GOD) { - vwrite_user(user, "%s~RS cannot be forced to leave your personal room.\n", - u->recap); - return; - } - vwrite_user(user, "%s~RS is forced to leave the room.\n", u->recap); - write_user(u, "You are being forced to leave the room.\n"); - move_user(u, rm, 0); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * allow a user to bump others from their personal room + */ +void +personal_room_bgone(UR_OBJECT user) +{ + RM_OBJECT rm; + UR_OBJECT u; + + if (!amsys->personal_rooms) { + write_user(user, "Personal room functions are currently disabled.\n"); + return; + } + if (word_count < 2) { + write_user(user, "Usage: mybgone /all\n"); + return; + } + if (strcmp(user->room->owner, user->name)) { + write_user(user, + "You have to be in your personal room to bounce people from it.\n"); + return; + } + /* get room to bounce people to */ + rm = get_room_full(amsys->default_warp); + if (!rm) { + write_user(user, + "No one can be bounced from your personal room at this time.\n"); + return; + } + strtolower(word[1]); + /* bounce everyone out - except GODS */ + if (!strcmp(word[1], "all")) { + for (u = user_first; u; u = u->next) { + if (u == user || u->room != user->room || u->level == GOD) { + continue; + } + vwrite_user(user, "%s~RS is forced to leave the room.\n", u->recap); + write_user(u, "You are being forced to leave the room.\n"); + move_user(u, rm, 0); + } + return; + } + /* send out just the one user */ + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u->room != user->room) { + vwrite_user(user, "%s~RS is not in your personal room.\n", u->recap); + return; + } + if (u->level == GOD) { + vwrite_user(user, "%s~RS cannot be forced to leave your personal room.\n", + u->recap); + return; + } + vwrite_user(user, "%s~RS is forced to leave the room.\n", u->recap); + write_user(u, "You are being forced to leave the room.\n"); + move_user(u, rm, 0); +} diff --git a/src/commands/myroom_key.c b/src/commands/myroom_key.c index 9d46422..94a3bf7 100644 --- a/src/commands/myroom_key.c +++ b/src/commands/myroom_key.c @@ -1,126 +1,126 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * this function allows users to give access to others even if their personal room - * has been locked - */ -void -personal_room_key(UR_OBJECT user) -{ - RM_OBJECT rm; - FU_OBJECT fu; - - if (!amsys->personal_rooms) { - write_user(user, "Personal room functions are currently disabled.\n"); - return; - } - - /* if no name was given then display keys given */ - if (word_count < 2) { - char text2[ARR_SIZE]; - int found = 0, cnt = 0; - - *text2 = '\0'; - for (fu = user->fu_first; fu; fu = fu->next) { - if (fu->flags & fufROOMKEY) { - if (!found++) { - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCYou have given the following people a key to your room~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } - switch (++cnt) { - case 1: - sprintf(text, "| %-24s", fu->name); - strcat(text2, text); - break; - case 2: - sprintf(text, " %-24s", fu->name); - strcat(text2, text); - break; - default: - sprintf(text, " %-24s |\n", fu->name); - strcat(text2, text); - write_user(user, text2); - cnt = 0; - *text2 = '\0'; - break; - } - } - } - if (!found) { - write_user(user, - "You have not given anyone a personal room key yet.\n"); - return; - } - if (cnt == 1) { - strcat(text2, " |\n"); - write_user(user, text2); - } else if (cnt == 2) { - strcat(text2, " |\n"); - write_user(user, text2); - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - return; - } - - { - char rmname[ROOM_NAME_LEN + 1]; - - /* see if user has a room created */ - sprintf(rmname, "(%s)", user->name); - strtolower(rmname); - rm = get_room_full(rmname); - if (!rm) { - write_user(user, - "Sorry, but you have not created a personal room yet.\n"); - return; - } - } - - /* actually add/remove a user */ - strtolower(word[1]); - *word[1] = toupper(*word[1]); - if (!strcmp(user->name, word[1])) { - write_user(user, "You already have access to your own room!\n"); - return; - } - /* - * check to see if the user is already listed before the adding part. - * This is to ensure you can remove a user even if they have, for - * instance, suicided. - */ - if (has_room_key(word[1], rm)) { - if (!personal_key_remove(user, word[1])) { - write_user(user, - "There was an error taking the key away from that user.\n"); - return; - } - vwrite_user(user, - "You take your personal room key away from ~FC~OL%s~RS.\n", - word[1]); - vwrite_user(get_user(word[1]), "%s takes back their personal room key.\n", - user->name); - } else { - /* see if there is such a user */ - if (!find_user_listed(word[1])) { - write_user(user, nosuchuser); - return; - } - /* give them a key */ - if (!personal_key_add(user, word[1])) { - write_user(user, "There was an error giving the key to that user.\n"); - return; - } - vwrite_user(user, "You give ~FC~OL%s~RS a key to your personal room.\n", - word[1]); - vwrite_user(get_user(word[1]), "%s gives you a key to their room.\n", - user->name); - } -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * this function allows users to give access to others even if their personal room + * has been locked + */ +void +personal_room_key(UR_OBJECT user) +{ + RM_OBJECT rm; + FU_OBJECT fu; + + if (!amsys->personal_rooms) { + write_user(user, "Personal room functions are currently disabled.\n"); + return; + } + + /* if no name was given then display keys given */ + if (word_count < 2) { + char text2[ARR_SIZE]; + int found = 0, cnt = 0; + + *text2 = '\0'; + for (fu = user->fu_first; fu; fu = fu->next) { + if (fu->flags & fufROOMKEY) { + if (!found++) { + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCYou have given the following people a key to your room~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } + switch (++cnt) { + case 1: + sprintf(text, "| %-24s", fu->name); + strcat(text2, text); + break; + case 2: + sprintf(text, " %-24s", fu->name); + strcat(text2, text); + break; + default: + sprintf(text, " %-24s |\n", fu->name); + strcat(text2, text); + write_user(user, text2); + cnt = 0; + *text2 = '\0'; + break; + } + } + } + if (!found) { + write_user(user, + "You have not given anyone a personal room key yet.\n"); + return; + } + if (cnt == 1) { + strcat(text2, " |\n"); + write_user(user, text2); + } else if (cnt == 2) { + strcat(text2, " |\n"); + write_user(user, text2); + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + return; + } + + { + char rmname[ROOM_NAME_LEN + 1]; + + /* see if user has a room created */ + sprintf(rmname, "(%s)", user->name); + strtolower(rmname); + rm = get_room_full(rmname); + if (!rm) { + write_user(user, + "Sorry, but you have not created a personal room yet.\n"); + return; + } + } + + /* actually add/remove a user */ + strtolower(word[1]); + *word[1] = toupper(*word[1]); + if (!strcmp(user->name, word[1])) { + write_user(user, "You already have access to your own room!\n"); + return; + } + /* + * check to see if the user is already listed before the adding part. + * This is to ensure you can remove a user even if they have, for + * instance, suicided. + */ + if (has_room_key(word[1], rm)) { + if (!personal_key_remove(user, word[1])) { + write_user(user, + "There was an error taking the key away from that user.\n"); + return; + } + vwrite_user(user, + "You take your personal room key away from ~FC~OL%s~RS.\n", + word[1]); + vwrite_user(get_user(word[1]), "%s takes back their personal room key.\n", + user->name); + } else { + /* see if there is such a user */ + if (!find_user_listed(word[1])) { + write_user(user, nosuchuser); + return; + } + /* give them a key */ + if (!personal_key_add(user, word[1])) { + write_user(user, "There was an error giving the key to that user.\n"); + return; + } + vwrite_user(user, "You give ~FC~OL%s~RS a key to your personal room.\n", + word[1]); + vwrite_user(get_user(word[1]), "%s gives you a key to their room.\n", + user->name); + } +} diff --git a/src/commands/myroom_lock.c b/src/commands/myroom_lock.c index 9459844..a4acd38 100644 --- a/src/commands/myroom_lock.c +++ b/src/commands/myroom_lock.c @@ -1,32 +1,32 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * allows a user to lock their room out to access from anyone - */ -void -personal_room_lock(UR_OBJECT user) -{ - if (!amsys->personal_rooms) { - write_user(user, "Personal room functions are currently disabled.\n"); - return; - } - if (strcmp(user->room->owner, user->name)) { - write_user(user, - "You have to be in your personal room to lock and unlock it.\n"); - return; - } - user->room->access ^= PRIVATE; - if (is_private_room(user->room)) { - write_user(user, - "You have now ~OL~FRlocked~RS your room to all the other users.\n"); - } else { - write_user(user, - "You have now ~OL~FGunlocked~RS your room to all the other users.\n"); - } - if (!personal_room_store(user->name, 1, user->room)) - write_syslog(SYSLOG | ERRLOG, 1, - "ERROR: Unable to save personal room status in personal_room_lock()\n"); +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * allows a user to lock their room out to access from anyone + */ +void +personal_room_lock(UR_OBJECT user) +{ + if (!amsys->personal_rooms) { + write_user(user, "Personal room functions are currently disabled.\n"); + return; + } + if (strcmp(user->room->owner, user->name)) { + write_user(user, + "You have to be in your personal room to lock and unlock it.\n"); + return; + } + user->room->access ^= PRIVATE; + if (is_private_room(user->room)) { + write_user(user, + "You have now ~OL~FRlocked~RS your room to all the other users.\n"); + } else { + write_user(user, + "You have now ~OL~FGunlocked~RS your room to all the other users.\n"); + } + if (!personal_room_store(user->name, 1, user->room)) + write_syslog(SYSLOG | ERRLOG, 1, + "ERROR: Unable to save personal room status in personal_room_lock()\n"); } \ No newline at end of file diff --git a/src/commands/myroom_paint.c b/src/commands/myroom_paint.c index 97b26a5..78d82ba 100644 --- a/src/commands/myroom_paint.c +++ b/src/commands/myroom_paint.c @@ -1,43 +1,43 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Enter a description for a personal room - */ -void -personal_room_decorate(UR_OBJECT user, char *inpstr) -{ - if (inpstr) { - if (!amsys->personal_rooms) { - write_user(user, "Personal room functions are currently disabled.\n"); - return; - } - if (strcmp(user->room->owner, user->name)) { - write_user(user, - "You have to be in your personal room to decorate it.\n"); - return; - } - if (word_count < 2) { - write_user(user, "\n~BB*** Decorating your personal room ***\n\n"); - user->misc_op = 19; - editor(user, NULL); - return; - } - strcat(inpstr, "\n"); - } else { - inpstr = user->malloc_start; - } - *user->room->desc = '\0'; - strncat(user->room->desc, inpstr, ROOM_DESC_LEN); - if (strlen(user->room->desc) < strlen(inpstr)) { - vwrite_user(user, "The description is too long for the room \"%s\".\n", - user->room->name); - } - write_user(user, "You have now redecorated your personal room.\n"); - if (!personal_room_store(user->name, 1, user->room)) { - write_syslog(SYSLOG | ERRLOG, 1, - "ERROR: Unable to save personal room status in personal_room_decorate()\n"); - } +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Enter a description for a personal room + */ +void +personal_room_decorate(UR_OBJECT user, char *inpstr) +{ + if (inpstr) { + if (!amsys->personal_rooms) { + write_user(user, "Personal room functions are currently disabled.\n"); + return; + } + if (strcmp(user->room->owner, user->name)) { + write_user(user, + "You have to be in your personal room to decorate it.\n"); + return; + } + if (word_count < 2) { + write_user(user, "\n~BB*** Decorating your personal room ***\n\n"); + user->misc_op = 19; + editor(user, NULL); + return; + } + strcat(inpstr, "\n"); + } else { + inpstr = user->malloc_start; + } + *user->room->desc = '\0'; + strncat(user->room->desc, inpstr, ROOM_DESC_LEN); + if (strlen(user->room->desc) < strlen(inpstr)) { + vwrite_user(user, "The description is too long for the room \"%s\".\n", + user->room->name); + } + write_user(user, "You have now redecorated your personal room.\n"); + if (!personal_room_store(user->name, 1, user->room)) { + write_syslog(SYSLOG | ERRLOG, 1, + "ERROR: Unable to save personal room status in personal_room_decorate()\n"); + } } \ No newline at end of file diff --git a/src/commands/myroom_rename.c b/src/commands/myroom_rename.c index e07c79f..1f6f981 100644 --- a/src/commands/myroom_rename.c +++ b/src/commands/myroom_rename.c @@ -1,39 +1,39 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * allows a user to rename their room - */ -void -personal_room_rename(UR_OBJECT user, char *inpstr) -{ - if (!amsys->personal_rooms) { - write_user(user, "Personal room functions are currently disabled.\n"); - return; - } - if (word_count < 2) { - write_user(user, "Usage: myname \n"); - return; - } - if (strcmp(user->room->owner, user->name)) { - write_user(user, "You have to be in your personal room to rename it.\n"); - return; - } - if (strlen(inpstr) > PERSONAL_ROOMNAME_LEN) { - write_user(user, "You cannot have a room name that long.\n"); - return; - } - if (strlen(inpstr) - teslen(inpstr, 0) < 1) { - write_user(user, "You must enter a room name.\n"); - return; - } - strcpy(user->room->show_name, inpstr); - vwrite_user(user, "You have now renamed your room to: %s\n", - user->room->show_name); - if (!personal_room_store(user->name, 1, user->room)) { - write_syslog(SYSLOG | ERRLOG, 1, - "ERROR: Unable to save personal room status in personal_room_rename()\n"); - } -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * allows a user to rename their room + */ +void +personal_room_rename(UR_OBJECT user, char *inpstr) +{ + if (!amsys->personal_rooms) { + write_user(user, "Personal room functions are currently disabled.\n"); + return; + } + if (word_count < 2) { + write_user(user, "Usage: myname \n"); + return; + } + if (strcmp(user->room->owner, user->name)) { + write_user(user, "You have to be in your personal room to rename it.\n"); + return; + } + if (strlen(inpstr) > PERSONAL_ROOMNAME_LEN) { + write_user(user, "You cannot have a room name that long.\n"); + return; + } + if (strlen(inpstr) - teslen(inpstr, 0) < 1) { + write_user(user, "You must enter a room name.\n"); + return; + } + strcpy(user->room->show_name, inpstr); + vwrite_user(user, "You have now renamed your room to: %s\n", + user->room->show_name); + if (!personal_room_store(user->name, 1, user->room)) { + write_syslog(SYSLOG | ERRLOG, 1, + "ERROR: Unable to save personal room status in personal_room_rename()\n"); + } +} diff --git a/src/commands/netdata.c b/src/commands/netdata.c index ae53093..e9039b2 100644 --- a/src/commands/netdata.c +++ b/src/commands/netdata.c @@ -1,70 +1,70 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -#ifdef NETLINKS - -#include "netlinks.h" - -/* - * Show type of data being received down links (this is usefull when a link has hung) - */ -void -netdata(UR_OBJECT user) -{ - char from[80], name[USER_NAME_LEN + 1]; - NL_OBJECT nl; - int cnt; - - cnt = 0; - write_user(user, "\n~BB*** Mail receiving status ***\n\n"); - for (nl = nl_first; nl; nl = nl->next) { - if (nl->type == UNCONNECTED || !nl->mailfile) { - continue; - } - if (!cnt++) { - write_user(user, - "To : From Last recv.\n\n"); - } - sprintf(from, "%s@%s", nl->mail_from, nl->service); - sprintf(text, "%-15s : %-25s %d seconds ago.\n", nl->mail_to, from, - (int) (time(0) - nl->last_recvd)); - write_user(user, text); - } - if (!cnt) { - write_user(user, "No mail being received.\n\n"); - } else { - write_user(user, "\n"); - } - cnt = 0; - write_user(user, "\n~BB*** Message receiving status ***\n\n"); - for (nl = nl_first; nl; nl = nl->next) { - if (nl->type == UNCONNECTED || !nl->mesg_user) { - continue; - } - if (!cnt++) { - write_user(user, "To : From Last recv.\n\n"); - } - if (nl->mesg_user == (UR_OBJECT) - 1) { - strcpy(name, ""); - } else { - strcpy(name, nl->mesg_user->name); - } - sprintf(text, "%-15s : %-15s %d seconds ago.\n", name, nl->service, - (int) (time(0) - nl->last_recvd)); - write_user(user, text); - } - if (!cnt) { - write_user(user, "No messages being received.\n\n"); - } else { - write_user(user, "\n"); - } -} - -#else - -#define NO_NETLINKS - -#endif + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +#ifdef NETLINKS + +#include "netlinks.h" + +/* + * Show type of data being received down links (this is usefull when a link has hung) + */ +void +netdata(UR_OBJECT user) +{ + char from[80], name[USER_NAME_LEN + 1]; + NL_OBJECT nl; + int cnt; + + cnt = 0; + write_user(user, "\n~BB*** Mail receiving status ***\n\n"); + for (nl = nl_first; nl; nl = nl->next) { + if (nl->type == UNCONNECTED || !nl->mailfile) { + continue; + } + if (!cnt++) { + write_user(user, + "To : From Last recv.\n\n"); + } + sprintf(from, "%s@%s", nl->mail_from, nl->service); + sprintf(text, "%-15s : %-25s %d seconds ago.\n", nl->mail_to, from, + (int) (time(0) - nl->last_recvd)); + write_user(user, text); + } + if (!cnt) { + write_user(user, "No mail being received.\n\n"); + } else { + write_user(user, "\n"); + } + cnt = 0; + write_user(user, "\n~BB*** Message receiving status ***\n\n"); + for (nl = nl_first; nl; nl = nl->next) { + if (nl->type == UNCONNECTED || !nl->mesg_user) { + continue; + } + if (!cnt++) { + write_user(user, "To : From Last recv.\n\n"); + } + if (nl->mesg_user == (UR_OBJECT) - 1) { + strcpy(name, ""); + } else { + strcpy(name, nl->mesg_user->name); + } + sprintf(text, "%-15s : %-15s %d seconds ago.\n", name, nl->service, + (int) (time(0) - nl->last_recvd)); + write_user(user, text); + } + if (!cnt) { + write_user(user, "No messages being received.\n\n"); + } else { + write_user(user, "\n"); + } +} + +#else + +#define NO_NETLINKS + +#endif diff --git a/src/commands/netstat.c b/src/commands/netstat.c index 662510f..bf205b9 100644 --- a/src/commands/netstat.c +++ b/src/commands/netstat.c @@ -1,82 +1,82 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -#ifdef NETLINKS - -#include "netlinks.h" - -/* - * List defined netlinks and their status - */ -void -netstat(UR_OBJECT user) -{ - static const char *const allow[] = {" ?", "ALL", " IN", "OUT"}; - static const char *const type[] = {" -", " IN", "OUT"}; - char nlstat[9], vers[8]; - NL_OBJECT nl; - UR_OBJECT u; - int iu, ou, a; - - if (!nl_first) { - write_user(user, "No remote connections configured.\n"); - return; - } - write_user(user, - "\n~BB*** Netlink data & status ***\n\n~FCService name : Allow Type Status IU OU Version Site\n\n"); - for (nl = nl_first; nl; nl = nl->next) { - iu = ou = 0; - if (nl->stage == UP) { - for (u = user_first; u; u = u->next) { - if (u->netlink == nl) { - if (u->type == REMOTE_TYPE) { - ++iu; - } - if (!u->room) { - ++ou; - } - } - } - } - if (nl->type == UNCONNECTED) { - strcpy(nlstat, "~FRDOWN"); - strcpy(vers, "-"); - } else { - if (nl->stage == UP) { - strcpy(nlstat, " ~FGUP"); - } else { - strcpy(nlstat, " ~FYVER"); - } - if (!nl->ver_major) { - /* Pre - 3.2 version */ - strcpy(vers, "3.?.?"); - } else { - sprintf(vers, "%d.%d.%d", nl->ver_major, nl->ver_minor, - nl->ver_patch); - } - } - /* - If link is incoming and remoter vers < 3.2 we have no way of knowing - what the permissions on it are so set to blank - */ - if (!nl->ver_major && nl->type == INCOMING && nl->allow != IN) { - a = 0; - } else { - a = nl->allow + 1; - } - sprintf(text, "%-15s : %s %s %s~RS %2d %2d %7s %s %s\n", - nl->service, allow[a], type[nl->type], nlstat, iu, ou, vers, - nl->site, nl->port); - write_user(user, text); - } - write_user(user, "\n"); -} - -#else - -#define NO_NETLINKS - -#endif + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +#ifdef NETLINKS + +#include "netlinks.h" + +/* + * List defined netlinks and their status + */ +void +netstat(UR_OBJECT user) +{ + static const char *const allow[] = {" ?", "ALL", " IN", "OUT"}; + static const char *const type[] = {" -", " IN", "OUT"}; + char nlstat[9], vers[8]; + NL_OBJECT nl; + UR_OBJECT u; + int iu, ou, a; + + if (!nl_first) { + write_user(user, "No remote connections configured.\n"); + return; + } + write_user(user, + "\n~BB*** Netlink data & status ***\n\n~FCService name : Allow Type Status IU OU Version Site\n\n"); + for (nl = nl_first; nl; nl = nl->next) { + iu = ou = 0; + if (nl->stage == UP) { + for (u = user_first; u; u = u->next) { + if (u->netlink == nl) { + if (u->type == REMOTE_TYPE) { + ++iu; + } + if (!u->room) { + ++ou; + } + } + } + } + if (nl->type == UNCONNECTED) { + strcpy(nlstat, "~FRDOWN"); + strcpy(vers, "-"); + } else { + if (nl->stage == UP) { + strcpy(nlstat, " ~FGUP"); + } else { + strcpy(nlstat, " ~FYVER"); + } + if (!nl->ver_major) { + /* Pre - 3.2 version */ + strcpy(vers, "3.?.?"); + } else { + sprintf(vers, "%d.%d.%d", nl->ver_major, nl->ver_minor, + nl->ver_patch); + } + } + /* + If link is incoming and remoter vers < 3.2 we have no way of knowing + what the permissions on it are so set to blank + */ + if (!nl->ver_major && nl->type == INCOMING && nl->allow != IN) { + a = 0; + } else { + a = nl->allow + 1; + } + sprintf(text, "%-15s : %s %s %s~RS %2d %2d %7s %s %s\n", + nl->service, allow[a], type[nl->type], nlstat, iu, ou, vers, + nl->site, nl->port); + write_user(user, text); + } + write_user(user, "\n"); +} + +#else + +#define NO_NETLINKS + +#endif diff --git a/src/commands/pemote.c b/src/commands/pemote.c index 8db1d2e..3d2e705 100644 --- a/src/commands/pemote.c +++ b/src/commands/pemote.c @@ -1,106 +1,106 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Do a private emote - */ -void -pemote(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: pemote \n"; - const char *name; - UR_OBJECT u; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot emote.\n"); - return; - } - if (word_count < 3 && !strchr("level < GOD) { - vwrite_user(user, "%s~RS is ignoring private emotes from you.\n", - u->recap); - return; - } - if (u->igntells && (user->level < WIZ || u->level > user->level)) { - vwrite_user(user, "%s~RS is ignoring private emotes at the moment.\n", - u->recap); - return; - } - inpstr = remove_first(inpstr); - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - name = user->vis || u->level >= user->level ? user->recap : invisname; - sprintf(text, "~OL~FG>~RS %s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", - inpstr); - if (u->afk) { - record_afk(user, u, text); - if (*u->afk_mesg) { - vwrite_user(user, "%s~RS is ~FRAFK~RS, message is: %s\n", u->recap, - u->afk_mesg); - } else { - vwrite_user(user, "%s~RS is ~FRAFK~RS at the moment.\n", u->recap); - } - write_user(user, "Sending message to their afk review buffer.\n"); - return; - } - if (u->malloc_start) { - record_edit(user, u, text); - vwrite_user(user, - "%s~RS is in ~FCEDIT~RS mode at the moment (using the line editor).\n", - u->recap); - write_user(user, "Sending message to their edit review buffer.\n"); - return; - } - if (u->ignall && (user->level < WIZ || u->level > user->level)) { - vwrite_user(user, "%s~RS is ignoring everyone at the moment.\n", - u->recap); - return; - } -#ifdef NETLINKS - if (!u->room) { - vwrite_user(user, - "%s~RS is offsite and would not be able to reply to you.\n", - u->recap); - return; - } -#endif - record_tell(user, u, text); - write_user(u, text); - sprintf(text, "~FG~OL>~RS (%s~RS) %s~RS%s%s\n", u->recap, name, - *inpstr != '\'' ? " " : "", inpstr); - record_tell(user, user, text); - write_user(user, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Do a private emote + */ +void +pemote(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: pemote \n"; + const char *name; + UR_OBJECT u; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot emote.\n"); + return; + } + if (word_count < 3 && !strchr("level < GOD) { + vwrite_user(user, "%s~RS is ignoring private emotes from you.\n", + u->recap); + return; + } + if (u->igntells && (user->level < WIZ || u->level > user->level)) { + vwrite_user(user, "%s~RS is ignoring private emotes at the moment.\n", + u->recap); + return; + } + inpstr = remove_first(inpstr); + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + name = user->vis || u->level >= user->level ? user->recap : invisname; + sprintf(text, "~OL~FG>~RS %s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", + inpstr); + if (u->afk) { + record_afk(user, u, text); + if (*u->afk_mesg) { + vwrite_user(user, "%s~RS is ~FRAFK~RS, message is: %s\n", u->recap, + u->afk_mesg); + } else { + vwrite_user(user, "%s~RS is ~FRAFK~RS at the moment.\n", u->recap); + } + write_user(user, "Sending message to their afk review buffer.\n"); + return; + } + if (u->malloc_start) { + record_edit(user, u, text); + vwrite_user(user, + "%s~RS is in ~FCEDIT~RS mode at the moment (using the line editor).\n", + u->recap); + write_user(user, "Sending message to their edit review buffer.\n"); + return; + } + if (u->ignall && (user->level < WIZ || u->level > user->level)) { + vwrite_user(user, "%s~RS is ignoring everyone at the moment.\n", + u->recap); + return; + } +#ifdef NETLINKS + if (!u->room) { + vwrite_user(user, + "%s~RS is offsite and would not be able to reply to you.\n", + u->recap); + return; + } +#endif + record_tell(user, u, text); + write_user(u, text); + sprintf(text, "~FG~OL>~RS (%s~RS) %s~RS%s%s\n", u->recap, name, + *inpstr != '\'' ? " " : "", inpstr); + record_tell(user, user, text); + write_user(user, text); +} diff --git a/src/commands/picture_all.c b/src/commands/picture_all.c index 79496ea..5b51bcd 100644 --- a/src/commands/picture_all.c +++ b/src/commands/picture_all.c @@ -3,6 +3,9 @@ #include "globals.h" #include "commands.h" #include "prototypes.h" +#ifndef __SDS_H +#include "../vendors/sds/sds.h" +#endif /* * Show a picture to the whole room that the user is in diff --git a/src/commands/picture_tell.c b/src/commands/picture_tell.c index 810ffbb..e4ee583 100644 --- a/src/commands/picture_tell.c +++ b/src/commands/picture_tell.c @@ -3,6 +3,9 @@ #include "globals.h" #include "commands.h" #include "prototypes.h" +#ifndef __SDS_H +#include "../vendors/sds/sds.h" +#endif /* * Displays a picture to a person @@ -77,6 +80,7 @@ picture_tell(UR_OBJECT user) fp = fopen(filename, "r"); if (!fp) { write_user(user, "Sorry, there is no picture with that name.\n"); + sdsfree(filename); return; } fclose(fp); diff --git a/src/commands/plead.c b/src/commands/plead.c index 6b4a361..eb4eb9f 100644 --- a/src/commands/plead.c +++ b/src/commands/plead.c @@ -1,59 +1,59 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * ask all the law, (sos), no muzzle restrictions - */ -void -plead(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: sos \n"; - UR_OBJECT u; - const char *type; - - if (word_count < 2) { - write_user(user, usage); - return; - } - if (user->level >= WIZ) { - write_user(user, "You are already a wizard!\n"); - return; - } - for (u = user_first; u; u = u->next) { - if (u->level >= WIZ && !u->login) { - break; - } - } - if (!u) { - write_user(user, "Sorry, but there are no wizzes currently logged on.\n"); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - type = smiley_type(inpstr); - if (!type) { - type = "plead"; - } - vwrite_level(WIZ, 1, RECORD, user, - "~OL~FG>~RS [~FRSOS~RS] %s~RS ~OL%ss~RS: %s\n", user->recap, - type, inpstr); - sprintf(text, "~OL~FG>~RS [~FRSOS~RS] You ~OL%s~RS: %s\n", type, inpstr); - record_tell(user, user, text); - write_user(user, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * ask all the law, (sos), no muzzle restrictions + */ +void +plead(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: sos \n"; + UR_OBJECT u; + const char *type; + + if (word_count < 2) { + write_user(user, usage); + return; + } + if (user->level >= WIZ) { + write_user(user, "You are already a wizard!\n"); + return; + } + for (u = user_first; u; u = u->next) { + if (u->level >= WIZ && !u->login) { + break; + } + } + if (!u) { + write_user(user, "Sorry, but there are no wizzes currently logged on.\n"); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + type = smiley_type(inpstr); + if (!type) { + type = "plead"; + } + vwrite_level(WIZ, 1, RECORD, user, + "~OL~FG>~RS [~FRSOS~RS] %s~RS ~OL%ss~RS: %s\n", user->recap, + type, inpstr); + sprintf(text, "~OL~FG>~RS [~FRSOS~RS] You ~OL%s~RS: %s\n", type, inpstr); + record_tell(user, user, text); + write_user(user, text); +} diff --git a/src/commands/preview.c b/src/commands/preview.c index 9c18ae2..812b409 100644 --- a/src/commands/preview.c +++ b/src/commands/preview.c @@ -3,9 +3,12 @@ #include "globals.h" #include "commands.h" #include "prototypes.h" +#ifndef __SDS_H +#include "../vendors/sds/sds.h" +#endif /* - * see list of pictures availiable--file dictated in "go" script + * see list of pictures available--file dictated in "go" script */ void preview(UR_OBJECT user) @@ -45,7 +48,7 @@ preview(UR_OBJECT user) sprintf(text, "%-12.12s ", dp->d_name); strcat(line, text); if (++cnt == 5) { - write_user(user, align_string(0, 78, 1, "|", " %s", line)); + write_user(user, align_string(ALIGN_LEFT, 78, 1, "|", " %s", line)); *line = '\0'; cnt = 0; } @@ -53,12 +56,12 @@ preview(UR_OBJECT user) closedir(dirp); if (total) { if (cnt) { - write_user(user, align_string(0, 78, 1, "|", " %s", line)); + write_user(user, align_string(ALIGN_LEFT, 78, 1, "|", " %s", line)); } write_user(user, "+----------------------------------------------------------------------------+\n"); write_user(user, - align_string(0, 78, 1, "|", " There are %d picture%s ", + align_string(ALIGN_LEFT, 78, 1, "|", " There are %d picture%s ", total, PLTEXT_S(total))); write_user(user, "+----------------------------------------------------------------------------+\n\n"); @@ -75,6 +78,7 @@ preview(UR_OBJECT user) fp = fopen(filename, "r"); if (!fp) { write_user(user, "Sorry, there is no picture with that name.\n"); + sdsfree(filename); return; } fclose(fp); diff --git a/src/commands/promote.c b/src/commands/promote.c index 6d6a7f9..aa1fec0 100644 --- a/src/commands/promote.c +++ b/src/commands/promote.c @@ -1,97 +1,97 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Promote a user - */ -void -promote(UR_OBJECT user) -{ - UR_OBJECT u; - int on; - enum lvl_value lvl; - - if (word_count < 2) { - write_user(user, "Usage: promote []\n"); - return; - } - if (word_count > 3) { - write_user(user, "Usage: promote []\n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - /* FIXME: lose .tpromote if .promote fails */ - /* first, gotta reset the user level if they have been temp promoted */ - if (u->real_level < u->level) { - u->level = u->real_level; - } - /* cannot promote jailed users */ - if (u->level == JAILED) { - vwrite_user(user, "You cannot promote a user of level %s.\n", - user_level[JAILED].name); - done_retrieve(u); - return; - } - if (word_count < 3) { - lvl = (enum lvl_value) (u->level + 1); - } else { - strtoupper(word[2]); - lvl = get_level(word[2]); - if (lvl == NUM_LEVELS) { - vwrite_user(user, "You must select a level between %s and %s.\n", - user_level[USER].name, user_level[GOD].name); - done_retrieve(u); - return; - } - if (lvl <= u->level) { - write_user(user, - "You cannot promote a user to a level less than or equal to what they are now.\n"); - done_retrieve(u); - return; - } - } - if (user->level < lvl) { - write_user(user, - "You cannot promote a user to a level higher than your own.\n"); - done_retrieve(u); - return; - } - /* do it */ - u->level = lvl; - u->unarrest = u->level; - u->real_level = u->level; - user_list_level(u->name, u->level); - strcpy(u->date, (long_date(1))); - u->accreq = -1; - u->real_level = u->level; - strcpy(u->date, long_date(1)); - add_user_date_node(u->name, (long_date(1))); - sprintf(text, "~FG~OLYou have been promoted to level: ~RS~OL%s.\n", - user_level[u->level].name); - if (!on) { - send_mail(user, u->name, text, 0); - } else { - write_user(u, text); - } - vwrite_level(u->level, 1, NORECORD, u, - "~FG~OL%s is promoted to level: ~RS~OL%s.\n", u->bw_recap, - user_level[u->level].name); - write_syslog(SYSLOG, 1, "%s PROMOTED %s to level %s.\n", user->name, - u->name, user_level[u->level].name); - sprintf(text, "Was ~FGpromoted~RS by %s to level %s.\n", user->name, - user_level[u->level].name); - add_history(u->name, 1, "%s", text); - if (!on) { - u->socket = -2; - strcpy(u->site, u->last_site); - } - save_user_details(u, on); - done_retrieve(u); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Promote a user + */ +void +promote(UR_OBJECT user) +{ + UR_OBJECT u; + int on; + enum lvl_value lvl; + + if (word_count < 2) { + write_user(user, "Usage: promote []\n"); + return; + } + if (word_count > 3) { + write_user(user, "Usage: promote []\n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + /* FIXME: lose .tpromote if .promote fails */ + /* first, gotta reset the user level if they have been temp promoted */ + if (u->real_level < u->level) { + u->level = u->real_level; + } + /* cannot promote jailed users */ + if (u->level == JAILED) { + vwrite_user(user, "You cannot promote a user of level %s.\n", + user_level[JAILED].name); + done_retrieve(u); + return; + } + if (word_count < 3) { + lvl = (enum lvl_value) (u->level + 1); + } else { + strtoupper(word[2]); + lvl = get_level(word[2]); + if (lvl == NUM_LEVELS) { + vwrite_user(user, "You must select a level between %s and %s.\n", + user_level[USER].name, user_level[GOD].name); + done_retrieve(u); + return; + } + if (lvl <= u->level) { + write_user(user, + "You cannot promote a user to a level less than or equal to what they are now.\n"); + done_retrieve(u); + return; + } + } + if (user->level < lvl) { + write_user(user, + "You cannot promote a user to a level higher than your own.\n"); + done_retrieve(u); + return; + } + /* do it */ + u->level = lvl; + u->unarrest = u->level; + u->real_level = u->level; + user_list_level(u->name, u->level); + strcpy(u->date, (long_date(1))); + u->accreq = -1; + u->real_level = u->level; + strcpy(u->date, long_date(1)); + add_user_date_node(u->name, (long_date(1))); + sprintf(text, "~FG~OLYou have been promoted to level: ~RS~OL%s.\n", + user_level[u->level].name); + if (!on) { + send_mail(user, u->name, text, 0); + } else { + write_user(u, text); + } + vwrite_level(u->level, 1, NORECORD, u, + "~FG~OL%s is promoted to level: ~RS~OL%s.\n", u->bw_recap, + user_level[u->level].name); + write_syslog(SYSLOG, 1, "%s PROMOTED %s to level %s.\n", user->name, + u->name, user_level[u->level].name); + sprintf(text, "Was ~FGpromoted~RS by %s to level %s.\n", user->name, + user_level[u->level].name); + add_history(u->name, 1, "%s", text); + if (!on) { + u->socket = -2; + strcpy(u->site, u->last_site); + } + save_user_details(u, on); + done_retrieve(u); } \ No newline at end of file diff --git a/src/commands/promote_temporary.c b/src/commands/promote_temporary.c index d5a0475..194be1d 100644 --- a/src/commands/promote_temporary.c +++ b/src/commands/promote_temporary.c @@ -1,77 +1,77 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * do a promotion of a user that lasts only for the current session - */ -void -temporary_promote(UR_OBJECT user) -{ - UR_OBJECT u; - enum lvl_value lvl; - - if (word_count < 2) { - write_user(user, "Usage: tpromote []\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, - "You cannot promote yourself, temporarily or otherwise.\n"); - return; - } - /* determine what level to promote them to */ - if (u->level >= user->level) { - write_user(user, - "You cannot temporarily promote anyone of the same or greater level than you.\n"); - return; - } - if (word_count == 3) { - lvl = get_level(word[2]); - if (lvl == NUM_LEVELS) { - write_user(user, "Usage: tpromote []\n"); - return; - } - if (lvl <= u->level) { - vwrite_user(user, - "You must specify a level higher than %s currently is.\n", - u->name); - return; - } - } else { - lvl = (enum lvl_value) (u->level + 1); - } - if (lvl == GOD) { - vwrite_user(user, "You cannot temporarily promote anyone to level %s.\n", - user_level[lvl].name); - return; - } - if (lvl >= user->level) { - write_user(user, - "You cannot temporarily promote anyone to a higher level than your own.\n"); - return; - } - /* if they have already been temp promoted this session then restore normal level first */ - if (u->level > u->real_level) { - u->level = u->real_level; - } - u->real_level = u->level; - u->level = lvl; - vwrite_user(user, "You temporarily promote %s to %s.\n", u->name, - user_level[u->level].name); - vwrite_room_except(u->room, u, - "~OL~FG%s~RS~OL~FG starts to glow as their power increases...\n", - u->bw_recap); - vwrite_user(u, "~OL~FGYou have been promoted (temporarily) to level %s.\n", - user_level[u->level].name); - write_syslog(SYSLOG, 1, "%s TEMPORARILY promote %s to %s.\n", user->name, - u->name, user_level[u->level].name); - sprintf(text, "Was temporarily to level %s.\n", user_level[u->level].name); - add_history(u->name, 1, "%s", text); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * do a promotion of a user that lasts only for the current session + */ +void +temporary_promote(UR_OBJECT user) +{ + UR_OBJECT u; + enum lvl_value lvl; + + if (word_count < 2) { + write_user(user, "Usage: tpromote []\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, + "You cannot promote yourself, temporarily or otherwise.\n"); + return; + } + /* determine what level to promote them to */ + if (u->level >= user->level) { + write_user(user, + "You cannot temporarily promote anyone of the same or greater level than you.\n"); + return; + } + if (word_count == 3) { + lvl = get_level(word[2]); + if (lvl == NUM_LEVELS) { + write_user(user, "Usage: tpromote []\n"); + return; + } + if (lvl <= u->level) { + vwrite_user(user, + "You must specify a level higher than %s currently is.\n", + u->name); + return; + } + } else { + lvl = (enum lvl_value) (u->level + 1); + } + if (lvl == GOD) { + vwrite_user(user, "You cannot temporarily promote anyone to level %s.\n", + user_level[lvl].name); + return; + } + if (lvl >= user->level) { + write_user(user, + "You cannot temporarily promote anyone to a higher level than your own.\n"); + return; + } + /* if they have already been temp promoted this session then restore normal level first */ + if (u->level > u->real_level) { + u->level = u->real_level; + } + u->real_level = u->level; + u->level = lvl; + vwrite_user(user, "You temporarily promote %s to %s.\n", u->name, + user_level[u->level].name); + vwrite_room_except(u->room, u, + "~OL~FG%s~RS~OL~FG starts to glow as their power increases...\n", + u->bw_recap); + vwrite_user(u, "~OL~FGYou have been promoted (temporarily) to level %s.\n", + user_level[u->level].name); + write_syslog(SYSLOG, 1, "%s TEMPORARILY promote %s to %s.\n", user->name, + u->name, user_level[u->level].name); + sprintf(text, "Was temporarily to level %s.\n", user_level[u->level].name); + add_history(u->name, 1, "%s", text); +} diff --git a/src/commands/purge.c b/src/commands/purge.c index 833c73a..4528968 100644 --- a/src/commands/purge.c +++ b/src/commands/purge.c @@ -1,79 +1,79 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * allows the user to call the purge function - */ -void -purge_users(UR_OBJECT user) -{ - int exp = 0; - - if (word_count < 2) { - write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); - return; - } - if (!strcmp(word[1], "-d")) { - write_user(user, - "~OL~FR***~RS Purging users with default settings ~OL~FR***\n"); - purge(1, NULL, 0); - } else if (!strcmp(word[1], "-s")) { - if (word_count < 3) { - write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); - return; - } - /* check for variations of wild card */ - if (!strcmp("*", word[2])) { - write_user(user, "You cannot purge users from the site \"*\".\n"); - return; - } - if (strstr(word[2], "**")) { - write_user(user, "You cannot have \"**\" in your site to purge.\n"); - return; - } - if (strstr(word[2], "?*")) { - write_user(user, "You cannot have \"?*\" in your site to purge.\n"); - return; - } - if (strstr(word[2], "*?")) { - write_user(user, "You cannot have \"*?\" in your site to purge.\n"); - return; - } - vwrite_user(user, - "~OL~FR***~RS Purging users with site \"%s\" ~OL~FR***\n", - word[2]); - purge(2, word[2], 0); - } else if (!strcmp(word[1], "-t")) { - if (word_count < 3) { - write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); - return; - } - exp = atoi(word[2]); - if (exp <= USER_EXPIRES) { - write_user(user, - "You cannot purge users who last logged in less than the default time.\n"); - vwrite_user(user, "The current default is: %d days\n", USER_EXPIRES); - return; - } - if (exp < 0 || exp > 999) { - write_user(user, "You must enter the amount days from 0-999.\n"); - return; - } - vwrite_user(user, - "~OL~FR***~RS Purging users who last logged in over %d days ago ~OL~FR***\n", - exp); - purge(3, NULL, exp); - } else { - write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); - return; - } - /* finished purging - give result */ - vwrite_user(user, - "Checked ~OL%d~RS user%s (~OL%d~RS skipped), ~OL%d~RS %s purged. User count is now ~OL%d~RS.\n", - amsys->purge_count, PLTEXT_S(amsys->purge_count), - amsys->purge_skip, amsys->users_purged, - PLTEXT_WAS(amsys->users_purged), amsys->user_count); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * allows the user to call the purge function + */ +void +purge_users(UR_OBJECT user) +{ + int exp = 0; + + if (word_count < 2) { + write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); + return; + } + if (!strcmp(word[1], "-d")) { + write_user(user, + "~OL~FR***~RS Purging users with default settings ~OL~FR***\n"); + purge(1, NULL, 0); + } else if (!strcmp(word[1], "-s")) { + if (word_count < 3) { + write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); + return; + } + /* check for variations of wild card */ + if (!strcmp("*", word[2])) { + write_user(user, "You cannot purge users from the site \"*\".\n"); + return; + } + if (strstr(word[2], "**")) { + write_user(user, "You cannot have \"**\" in your site to purge.\n"); + return; + } + if (strstr(word[2], "?*")) { + write_user(user, "You cannot have \"?*\" in your site to purge.\n"); + return; + } + if (strstr(word[2], "*?")) { + write_user(user, "You cannot have \"*?\" in your site to purge.\n"); + return; + } + vwrite_user(user, + "~OL~FR***~RS Purging users with site \"%s\" ~OL~FR***\n", + word[2]); + purge(2, word[2], 0); + } else if (!strcmp(word[1], "-t")) { + if (word_count < 3) { + write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); + return; + } + exp = atoi(word[2]); + if (exp <= USER_EXPIRES) { + write_user(user, + "You cannot purge users who last logged in less than the default time.\n"); + vwrite_user(user, "The current default is: %d days\n", USER_EXPIRES); + return; + } + if (exp < 0 || exp > 999) { + write_user(user, "You must enter the amount days from 0-999.\n"); + return; + } + vwrite_user(user, + "~OL~FR***~RS Purging users who last logged in over %d days ago ~OL~FR***\n", + exp); + purge(3, NULL, exp); + } else { + write_user(user, "Usage: purge [-d] [-s ] [-t ]\n"); + return; + } + /* finished purging - give result */ + vwrite_user(user, + "Checked ~OL%d~RS user%s (~OL%d~RS skipped), ~OL%d~RS %s purged. User count is now ~OL%d~RS.\n", + amsys->purge_count, PLTEXT_S(amsys->purge_count), + amsys->purge_skip, amsys->users_purged, + PLTEXT_WAS(amsys->users_purged), amsys->user_count); +} diff --git a/src/commands/quick_call.c b/src/commands/quick_call.c index 86c72cc..c0c05fb 100644 --- a/src/commands/quick_call.c +++ b/src/commands/quick_call.c @@ -1,38 +1,38 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * set a name for a quick call - */ -void -quick_call(UR_OBJECT user) -{ -#if !!0 - static const char usage[] = "Usage: call []\n"; -#endif - UR_OBJECT u; - - if (word_count < 2) { - if (!*user->call) { - write_user(user, "Quick call not set.\n"); - return; - } - vwrite_user(user, "Quick call to: %s.\n", user->call); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "You cannot set your quick call to yourself.\n"); - return; - } - strcpy(user->call, u->name); - *user->call = toupper(*user->call); - vwrite_user(user, "You have set a quick call to: %s.\n", user->call); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * set a name for a quick call + */ +void +quick_call(UR_OBJECT user) +{ +#if !!0 + static const char usage[] = "Usage: call []\n"; +#endif + UR_OBJECT u; + + if (word_count < 2) { + if (!*user->call) { + write_user(user, "Quick call not set.\n"); + return; + } + vwrite_user(user, "Quick call to: %s.\n", user->call); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "You cannot set your quick call to yourself.\n"); + return; + } + strcpy(user->call, u->name); + *user->call = toupper(*user->call); + vwrite_user(user, "You have set a quick call to: %s.\n", user->call); +} diff --git a/src/commands/ranks.c b/src/commands/ranks.c index 20b4c12..d47c6b2 100644 --- a/src/commands/ranks.c +++ b/src/commands/ranks.c @@ -1,38 +1,38 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * show the ranks and commands per level for the talker - */ -void -show_ranks(UR_OBJECT user) -{ - enum lvl_value lvl; - CMD_OBJECT cmd; - int total, cnt[NUM_LEVELS]; - - for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { - cnt[lvl] = 0; - } - for (cmd = first_command; cmd; cmd = cmd->next) { - ++cnt[cmd->level]; - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCThe ranks (levels) on the talker~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - total = 0; - for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { - vwrite_user(user, - "| %s(%1.1s) : %-10.10s : Lev %d : %3d cmds total : %2d cmds this level ~RS|\n", - lvl == user->level ? "~FY~OL" : "", user_level[lvl].alias, - user_level[lvl].name, lvl, total += cnt[lvl], cnt[lvl]); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * show the ranks and commands per level for the talker + */ +void +show_ranks(UR_OBJECT user) +{ + enum lvl_value lvl; + CMD_OBJECT cmd; + int total, cnt[NUM_LEVELS]; + + for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { + cnt[lvl] = 0; + } + for (cmd = first_command; cmd; cmd = cmd->next) { + ++cnt[cmd->level]; + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCThe ranks (levels) on the talker~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + total = 0; + for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { + vwrite_user(user, + "| %s(%1.1s) : %-10.10s : Lev %d : %3d cmds total : %2d cmds this level ~RS|\n", + lvl == user->level ? "~FY~OL" : "", user_level[lvl].alias, + user_level[lvl].name, lvl, total += cnt[lvl], cnt[lvl]); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); } \ No newline at end of file diff --git a/src/commands/rcountu.c b/src/commands/rcountu.c index 503b5b5..1522c3d 100644 --- a/src/commands/rcountu.c +++ b/src/commands/rcountu.c @@ -1,117 +1,117 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * read all the user files to check if a user exists - */ -void -recount_users(UR_OBJECT user, char *inpstr) -{ - char filename[80], *s; - DIR *dirp; - FILE *fp; - struct dirent *dp; - UD_OBJECT entry, next; - UR_OBJECT u; - int incorrect, correct, added, removed; - - if (!user->misc_op) { - user->misc_op = 17; - write_user(user, - "~OL~FRWARNING:~RS This process may take some time if you have a lot of user accounts.\n"); - write_user(user, - " This should only be done if there are no, or minimal, users currently\n logged on.\n"); - write_user(user, "\nDo you wish to continue (y|n)? "); - return; - } - user->misc_op = 0; - if (tolower(*inpstr) != 'y') { - return; - } - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - incorrect = correct = added = removed = 0; - write_user(user, "~OLRecounting all of the users...\n"); - /* First process the files to see if there are any to add to the directory listing */ - write_user(user, "Processing users to add..."); - u = create_user(); - if (!u) { - write_user(user, "ERROR: Cannot create user object.\n"); - write_syslog(SYSLOG | ERRLOG, 1, - "ERROR: Cannot create user object in recount_users().\n"); - return; - } - /* open the directory file up */ - dirp = opendir(USERFILES); - if (!dirp) { - write_user(user, "ERROR: Failed to open userfile directory.\n"); - write_syslog(SYSLOG | ERRLOG, 1, - "ERROR: Directory open failure in recount_users().\n"); - return; - } - /* count up how many files in the directory - this include . and .. */ - for (dp = readdir(dirp); dp; dp = readdir(dirp)) { - s = strchr(dp->d_name, '.'); - if (!s || strcmp(s, ".D")) { - continue; - } - *u->name = '\0'; - strncat(u->name, dp->d_name, (size_t) (s - dp->d_name)); - for (entry = first_user_entry; entry; entry = next) { - next = entry->next; - if (!strcmp(u->name, entry->name)) { - break; - } - } - if (!entry) { - if (load_user_details(u)) { - add_user_node(u->name, u->level); - write_syslog(SYSLOG, 0, - "Added new user node for existing user \"%s\"\n", - u->name); - ++added; - reset_user(u); - } - /* FIXME: Probably ought to warn about this case */ - } else { - ++correct; - } - } - closedir(dirp); - destruct_user(u); - /* - * Now process any nodes to remove the directory listing. This may - * not be optimal to do one loop to add and then one to remove, but - * it is the best way I can think of doing it right now at 4:27am! - */ - write_user(user, "\nProcessing users to remove..."); - for (entry = first_user_entry; entry; entry = next) { - next = entry->next; - sprintf(filename, "%s/%s.D", USERFILES, entry->name); - fp = fopen(filename, "r"); - if (!fp) { - ++removed; - --correct; - write_syslog(SYSLOG, 0, - "Removed user node for \"%s\" - user file does not exist.\n", - entry->name); - rem_user_node(entry->name); - } else { - fclose(fp); - } - } - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - vwrite_user(user, - "Checked ~OL%d~RS user%s. ~OL%d~RS node%s %s added, and ~OL%d~RS node%s %s removed.\n", - added + removed + correct, PLTEXT_S(added + removed + correct), - added, PLTEXT_S(added), PLTEXT_WAS(added), removed, - PLTEXT_S(removed), PLTEXT_WAS(removed)); - if (incorrect) { - write_user(user, "See the system log for further details.\n"); - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * read all the user files to check if a user exists + */ +void +recount_users(UR_OBJECT user, char *inpstr) +{ + char filename[80], *s; + DIR *dirp; + FILE *fp; + struct dirent *dp; + UD_OBJECT entry, next; + UR_OBJECT u; + int incorrect, correct, added, removed; + + if (!user->misc_op) { + user->misc_op = 17; + write_user(user, + "~OL~FRWARNING:~RS This process may take some time if you have a lot of user accounts.\n"); + write_user(user, + " This should only be done if there are no, or minimal, users currently\n logged on.\n"); + write_user(user, "\nDo you wish to continue (y|n)? "); + return; + } + user->misc_op = 0; + if (tolower(*inpstr) != 'y') { + return; + } + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + incorrect = correct = added = removed = 0; + write_user(user, "~OLRecounting all of the users...\n"); + /* First process the files to see if there are any to add to the directory listing */ + write_user(user, "Processing users to add..."); + u = create_user(); + if (!u) { + write_user(user, "ERROR: Cannot create user object.\n"); + write_syslog(SYSLOG | ERRLOG, 1, + "ERROR: Cannot create user object in recount_users().\n"); + return; + } + /* open the directory file up */ + dirp = opendir(USERFILES); + if (!dirp) { + write_user(user, "ERROR: Failed to open userfile directory.\n"); + write_syslog(SYSLOG | ERRLOG, 1, + "ERROR: Directory open failure in recount_users().\n"); + return; + } + /* count up how many files in the directory - this include . and .. */ + for (dp = readdir(dirp); dp; dp = readdir(dirp)) { + s = strchr(dp->d_name, '.'); + if (!s || strcmp(s, ".D")) { + continue; + } + *u->name = '\0'; + strncat(u->name, dp->d_name, (size_t) (s - dp->d_name)); + for (entry = first_user_entry; entry; entry = next) { + next = entry->next; + if (!strcmp(u->name, entry->name)) { + break; + } + } + if (!entry) { + if (load_user_details(u)) { + add_user_node(u->name, u->level); + write_syslog(SYSLOG, 0, + "Added new user node for existing user \"%s\"\n", + u->name); + ++added; + reset_user(u); + } + /* FIXME: Probably ought to warn about this case */ + } else { + ++correct; + } + } + closedir(dirp); + destruct_user(u); + /* + * Now process any nodes to remove the directory listing. This may + * not be optimal to do one loop to add and then one to remove, but + * it is the best way I can think of doing it right now at 4:27am! + */ + write_user(user, "\nProcessing users to remove..."); + for (entry = first_user_entry; entry; entry = next) { + next = entry->next; + sprintf(filename, "%s/%s.D", USERFILES, entry->name); + fp = fopen(filename, "r"); + if (!fp) { + ++removed; + --correct; + write_syslog(SYSLOG, 0, + "Removed user node for \"%s\" - user file does not exist.\n", + entry->name); + rem_user_node(entry->name); + } else { + fclose(fp); + } + } + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + vwrite_user(user, + "Checked ~OL%d~RS user%s. ~OL%d~RS node%s %s added, and ~OL%d~RS node%s %s removed.\n", + added + removed + correct, PLTEXT_S(added + removed + correct), + added, PLTEXT_S(added), PLTEXT_WAS(added), removed, + PLTEXT_S(removed), PLTEXT_WAS(removed)); + if (incorrect) { + write_user(user, "See the system log for further details.\n"); + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); +} diff --git a/src/commands/read_board.c b/src/commands/read_board.c index 493e2b1..12d02b5 100644 --- a/src/commands/read_board.c +++ b/src/commands/read_board.c @@ -1,66 +1,66 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Read the message board - */ -void -read_board(UR_OBJECT user) -{ - char filename[80]; - const char *name; - RM_OBJECT rm; - int ret; - - rm = NULL; - if (word_count < 2) { - rm = user->room; - } else { - if (word_count >= 3) { - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - ret = atoi(word[2]); - read_board_specific(user, rm, ret); - return; - } - ret = atoi(word[1]); - if (ret) { - read_board_specific(user, user->room, ret); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - if (!has_room_access(user, rm)) { - write_user(user, - "That room is currently private, you cannot read the board.\n"); - return; - } - } - vwrite_user(user, "\n~BB*** The %s message board ***\n\n", rm->name); - if (is_personal_room(rm)) { - sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); - } else { - sprintf(filename, "%s/%s.B", DATAFILES, rm->name); - } - user->filepos = 0; - ret = more(user, user->socket, filename); - if (!ret) { - write_user(user, "There are no messages on the board.\n\n"); - } else if (ret == 1) { - user->misc_op = 2; - } - name = user->vis ? user->recap : invisname; - if (rm == user->room) { - vwrite_room_except(user->room, user, "%s~RS reads the message board.\n", - name); - } + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Read the message board + */ +void +read_board(UR_OBJECT user) +{ + char filename[80]; + const char *name; + RM_OBJECT rm; + int ret; + + rm = NULL; + if (word_count < 2) { + rm = user->room; + } else { + if (word_count >= 3) { + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + ret = atoi(word[2]); + read_board_specific(user, rm, ret); + return; + } + ret = atoi(word[1]); + if (ret) { + read_board_specific(user, user->room, ret); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + if (!has_room_access(user, rm)) { + write_user(user, + "That room is currently private, you cannot read the board.\n"); + return; + } + } + vwrite_user(user, "\n~BB*** The %s message board ***\n\n", rm->name); + if (is_personal_room(rm)) { + sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); + } else { + sprintf(filename, "%s/%s.B", DATAFILES, rm->name); + } + user->filepos = 0; + ret = more(user, user->socket, filename); + if (!ret) { + write_user(user, "There are no messages on the board.\n\n"); + } else if (ret == 1) { + user->misc_op = 2; + } + name = user->vis ? user->recap : invisname; + if (rm == user->room) { + vwrite_room_except(user->room, user, "%s~RS reads the message board.\n", + name); + } } \ No newline at end of file diff --git a/src/commands/reboot_talker.c b/src/commands/reboot_talker.c index 555b856..035b88e 100644 --- a/src/commands/reboot_talker.c +++ b/src/commands/reboot_talker.c @@ -1,59 +1,59 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Reboot talker interface func - */ -void -reboot_com(UR_OBJECT user) -{ - if (!amsys->rs_which) { - write_user(user, - "The shutdown countdown is currently active, you must cancel it first.\n"); - return; - } - if (!strcmp(word[1], "cancel")) { - if (!amsys->rs_countdown) { - write_user(user, "The reboot countdown is not currently active.\n"); - return; - } - if (amsys->rs_countdown && !amsys->rs_user) { - write_user(user, - "Someone else is currently setting the reboot countdown.\n"); - return; - } - write_room(NULL, "~OLSYSTEM:~RS~FG Reboot cancelled.\n"); - write_syslog(SYSLOG, 1, "%s cancelled the reboot countdown.\n", - user->name); - amsys->rs_countdown = 0; - amsys->rs_announce = 0; - amsys->rs_which = -1; - amsys->rs_user = NULL; - return; - } - if (word_count > 1 && !is_number(word[1])) { - write_user(user, "Usage: reboot [|cancel]\n"); - return; - } - if (amsys->rs_countdown) { - write_user(user, - "The reboot countdown is currently active, you must cancel it first.\n"); - return; - } - if (word_count < 2) { - amsys->rs_countdown = 0; - amsys->rs_announce = 0; - amsys->rs_which = 1; - amsys->rs_user = NULL; - } else { - amsys->rs_countdown = atoi(word[1]); - amsys->rs_which = 1; - } - write_user(user, - "\n\07~FY~OL~LI*** WARNING - This will reboot the talker! ***\n\nAre you sure about this (y|n)? "); - user->misc_op = 7; - no_prompt = 1; + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Reboot talker interface func + */ +void +reboot_com(UR_OBJECT user) +{ + if (!amsys->rs_which) { + write_user(user, + "The shutdown countdown is currently active, you must cancel it first.\n"); + return; + } + if (!strcmp(word[1], "cancel")) { + if (!amsys->rs_countdown) { + write_user(user, "The reboot countdown is not currently active.\n"); + return; + } + if (amsys->rs_countdown && !amsys->rs_user) { + write_user(user, + "Someone else is currently setting the reboot countdown.\n"); + return; + } + write_room(NULL, "~OLSYSTEM:~RS~FG Reboot cancelled.\n"); + write_syslog(SYSLOG, 1, "%s cancelled the reboot countdown.\n", + user->name); + amsys->rs_countdown = 0; + amsys->rs_announce = 0; + amsys->rs_which = -1; + amsys->rs_user = NULL; + return; + } + if (word_count > 1 && !is_number(word[1])) { + write_user(user, "Usage: reboot [|cancel]\n"); + return; + } + if (amsys->rs_countdown) { + write_user(user, + "The reboot countdown is currently active, you must cancel it first.\n"); + return; + } + if (word_count < 2) { + amsys->rs_countdown = 0; + amsys->rs_announce = 0; + amsys->rs_which = 1; + amsys->rs_user = NULL; + } else { + amsys->rs_countdown = atoi(word[1]); + amsys->rs_which = 1; + } + write_user(user, + "\n\07~FY~OL~LI*** WARNING - This will reboot the talker! ***\n\nAre you sure about this (y|n)? "); + user->misc_op = 7; + no_prompt = 1; } \ No newline at end of file diff --git a/src/commands/recount.c b/src/commands/recount.c index 97d6985..391264b 100644 --- a/src/commands/recount.c +++ b/src/commands/recount.c @@ -1,154 +1,154 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Remove any expired messages from boards unless force = 2 in which case - * just do a recount. - */ -void -check_messages(UR_OBJECT user, int chforce) -{ - char id[82], filename[80], line[82], *s; - FILE *infp, *outfp; - RM_OBJECT rm; - int valid, pt, write_rest, board_cnt, old_cnt, bad_cnt, tmp; - - infp = outfp = NULL; - switch (chforce) { - case 0: - break; - case 1: - printf("Checking boards...\n"); - break; - case 2: - if (word_count >= 2) { - strtolower(word[1]); - if (strcmp(word[1], "motds")) { - write_user(user, "Usage: recount [motds]\n"); - return; - } - if (!count_motds(1)) { - write_user(user, - "Sorry, could not recount the motds at this time.\n"); - write_syslog(SYSLOG | ERRLOG, 1, - "ERROR: Could not recount motds in check_messages().\n"); - return; - } - vwrite_user(user, "There %s %d login motd%s and %d post-login motd%s\n", - PLTEXT_WAS(amsys->motd1_cnt), amsys->motd1_cnt, - PLTEXT_S(amsys->motd1_cnt), amsys->motd2_cnt, - PLTEXT_S(amsys->motd2_cnt)); - write_syslog(SYSLOG, 1, "%s recounted the MOTDS.\n", user->name); - return; - } - break; - } - board_cnt = 0; - old_cnt = 0; - bad_cnt = 0; - for (rm = room_first; rm; rm = rm->next) { - tmp = rm->mesg_cnt; - rm->mesg_cnt = 0; - if (is_personal_room(rm)) { - sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); - } else { - sprintf(filename, "%s/%s.B", DATAFILES, rm->name); - } - infp = fopen(filename, "r"); - if (!infp) { - continue; - } - if (chforce < 2) { - outfp = fopen("tempfile", "w"); - if (!outfp) { - if (chforce) { - fprintf(stderr, "Amnuts: Cannot open tempfile.\n"); - } - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Cannot open tempfile in check_messages().\n"); - fclose(infp); - return; - } - } - ++board_cnt; - /* - We assume that once 1 in date message is encountered all the others - will be in date too , hence write_rest once set to 1 is never set to - 0 again - */ - valid = 1; - write_rest = 0; - /* max of 80+newline+terminator = 82 */ - for (s = fgets(line, 82, infp); s; s = fgets(line, 82, infp)) { - if (*s == '\n') { - valid = 1; - } - sscanf(s, "%s %d", id, &pt); - if (!write_rest) { - if (valid && !strcmp(id, "PT:")) { - if (chforce == 2) { - ++rm->mesg_cnt; - } else { - /* 86400 = num. of secs in a day */ - if ((int) time(0) - pt < amsys->mesg_life * 86400) { - fputs(s, outfp); - ++rm->mesg_cnt; - write_rest = 1; - } else { - ++old_cnt; - } - } - valid = 0; - } - } else { - fputs(s, outfp); - if (valid && !strcmp(id, "PT:")) { - ++rm->mesg_cnt; - valid = 0; - } - } - } - fclose(infp); - if (chforce < 2) { - fclose(outfp); - remove(filename); - if (!write_rest) { - remove("tempfile"); - } else { - rename("tempfile", filename); - } - } - if (rm->mesg_cnt != tmp) { - ++bad_cnt; - } - } - switch (chforce) { - case 0: - if (bad_cnt) { - write_syslog(SYSLOG, 1, - "CHECK_MESSAGES: %d file%s checked, %d had an incorrect message count, %d message%s deleted.\n", - board_cnt, PLTEXT_S(board_cnt), bad_cnt, old_cnt, - PLTEXT_S(old_cnt)); - } else { - write_syslog(SYSLOG, 1, - "CHECK_MESSAGES: %d file%s checked, %d message%s deleted.\n", - board_cnt, PLTEXT_S(board_cnt), old_cnt, - PLTEXT_S(old_cnt)); - } - break; - case 1: - printf(" %d board file%s checked, %d out of date message%s found.\n", - board_cnt, PLTEXT_S(board_cnt), old_cnt, PLTEXT_S(old_cnt)); - break; - case 2: - vwrite_user(user, - "%d board file%s checked, %d had an incorrect message count.\n", - board_cnt, PLTEXT_S(board_cnt), bad_cnt); - write_syslog(SYSLOG, 1, "%s forced a recount of the message boards.\n", - user->name); - break; - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Remove any expired messages from boards unless force = 2 in which case + * just do a recount. + */ +void +check_messages(UR_OBJECT user, int chforce) +{ + char id[82], filename[80], line[82], *s; + FILE *infp, *outfp; + RM_OBJECT rm; + int valid, pt, write_rest, board_cnt, old_cnt, bad_cnt, tmp; + + infp = outfp = NULL; + switch (chforce) { + case 0: + break; + case 1: + printf("Checking boards...\n"); + break; + case 2: + if (word_count >= 2) { + strtolower(word[1]); + if (strcmp(word[1], "motds")) { + write_user(user, "Usage: recount [motds]\n"); + return; + } + if (!count_motds(1)) { + write_user(user, + "Sorry, could not recount the motds at this time.\n"); + write_syslog(SYSLOG | ERRLOG, 1, + "ERROR: Could not recount motds in check_messages().\n"); + return; + } + vwrite_user(user, "There %s %d login motd%s and %d post-login motd%s\n", + PLTEXT_WAS(amsys->motd1_cnt), amsys->motd1_cnt, + PLTEXT_S(amsys->motd1_cnt), amsys->motd2_cnt, + PLTEXT_S(amsys->motd2_cnt)); + write_syslog(SYSLOG, 1, "%s recounted the MOTDS.\n", user->name); + return; + } + break; + } + board_cnt = 0; + old_cnt = 0; + bad_cnt = 0; + for (rm = room_first; rm; rm = rm->next) { + tmp = rm->mesg_cnt; + rm->mesg_cnt = 0; + if (is_personal_room(rm)) { + sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); + } else { + sprintf(filename, "%s/%s.B", DATAFILES, rm->name); + } + infp = fopen(filename, "r"); + if (!infp) { + continue; + } + if (chforce < 2) { + outfp = fopen("tempfile", "w"); + if (!outfp) { + if (chforce) { + fprintf(stderr, "Amnuts: Cannot open tempfile.\n"); + } + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Cannot open tempfile in check_messages().\n"); + fclose(infp); + return; + } + } + ++board_cnt; + /* + We assume that once 1 in date message is encountered all the others + will be in date too , hence write_rest once set to 1 is never set to + 0 again + */ + valid = 1; + write_rest = 0; + /* max of 80+newline+terminator = 82 */ + for (s = fgets(line, 82, infp); s; s = fgets(line, 82, infp)) { + if (*s == '\n') { + valid = 1; + } + sscanf(s, "%s %d", id, &pt); + if (!write_rest) { + if (valid && !strcmp(id, "PT:")) { + if (chforce == 2) { + ++rm->mesg_cnt; + } else { + /* 86400 = num. of secs in a day */ + if ((int) time(0) - pt < amsys->mesg_life * 86400) { + fputs(s, outfp); + ++rm->mesg_cnt; + write_rest = 1; + } else { + ++old_cnt; + } + } + valid = 0; + } + } else { + fputs(s, outfp); + if (valid && !strcmp(id, "PT:")) { + ++rm->mesg_cnt; + valid = 0; + } + } + } + fclose(infp); + if (chforce < 2) { + fclose(outfp); + remove(filename); + if (!write_rest) { + remove("tempfile"); + } else { + rename("tempfile", filename); + } + } + if (rm->mesg_cnt != tmp) { + ++bad_cnt; + } + } + switch (chforce) { + case 0: + if (bad_cnt) { + write_syslog(SYSLOG, 1, + "CHECK_MESSAGES: %d file%s checked, %d had an incorrect message count, %d message%s deleted.\n", + board_cnt, PLTEXT_S(board_cnt), bad_cnt, old_cnt, + PLTEXT_S(old_cnt)); + } else { + write_syslog(SYSLOG, 1, + "CHECK_MESSAGES: %d file%s checked, %d message%s deleted.\n", + board_cnt, PLTEXT_S(board_cnt), old_cnt, + PLTEXT_S(old_cnt)); + } + break; + case 1: + printf(" %d board file%s checked, %d out of date message%s found.\n", + board_cnt, PLTEXT_S(board_cnt), old_cnt, PLTEXT_S(old_cnt)); + break; + case 2: + vwrite_user(user, + "%d board file%s checked, %d had an incorrect message count.\n", + board_cnt, PLTEXT_S(board_cnt), bad_cnt); + write_syslog(SYSLOG, 1, "%s forced a recount of the message boards.\n", + user->name); + break; + } +} diff --git a/src/commands/reload_room.c b/src/commands/reload_room.c index 1a3b40d..f21ba2d 100644 --- a/src/commands/reload_room.c +++ b/src/commands/reload_room.c @@ -1,113 +1,113 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Reloads the description for one or all rooms--incase you have edited the - * file and do not want to reboot the talker to to make the changes displayed - */ -void -reload_room_description(UR_OBJECT user) -{ - int c, i, error; - RM_OBJECT rm; - char filename[80]; - FILE *fp; - - if (word_count < 2) { - write_user(user, "Usage: rloadrm -a/\n"); - return; - } - /* if reload all of the rooms */ - if (!strcmp(word[1], "-a")) { - error = 0; - for (rm = room_first; rm; rm = rm->next) { - if (is_personal_room(rm)) { - continue; - } - sprintf(filename, "%s/%s.R", DATAFILES, rm->name); - fp = fopen(filename, "r"); - if (!fp) { - vwrite_user(user, - "Sorry, cannot reload the description file for the room \"%s\".\n", - rm->name); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Cannot reload the description file for room %s.\n", - rm->name); - ++error; - continue; - } - i = 0; - for (c = getc(fp); c != EOF; c = getc(fp)) { - if (i == ROOM_DESC_LEN) { - break; - } - rm->desc[i++] = c; - } - if (c != EOF) { - vwrite_user(user, - "The description is too long for the room \"%s\".\n", - rm->name); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Description too long when reloading for room %s.\n", - rm->name); - } - rm->desc[i] = '\0'; - fclose(fp); - } - if (!error) { - write_user(user, "You have now reloaded all room descriptions.\n"); - } else { - write_user(user, - "You have now reloaded all room descriptions that you can.\n"); - } - write_syslog(SYSLOG, 1, "%s reloaded all of the room descriptions.\n", - user->name); - return; - } - /* if it is just one room to reload */ - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - /* check first for personal room, and do not reload */ - if (is_personal_room(rm)) { - write_user(user, - "Sorry, but you cannot reload personal room descriptions.\n"); - return; - } - sprintf(filename, "%s/%s.R", DATAFILES, rm->name); - fp = fopen(filename, "r"); - if (!fp) { - vwrite_user(user, - "Sorry, cannot reload the description file for the room \"%s\".\n", - rm->name); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Cannot reload the description file for room %s.\n", - rm->name); - return; - } - i = 0; - for (c = getc(fp); c != EOF; c = getc(fp)) { - if (i == ROOM_DESC_LEN) { - break; - } - rm->desc[i++] = c; - } - if (c != EOF) { - vwrite_user(user, "The description is too long for the room \"%s\".\n", - rm->name); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Description too long when reloading for room %s.\n", - rm->name); - } - rm->desc[i] = '\0'; - fclose(fp); - vwrite_user(user, - "You have now reloaded the description for the room \"%s\".\n", - rm->name); - write_syslog(SYSLOG, 1, "%s reloaded the description for the room %s\n", - user->name, rm->name); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Reloads the description for one or all rooms--in case you have edited the + * file and do not want to reboot the talker to make the changes displayed + */ +void +reload_room_description(UR_OBJECT user) +{ + int c, i, error; + RM_OBJECT rm; + char filename[80]; + FILE *fp; + + if (word_count < 2) { + write_user(user, "Usage: rloadrm -a/\n"); + return; + } + /* if reload all of the rooms */ + if (!strcmp(word[1], "-a")) { + error = 0; + for (rm = room_first; rm; rm = rm->next) { + if (is_personal_room(rm)) { + continue; + } + sprintf(filename, "%s/%s.R", DATAFILES, rm->name); + fp = fopen(filename, "r"); + if (!fp) { + vwrite_user(user, + "Sorry, cannot reload the description file for the room \"%s\".\n", + rm->name); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Cannot reload the description file for room %s.\n", + rm->name); + ++error; + continue; + } + i = 0; + for (c = getc(fp); c != EOF; c = getc(fp)) { + if (i == ROOM_DESC_LEN) { + break; + } + rm->desc[i++] = c; + } + if (c != EOF) { + vwrite_user(user, + "The description is too long for the room \"%s\".\n", + rm->name); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Description too long when reloading for room %s.\n", + rm->name); + } + rm->desc[i] = '\0'; + fclose(fp); + } + if (!error) { + write_user(user, "You have now reloaded all room descriptions.\n"); + } else { + write_user(user, + "You have now reloaded all room descriptions that you can.\n"); + } + write_syslog(SYSLOG, 1, "%s reloaded all of the room descriptions.\n", + user->name); + return; + } + /* if it is just one room to reload */ + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + /* check first for personal room, and do not reload */ + if (is_personal_room(rm)) { + write_user(user, + "Sorry, but you cannot reload personal room descriptions.\n"); + return; + } + sprintf(filename, "%s/%s.R", DATAFILES, rm->name); + fp = fopen(filename, "r"); + if (!fp) { + vwrite_user(user, + "Sorry, cannot reload the description file for the room \"%s\".\n", + rm->name); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Cannot reload the description file for room %s.\n", + rm->name); + return; + } + i = 0; + for (c = getc(fp); c != EOF; c = getc(fp)) { + if (i == ROOM_DESC_LEN) { + break; + } + rm->desc[i++] = c; + } + if (c != EOF) { + vwrite_user(user, "The description is too long for the room \"%s\".\n", + rm->name); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Description too long when reloading for room %s.\n", + rm->name); + } + rm->desc[i] = '\0'; + fclose(fp); + vwrite_user(user, + "You have now reloaded the description for the room \"%s\".\n", + rm->name); + write_syslog(SYSLOG, 1, "%s reloaded the description for the room %s\n", + user->name, rm->name); +} diff --git a/src/commands/reminder.c b/src/commands/reminder.c index da258de..2a37e97 100644 --- a/src/commands/reminder.c +++ b/src/commands/reminder.c @@ -1,283 +1,283 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Display the reminders a user has to them - * login is used to show information at the login prompt, otherwise user - * is just using the .reminder command. stage is used for inputting of a new reminder - */ -void -show_reminders(UR_OBJECT user, int stage) -{ - char temp[ARR_SIZE]; - const struct tm *date; - time_t now; - int yr, mo, dy; - int dd, mm, yy; - int i, total, count, del; - - time(&now); - date = localtime(&now); - /* display manually */ - if (!stage) { - if (word_count < 2) { - write_user(user, - "~OLTo view:\nUsage: reminder all\n reminder today\n"); - write_user(user, " reminder [ []]\n"); - write_user(user, - "~OLTo manage:\nUsage: reminder set\n reminder del \n"); - return; - } - /* display all the reminders a user has set */ - if (!strcasecmp("all", word[1])) { - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCAll your reminders~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - total = 0; - count = 0; - for (i = 0; i < MAX_REMINDERS; ++i) { - /* no msg set, then no reminder */ - if (!*user->reminder[i].msg) { - continue; - } - ++total; - scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); - ++count; - vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, - yy, mm, dd, user->reminder[i].msg); - } - if (!count) { - write_user(user, "You do not have reminders set.\n"); - } - write_user(user, - "\n+----------------------------------------------------------------------------+\n\n"); - return; - } - /* display all the reminders a user has for today */ - if (!strcasecmp("today", word[1])) { - dy = date->tm_mday; - mo = 1 + date->tm_mon; - yr = 1900 + date->tm_year; - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCYour reminders for today are~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - total = 0; - count = 0; - for (i = 0; i < MAX_REMINDERS; ++i) { - if (!*user->reminder[i].msg) { - continue; - } - ++total; - scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); - if (dd == dy && mm == mo && yy == yr) { - ++count; - vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, - yy, mm, dd, user->reminder[i].msg); - } - } - if (!count) { - write_user(user, "You do not have reminders set for today.\n"); - } - write_user(user, - "\n+----------------------------------------------------------------------------+\n\n"); - return; - } - /* allow a user to set a reminder */ - if (!strcasecmp("set", word[1])) { - /* check to see if there is enough space to add another reminder */ - for (i = 0; i < MAX_REMINDERS; ++i) { - if (!*user->reminder[i].msg) { - break; - } - } - if (i >= MAX_REMINDERS) { - write_user(user, - "You already have the maximum amount of reminders set.\n"); - return; - } - user->reminder_pos = i; - write_user(user, "Please enter a date for the reminder (1-31): "); - user->misc_op = 20; - return; - } - /* allow a user to delete one of their reminders */ - if (!strcasecmp("del", word[1])) { - if (word_count < 3) { - write_user(user, "Usage: reminder del \n"); - write_user(user, - "where: can be taken from \"reminder all\"\n"); - return; - } - del = atoi(word[2]); - total = 0; - for (i = 0; i < MAX_REMINDERS; ++i) { - if (!*user->reminder[i].msg) { - continue; - } - ++total; - if (total == del) { - break; - } - } - if (i >= MAX_REMINDERS) { - vwrite_user(user, - "Sorry, could not delete reminder number ~OL%d~RS.\n", - del); - return; - } - user->reminder[i].date = -1; - *user->reminder[i].msg = '\0'; - vwrite_user(user, "You have now deleted reminder number ~OL%d~RS.\n", - del); - write_user_reminders(user); - return; - } - /* view reminders for a particular day */ - yr = word_count < 4 ? 1900 + date->tm_year : atoi(word[3]); - mo = word_count < 3 ? 1 + date->tm_mon : atoi(word[2]); - dy = word_count < 2 ? date->tm_mday : atoi(word[1]); - /* assume that year give xx is y2k if xx!=99 */ - if (yr == 99) { - yr += 1900; - } else if (yr < 99) { - yr += 2000; - } - if (word_count > 4 || yr > 3000 || yr < 1800 || mo < 1 || mo > 12 - || dy < 1 || dy > 31) { - write_user(user, "Usage: reminder [ []]\n"); - write_user(user, "where: = day from 1 to 31\n"); - write_user(user, " = month from 1 to 12\n"); - write_user(user, " = year from 1 to 99, or 1800 to 3000\n"); - return; - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - sprintf(temp, "Your reminders for %.4d-%.2d-%.2d", yr, mo, dy); - vwrite_user(user, "| ~OL~FC%-74.74s~RS |\n", temp); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - total = 0; - count = 0; - for (i = 0; i < MAX_REMINDERS; ++i) { - if (!*user->reminder[i].msg) { - continue; - } - ++total; - scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); - if (dd == dy && mm == mo && yy == yr) { - ++count; - vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, - yy, mm, dd, user->reminder[i].msg); - } - } - if (!count) { - vwrite_user(user, "You have no reminders set for %.4d-%.2d-%.2d\n", yr, - mo, dy); - } - write_user(user, - "\n+----------------------------------------------------------------------------+\n\n"); - return; - } - /* next stages of asking for a new reminder */ - switch (stage) { - case 1: - yy = 1900 + date->tm_year; - mm = 1 + date->tm_mon; - dd = !word_count ? -1 : atoi(word[0]); - if (dd < 1 || dd > 31) { - write_user(user, - "The day for the reminder must be between 1 and 31.\n"); - user->reminder_pos = -1; - user->misc_op = 0; - return; - } - write_user(user, "Please enter a month (1-12): "); - user->reminder[user->reminder_pos].date = ymd_to_scalar(yy, mm, dd); - user->misc_op = 21; - return; - case 2: - scalar_to_ymd(user->reminder[user->reminder_pos].date, &yy, &mm, &dd); - mm = !word_count ? -1 : atoi(word[0]); - if (mm < 1 || mm > 12) { - write_user(user, - "The month for the reminder must be between 1 and 12.\n"); - user->reminder[user->reminder_pos].date = -1; - user->reminder_pos = -1; - user->misc_op = 0; - return; - } - write_user(user, - "Please enter a year (xx or 19xx or 20xx, etc, for this year): "); - user->reminder[user->reminder_pos].date = ymd_to_scalar(yy, mm, dd); - user->misc_op = 22; - return; - case 3: - scalar_to_ymd(user->reminder[user->reminder_pos].date, &yy, &mm, &dd); - yy = !word_count ? -1 : atoi(word[0]); - if (yy == -1) { - yy = 1900 + date->tm_year; - } - /* assume that year give xx is y2k if xx!=99 */ - if (yy == 99) { - yy += 1900; - } else if (yy < 99) { - yy += 2000; - } - if (yy > 3000 || yy < 1800) { - write_user(user, - "The year for the reminder must be between 1-99 or 1800-3000.\n"); - user->reminder[user->reminder_pos].date = -1; - user->reminder_pos = -1; - user->misc_op = 0; - return; - } - /* check to see if date has past - why put in a remind for a date that has? */ - user->reminder[user->reminder_pos].date = ymd_to_scalar(yy, mm, dd); - if (user->reminder[user->reminder_pos].date < - ymd_to_scalar(1900 + date->tm_year, 1 + date->tm_mon, - date->tm_mday)) { - write_user(user, - "That date has already passed so there is no point setting a reminder for it.\n"); - user->reminder[user->reminder_pos].date = -1; - user->reminder_pos = -1; - user->misc_op = 0; - return; - } - write_user(user, "Please enter reminder message:\n~FG>>~RS"); - user->misc_op = 23; - return; - case 4: - /* tell them they MUST enter a message */ - if (!*user->reminder[user->reminder_pos].msg) { - write_user(user, "Please enter reminder message:\n~FG>>~RS"); - user->misc_op = 23; - return; - } - write_user(user, "You have set the following reminder:\n"); - total = 0; - for (i = 0; i < MAX_REMINDERS; ++i) { - if (!*user->reminder[i].msg) { - continue; - } - ++total; - if (i == user->reminder_pos) { - break; - } - } - user->reminder_pos = -1; - scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); - vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, yy, - mm, dd, user->reminder[i].msg); - write_user_reminders(user); - user->misc_op = 0; - return; - } -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Display the reminders a user has to them + * login is used to show information at the login prompt, otherwise user + * is just using the .reminder command. stage is used for inputting of a new reminder + */ +void +show_reminders(UR_OBJECT user, int stage) +{ + char temp[ARR_SIZE]; + const struct tm *date; + time_t now; + int yr, mo, dy; + int dd, mm, yy; + int i, total, count, del; + + time(&now); + date = localtime(&now); + /* display manually */ + if (!stage) { + if (word_count < 2) { + write_user(user, + "~OLTo view:\nUsage: reminder all\n reminder today\n"); + write_user(user, " reminder [ []]\n"); + write_user(user, + "~OLTo manage:\nUsage: reminder set\n reminder del \n"); + return; + } + /* display all the reminders a user has set */ + if (!strcasecmp("all", word[1])) { + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCAll your reminders~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + total = 0; + count = 0; + for (i = 0; i < MAX_REMINDERS; ++i) { + /* no msg set, then no reminder */ + if (!*user->reminder[i].msg) { + continue; + } + ++total; + scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); + ++count; + vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, + yy, mm, dd, user->reminder[i].msg); + } + if (!count) { + write_user(user, "You do not have reminders set.\n"); + } + write_user(user, + "\n+----------------------------------------------------------------------------+\n\n"); + return; + } + /* display all the reminders a user has for today */ + if (!strcasecmp("today", word[1])) { + dy = date->tm_mday; + mo = 1 + date->tm_mon; + yr = 1900 + date->tm_year; + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCYour reminders for today are~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + total = 0; + count = 0; + for (i = 0; i < MAX_REMINDERS; ++i) { + if (!*user->reminder[i].msg) { + continue; + } + ++total; + scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); + if (dd == dy && mm == mo && yy == yr) { + ++count; + vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, + yy, mm, dd, user->reminder[i].msg); + } + } + if (!count) { + write_user(user, "You do not have reminders set for today.\n"); + } + write_user(user, + "\n+----------------------------------------------------------------------------+\n\n"); + return; + } + /* allow a user to set a reminder */ + if (!strcasecmp("set", word[1])) { + /* check to see if there is enough space to add another reminder */ + for (i = 0; i < MAX_REMINDERS; ++i) { + if (!*user->reminder[i].msg) { + break; + } + } + if (i >= MAX_REMINDERS) { + write_user(user, + "You already have the maximum amount of reminders set.\n"); + return; + } + user->reminder_pos = i; + write_user(user, "Please enter a date for the reminder (1-31): "); + user->misc_op = 20; + return; + } + /* allow a user to delete one of their reminders */ + if (!strcasecmp("del", word[1])) { + if (word_count < 3) { + write_user(user, "Usage: reminder del \n"); + write_user(user, + "where: can be taken from \"reminder all\"\n"); + return; + } + del = atoi(word[2]); + total = 0; + for (i = 0; i < MAX_REMINDERS; ++i) { + if (!*user->reminder[i].msg) { + continue; + } + ++total; + if (total == del) { + break; + } + } + if (i >= MAX_REMINDERS) { + vwrite_user(user, + "Sorry, could not delete reminder number ~OL%d~RS.\n", + del); + return; + } + user->reminder[i].date = -1; + *user->reminder[i].msg = '\0'; + vwrite_user(user, "You have now deleted reminder number ~OL%d~RS.\n", + del); + write_user_reminders(user); + return; + } + /* view reminders for a particular day */ + yr = word_count < 4 ? 1900 + date->tm_year : atoi(word[3]); + mo = word_count < 3 ? 1 + date->tm_mon : atoi(word[2]); + dy = word_count < 2 ? date->tm_mday : atoi(word[1]); + /* assume that year give xx is y2k if xx!=99 */ + if (yr == 99) { + yr += 1900; + } else if (yr < 99) { + yr += 2000; + } + if (word_count > 4 || yr > 3000 || yr < 1800 || mo < 1 || mo > 12 + || dy < 1 || dy > 31) { + write_user(user, "Usage: reminder [ []]\n"); + write_user(user, "where: = day from 1 to 31\n"); + write_user(user, " = month from 1 to 12\n"); + write_user(user, " = year from 1 to 99, or 1800 to 3000\n"); + return; + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + sprintf(temp, "Your reminders for %.4d-%.2d-%.2d", yr, mo, dy); + vwrite_user(user, "| ~OL~FC%-74.74s~RS |\n", temp); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + total = 0; + count = 0; + for (i = 0; i < MAX_REMINDERS; ++i) { + if (!*user->reminder[i].msg) { + continue; + } + ++total; + scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); + if (dd == dy && mm == mo && yy == yr) { + ++count; + vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, + yy, mm, dd, user->reminder[i].msg); + } + } + if (!count) { + vwrite_user(user, "You have no reminders set for %.4d-%.2d-%.2d\n", yr, + mo, dy); + } + write_user(user, + "\n+----------------------------------------------------------------------------+\n\n"); + return; + } + /* next stages of asking for a new reminder */ + switch (stage) { + case 1: + yy = 1900 + date->tm_year; + mm = 1 + date->tm_mon; + dd = !word_count ? -1 : atoi(word[0]); + if (dd < 1 || dd > 31) { + write_user(user, + "The day for the reminder must be between 1 and 31.\n"); + user->reminder_pos = -1; + user->misc_op = 0; + return; + } + write_user(user, "Please enter a month (1-12): "); + user->reminder[user->reminder_pos].date = ymd_to_scalar(yy, mm, dd); + user->misc_op = 21; + return; + case 2: + scalar_to_ymd(user->reminder[user->reminder_pos].date, &yy, &mm, &dd); + mm = !word_count ? -1 : atoi(word[0]); + if (mm < 1 || mm > 12) { + write_user(user, + "The month for the reminder must be between 1 and 12.\n"); + user->reminder[user->reminder_pos].date = -1; + user->reminder_pos = -1; + user->misc_op = 0; + return; + } + write_user(user, + "Please enter a year (xx or 19xx or 20xx, etc, for this year): "); + user->reminder[user->reminder_pos].date = ymd_to_scalar(yy, mm, dd); + user->misc_op = 22; + return; + case 3: + scalar_to_ymd(user->reminder[user->reminder_pos].date, &yy, &mm, &dd); + yy = !word_count ? -1 : atoi(word[0]); + if (yy == -1) { + yy = 1900 + date->tm_year; + } + /* assume that year give xx is y2k if xx!=99 */ + if (yy == 99) { + yy += 1900; + } else if (yy < 99) { + yy += 2000; + } + if (yy > 3000 || yy < 1800) { + write_user(user, + "The year for the reminder must be between 1-99 or 1800-3000.\n"); + user->reminder[user->reminder_pos].date = -1; + user->reminder_pos = -1; + user->misc_op = 0; + return; + } + /* check to see if date has past - why put in a remind for a date that has? */ + user->reminder[user->reminder_pos].date = ymd_to_scalar(yy, mm, dd); + if (user->reminder[user->reminder_pos].date < + ymd_to_scalar(1900 + date->tm_year, 1 + date->tm_mon, + date->tm_mday)) { + write_user(user, + "That date has already passed so there is no point setting a reminder for it.\n"); + user->reminder[user->reminder_pos].date = -1; + user->reminder_pos = -1; + user->misc_op = 0; + return; + } + write_user(user, "Please enter reminder message:\n~FG>>~RS"); + user->misc_op = 23; + return; + case 4: + /* tell them they MUST enter a message */ + if (!*user->reminder[user->reminder_pos].msg) { + write_user(user, "Please enter reminder message:\n~FG>>~RS"); + user->misc_op = 23; + return; + } + write_user(user, "You have set the following reminder:\n"); + total = 0; + for (i = 0; i < MAX_REMINDERS; ++i) { + if (!*user->reminder[i].msg) { + continue; + } + ++total; + if (i == user->reminder_pos) { + break; + } + } + user->reminder_pos = -1; + scalar_to_ymd(user->reminder[i].date, &yy, &mm, &dd); + vwrite_user(user, "~OL%2d)~RS ~OL~FC%.4d-%.2d-%.2d~RS %s\n", total, yy, + mm, dd, user->reminder[i].msg); + write_user_reminders(user); + user->misc_op = 0; + return; + } +} diff --git a/src/commands/remote_stat.c b/src/commands/remote_stat.c index c38ed76..c11013a 100644 --- a/src/commands/remote_stat.c +++ b/src/commands/remote_stat.c @@ -1,52 +1,52 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -#ifdef NETLINKS - -#include "netlinks.h" - -/* - * Stat a remote system - */ -void -remote_stat(UR_OBJECT user) -{ - NL_OBJECT nl; - RM_OBJECT rm; - - if (word_count < 2) { - write_user(user, "Usage: rstat \n"); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - nl = rm->netlink; - if (!nl) { - write_user(user, "That room is not linked to a service.\n"); - return; - } - if (nl->stage != UP) { - write_user(user, "Not (fully) connected to service.\n"); - return; - } - if (nl->ver_major <= 3 && nl->ver_minor < 1) { - write_user(user, - "The NUTS version running that service does not support this facility.\n"); - return; - } - sprintf(text, "%s %s\n", netcom[NLC_RSTAT], user->name); - write_sock(nl->socket, text); - write_user(user, "Request sent.\n"); -} - -#else - -#define NO_NETLINKS - -#endif + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +#ifdef NETLINKS + +#include "netlinks.h" + +/* + * Stat a remote system + */ +void +remote_stat(UR_OBJECT user) +{ + NL_OBJECT nl; + RM_OBJECT rm; + + if (word_count < 2) { + write_user(user, "Usage: rstat \n"); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + nl = rm->netlink; + if (!nl) { + write_user(user, "That room is not linked to a service.\n"); + return; + } + if (nl->stage != UP) { + write_user(user, "Not (fully) connected to service.\n"); + return; + } + if (nl->ver_major <= 3 && nl->ver_minor < 1) { + write_user(user, + "The NUTS version running that service does not support this facility.\n"); + return; + } + sprintf(text, "%s %s\n", netcom[NLC_RSTAT], user->name); + write_sock(nl->socket, text); + write_user(user, "Request sent.\n"); +} + +#else + +#define NO_NETLINKS + +#endif diff --git a/src/commands/resite.c b/src/commands/resite.c index a14b96d..10593bd 100644 --- a/src/commands/resite.c +++ b/src/commands/resite.c @@ -1,61 +1,61 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -#ifdef IDENTD - -/* - * For Ident, by Ardant - */ -void -resite(UR_OBJECT user) -{ - char buffer[255]; - UR_OBJECT u; - - if (word_count < 2) { - write_user(user, "Usage: resite |-a\n"); - return; - } - if (!amsys->ident_state) { - write_user(user, "The ident daemon is not active.\n"); - return; - } - if (!strcmp(word[1], "-a")) { - for (u = user_first; u; u = u->next) { - sprintf(buffer, "SITE: %s\n", u->ipsite); - write_sock(amsys->ident_socket, buffer); -#ifdef WIZPORT - sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, - !user->wizport ? amsys->mport_port : amsys->wport_port, - u->ipsite); -#else - sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, - amsys->mport_port, u->ipsite); -#endif - write_sock(amsys->ident_socket, buffer); - } - write_user(user, "Refreshed site lookup of all users.\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - sprintf(buffer, "SITE: %s\n", u->ipsite); - write_sock(amsys->ident_socket, buffer); -#ifdef WIZPORT - sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, - !user->wizport ? amsys->mport_port : amsys->wport_port, u->ipsite); -#else - sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, - amsys->mport_port, u->ipsite); -#endif - write_sock(amsys->ident_socket, buffer); - sprintf(text, "Refreshed site lookup for \"%s\".\n", u->name); - write_user(user, text); -} - +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +#ifdef IDENTD + +/* + * For Ident, by Ardant + */ +void +resite(UR_OBJECT user) +{ + char buffer[255]; + UR_OBJECT u; + + if (word_count < 2) { + write_user(user, "Usage: resite |-a\n"); + return; + } + if (!amsys->ident_state) { + write_user(user, "The ident daemon is not active.\n"); + return; + } + if (!strcmp(word[1], "-a")) { + for (u = user_first; u; u = u->next) { + sprintf(buffer, "SITE: %s\n", u->ipsite); + write_sock(amsys->ident_socket, buffer); +#ifdef WIZPORT + sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, + !user->wizport ? amsys->mport_port : amsys->wport_port, + u->ipsite); +#else + sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, + amsys->mport_port, u->ipsite); +#endif + write_sock(amsys->ident_socket, buffer); + } + write_user(user, "Refreshed site lookup of all users.\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + sprintf(buffer, "SITE: %s\n", u->ipsite); + write_sock(amsys->ident_socket, buffer); +#ifdef WIZPORT + sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, + !user->wizport ? amsys->mport_port : amsys->wport_port, u->ipsite); +#else + sprintf(buffer, "AUTH: %d %s %s %s\n", u->socket, u->site_port, + amsys->mport_port, u->ipsite); +#endif + write_sock(amsys->ident_socket, buffer); + sprintf(text, "Refreshed site lookup for \"%s\".\n", u->name); + write_user(user, text); +} + #endif \ No newline at end of file diff --git a/src/commands/retire.c b/src/commands/retire.c index b5f3d06..5ca7f11 100644 --- a/src/commands/retire.c +++ b/src/commands/retire.c @@ -1,56 +1,56 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Retire a user--i.e., remove from the wizlist but do not alter level - */ -void -retire_user(UR_OBJECT user) -{ - UR_OBJECT u; - int on; - - if (word_count < 2) { - write_user(user, "Usage: retire \n"); - return; - } - if (is_retired(word[1])) { - vwrite_user(user, "%s has already been retired from the wizlist.\n", - word[1]); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - if (u == user) { - write_user(user, "You cannot retire yourself.\n"); - return; - } - if (u->level < WIZ) { - write_user(user, "You cannot retire anyone under the level WIZ\n"); - return; - } - u->retired = 1; - add_retire_list(u->name); - vwrite_user(user, "You retire %s from the wizlist.\n", u->name); - write_syslog(SYSLOG, 1, "%s RETIRED %s\n", user->name, u->name); - sprintf(text, "Was ~FRretired~RS by %s.\n", user->name); - add_history(u->name, 1, "%s", text); - sprintf(text, - "You have been retired from the wizlist but still retain your level.\n"); - if (!on) { - send_mail(user, u->name, text, 0); - } else { - write_user(u, text); - } - if (!on) { - strcpy(u->site, u->last_site); - u->socket = -2; - } - save_user_details(u, on); - done_retrieve(u); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Retire a user--i.e., remove from the wizlist but do not alter level + */ +void +retire_user(UR_OBJECT user) +{ + UR_OBJECT u; + int on; + + if (word_count < 2) { + write_user(user, "Usage: retire \n"); + return; + } + if (is_retired(word[1])) { + vwrite_user(user, "%s has already been retired from the wizlist.\n", + word[1]); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + if (u == user) { + write_user(user, "You cannot retire yourself.\n"); + return; + } + if (u->level < WIZ) { + write_user(user, "You cannot retire anyone under the level WIZ\n"); + return; + } + u->retired = 1; + add_retire_list(u->name); + vwrite_user(user, "You retire %s from the wizlist.\n", u->name); + write_syslog(SYSLOG, 1, "%s RETIRED %s\n", user->name, u->name); + sprintf(text, "Was ~FRretired~RS by %s.\n", user->name); + add_history(u->name, 1, "%s", text); + sprintf(text, + "You have been retired from the wizlist but still retain your level.\n"); + if (!on) { + send_mail(user, u->name, text, 0); + } else { + write_user(u, text); + } + if (!on) { + strcpy(u->site, u->last_site); + u->socket = -2; + } + save_user_details(u, on); + done_retrieve(u); +} diff --git a/src/commands/revafk.c b/src/commands/revafk.c index b14a62b..17ffcdb 100644 --- a/src/commands/revafk.c +++ b/src/commands/revafk.c @@ -1,24 +1,24 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show recorded tells and pemotes - */ -void -revafk(UR_OBJECT user) -{ -#if !!0 - static const char usage[] = "Usage: revafk\n"; -#endif - - start_pager(user); - write_user(user, "\n~BB~FG*** Your AFK review buffer ***\n\n"); - if (!review_buffer(user, rbfAFK)) { - write_user(user, "AFK buffer is empty.\n"); - } - write_user(user, "\n~BB~FG*** End ***\n\n"); - stop_pager(user); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show recorded tells and pemotes + */ +void +revafk(UR_OBJECT user) +{ +#if !!0 + static const char usage[] = "Usage: revafk\n"; +#endif + + start_pager(user); + write_user(user, "\n~BB~FG*** Your AFK review buffer ***\n\n"); + if (!review_buffer(user, rbfAFK)) { + write_user(user, "AFK buffer is empty.\n"); + } + write_user(user, "\n~BB~FG*** End ***\n\n"); + stop_pager(user); +} diff --git a/src/commands/revclr.c b/src/commands/revclr.c index b217d8e..eb48ada 100644 --- a/src/commands/revclr.c +++ b/src/commands/revclr.c @@ -1,23 +1,23 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Clear the review buffer - */ -void -revclr(UR_OBJECT user) -{ -#if !!0 - static const char usage[] = "Usage: cbuff\n"; -#endif - const char *name; - - clear_revbuff(user->room); - name = user->vis ? user->recap : invisname; - vwrite_room_except(user->room, user, "%s~RS clears the review buffer.\n", - name); - write_user(user, "You clear the review buffer.\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Clear the review buffer + */ +void +revclr(UR_OBJECT user) +{ +#if !!0 + static const char usage[] = "Usage: cbuff\n"; +#endif + const char *name; + + clear_revbuff(user->room); + name = user->vis ? user->recap : invisname; + vwrite_room_except(user->room, user, "%s~RS clears the review buffer.\n", + name); + write_user(user, "You clear the review buffer.\n"); +} diff --git a/src/commands/revedit.c b/src/commands/revedit.c index c6e6eff..b54b488 100644 --- a/src/commands/revedit.c +++ b/src/commands/revedit.c @@ -1,24 +1,24 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show recorded tells and pemotes - */ -void -revedit(UR_OBJECT user) -{ -#if !!0 - static const char usage[] = "Usage: revedit\n"; -#endif - - start_pager(user); - write_user(user, "\n~BB~FG*** Your EDIT review buffer ***\n\n"); - if (!review_buffer(user, rbfEDIT)) { - write_user(user, "EDIT buffer is empty.\n"); - } - write_user(user, "\n~BB~FG*** End ***\n\n"); - stop_pager(user); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show recorded tells and pemotes + */ +void +revedit(UR_OBJECT user) +{ +#if !!0 + static const char usage[] = "Usage: revedit\n"; +#endif + + start_pager(user); + write_user(user, "\n~BB~FG*** Your EDIT review buffer ***\n\n"); + if (!review_buffer(user, rbfEDIT)) { + write_user(user, "EDIT buffer is empty.\n"); + } + write_user(user, "\n~BB~FG*** End ***\n\n"); + stop_pager(user); +} diff --git a/src/commands/review.c b/src/commands/review.c index 3776ee1..b55f6bb 100644 --- a/src/commands/review.c +++ b/src/commands/review.c @@ -1,63 +1,63 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * See review of conversation - */ -void -review(UR_OBJECT user) -{ -#if !!0 - static const char usage[] = "Usage: review\n"; -#endif - RM_OBJECT rm; - int i, line, cnt; - - if (word_count < 2 || user->level < GOD) { - rm = user->room; - } else { - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - if (!has_room_access(user, rm)) { - write_user(user, - "That room is currently private, you cannot review the conversation.\n"); - return; - } - vwrite_user(user, "~FC(Review of %s room)\n", rm->name); - } - cnt = 0; - start_pager(user); - if (user->reverse_buffer) { - for (i = REVIEW_LINES - 1; i >= 0; --i) { - line = (rm->revline + i) % REVIEW_LINES; - if (*rm->revbuff[line]) { - if (!cnt++) { - write_user(user, "\n~BB~FG*** Room conversation buffer ***\n\n"); - } - write_user(user, rm->revbuff[line]); - } - } - } else { - for (i = 0; i < REVIEW_LINES; ++i) { - line = (rm->revline + i) % REVIEW_LINES; - if (*rm->revbuff[line]) { - if (!cnt++) { - write_user(user, "\n~BB~FG*** Room conversation buffer ***\n\n"); - } - write_user(user, rm->revbuff[line]); - } - } - } - if (!cnt) { - write_user(user, "Review buffer is empty.\n"); - } else { - write_user(user, "\n~BB~FG*** End ***\n\n"); - } - stop_pager(user); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * See review of conversation + */ +void +review(UR_OBJECT user) +{ +#if !!0 + static const char usage[] = "Usage: review\n"; +#endif + RM_OBJECT rm; + int i, line, cnt; + + if (word_count < 2 || user->level < GOD) { + rm = user->room; + } else { + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + if (!has_room_access(user, rm)) { + write_user(user, + "That room is currently private, you cannot review the conversation.\n"); + return; + } + vwrite_user(user, "~FC(Review of %s room)\n", rm->name); + } + cnt = 0; + start_pager(user); + if (user->reverse_buffer) { + for (i = REVIEW_LINES - 1; i >= 0; --i) { + line = (rm->revline + i) % REVIEW_LINES; + if (*rm->revbuff[line]) { + if (!cnt++) { + write_user(user, "\n~BB~FG*** Room conversation buffer ***\n\n"); + } + write_user(user, rm->revbuff[line]); + } + } + } else { + for (i = 0; i < REVIEW_LINES; ++i) { + line = (rm->revline + i) % REVIEW_LINES; + if (*rm->revbuff[line]) { + if (!cnt++) { + write_user(user, "\n~BB~FG*** Room conversation buffer ***\n\n"); + } + write_user(user, rm->revbuff[line]); + } + } + } + if (!cnt) { + write_user(user, "Review buffer is empty.\n"); + } else { + write_user(user, "\n~BB~FG*** End ***\n\n"); + } + stop_pager(user); +} diff --git a/src/commands/revshout.c b/src/commands/revshout.c index cbde870..90ce20b 100644 --- a/src/commands/revshout.c +++ b/src/commands/revshout.c @@ -1,47 +1,47 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * See review of shouts - */ -void -revshout(UR_OBJECT user) -{ -#if !!0 - static const char usage[] = "Usage: revshout\n"; -#endif - int i, line, cnt; - - cnt = 0; - start_pager(user); - if (user->reverse_buffer) { - for (i = REVIEW_LINES - 1; i >= 0; --i) { - line = (amsys->sbuffline + i) % REVIEW_LINES; - if (*amsys->shoutbuff[line]) { - if (!cnt++) { - write_user(user, "~BB~FG*** Shout review buffer ***\n\n"); - } - write_user(user, amsys->shoutbuff[line]); - } - } - } else { - for (i = 0; i < REVIEW_LINES; ++i) { - line = (amsys->sbuffline + i) % REVIEW_LINES; - if (*amsys->shoutbuff[line]) { - if (!cnt++) { - write_user(user, "~BB~FG*** Shout review buffer ***\n\n"); - } - write_user(user, amsys->shoutbuff[line]); - } - } - } - if (!cnt) { - write_user(user, "Shout review buffer is empty.\n"); - } else { - write_user(user, "\n~BB~FG*** End ***\n\n"); - } - stop_pager(user); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * See review of shouts + */ +void +revshout(UR_OBJECT user) +{ +#if !!0 + static const char usage[] = "Usage: revshout\n"; +#endif + int i, line, cnt; + + cnt = 0; + start_pager(user); + if (user->reverse_buffer) { + for (i = REVIEW_LINES - 1; i >= 0; --i) { + line = (amsys->sbuffline + i) % REVIEW_LINES; + if (*amsys->shoutbuff[line]) { + if (!cnt++) { + write_user(user, "~BB~FG*** Shout review buffer ***\n\n"); + } + write_user(user, amsys->shoutbuff[line]); + } + } + } else { + for (i = 0; i < REVIEW_LINES; ++i) { + line = (amsys->sbuffline + i) % REVIEW_LINES; + if (*amsys->shoutbuff[line]) { + if (!cnt++) { + write_user(user, "~BB~FG*** Shout review buffer ***\n\n"); + } + write_user(user, amsys->shoutbuff[line]); + } + } + } + if (!cnt) { + write_user(user, "Shout review buffer is empty.\n"); + } else { + write_user(user, "\n~BB~FG*** End ***\n\n"); + } + stop_pager(user); +} diff --git a/src/commands/revtell.c b/src/commands/revtell.c index adaecfd..4c373fa 100644 --- a/src/commands/revtell.c +++ b/src/commands/revtell.c @@ -1,24 +1,24 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show recorded tells and pemotes - */ -void -revtell(UR_OBJECT user) -{ -#if !!0 - static const char usage[] = "Usage: revtell\n"; -#endif - - start_pager(user); - write_user(user, "\n~BB~FG*** Your tell buffer ***\n\n"); - if (!review_buffer(user, rbfTELL)) { - write_user(user, "Revtell buffer is empty.\n"); - } - write_user(user, "\n~BB~FG*** End ***\n\n"); - stop_pager(user); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show recorded tells and pemotes + */ +void +revtell(UR_OBJECT user) +{ +#if !!0 + static const char usage[] = "Usage: revtell\n"; +#endif + + start_pager(user); + write_user(user, "\n~BB~FG*** Your tell buffer ***\n\n"); + if (!review_buffer(user, rbfTELL)) { + write_user(user, "Revtell buffer is empty.\n"); + } + write_user(user, "\n~BB~FG*** End ***\n\n"); + stop_pager(user); +} diff --git a/src/commands/rmail.c b/src/commands/rmail.c index 0baaef9..fe1c706 100644 --- a/src/commands/rmail.c +++ b/src/commands/rmail.c @@ -1,40 +1,40 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Read your mail - */ -void -rmail(UR_OBJECT user) -{ - char filename[80]; - int ret; - - sprintf(filename, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); - - /* Just reading the one message or all new mail */ - if (word_count > 1) { - strtolower(word[1]); - if (!strcmp(word[1], "new")) { - read_new_mail(user); - } else { - read_specific_mail(user); - } - return; - } - /* Update last read / new mail received time at head of file */ - if (!reset_mail_counts(user)) { - write_user(user, "You do not have any mail.\n"); - return; - } - /* Reading the whole mail box */ - write_user(user, "\n~BB*** Your mailbox has the following messages ***\n\n"); - user->filepos = 0; - ret = more(user, user->socket, filename); - if (ret == 1) { - user->misc_op = 2; - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Read your mail + */ +void +rmail(UR_OBJECT user) +{ + char filename[80]; + int ret; + + sprintf(filename, "%s/%s/%s.M", USERFILES, USERMAILS, user->name); + + /* Just reading the one message or all new mail */ + if (word_count > 1) { + strtolower(word[1]); + if (!strcmp(word[1], "new")) { + read_new_mail(user); + } else { + read_specific_mail(user); + } + return; + } + /* Update last read / new mail received time at head of file */ + if (!reset_mail_counts(user)) { + write_user(user, "You do not have any mail.\n"); + return; + } + /* Reading the whole mail box */ + write_user(user, "\n~BB*** Your mailbox has the following messages ***\n\n"); + user->filepos = 0; + ret = more(user, user->socket, filename); + if (ret == 1) { + user->misc_op = 2; + } +} diff --git a/src/commands/room.c b/src/commands/room.c index b269e5e..50a69bf 100644 --- a/src/commands/room.c +++ b/src/commands/room.c @@ -1,160 +1,160 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" -#include "rooms.h" - -/* - * Show talker rooms - */ -void -rooms(UR_OBJECT user, int show_topics, int wrap) -{ - RM_OBJECT rm; - UR_OBJECT u; -#ifdef NETLINKS - NL_OBJECT nl; - char serv[SERV_NAME_LEN + 1], nstat[9]; - char rmaccess[9]; -#endif - int cnt, rm_cnt, rm_pub, rm_priv; - - if (word_count < 2) { - if (!wrap) { - user->wrap_room = room_first; - } - if (show_topics) { - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "~FC~OLpl u/m~RS | ~OL~FCname~RS - ~FC~OLtopic\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } else { - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "~FC~OLRoom name ~RS|~FC~OL Access Users Mesgs Inlink LStat Service\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } - rm_cnt = 0; - for (rm = user->wrap_room; rm; rm = rm->next) { - if (is_personal_room(rm)) { - continue; - } - if (rm_cnt == user->pager - 4) { - switch (show_topics) { - case 0: - user->misc_op = 10; - break; - case 1: - user->misc_op = 11; - break; - } - write_user(user, "~BB~FG-=[*]=- PRESS , E TO EXIT:~RS "); - return; - } - cnt = 0; - for (u = user_first; u; u = u->next) - if (u->type != CLONE_TYPE && u->room == rm) { - ++cnt; - } - if (show_topics) { - vwrite_user(user, "%c%c %2d/%-2d | %s%-20.20s~RS - %s\n", - is_private_room(rm) ? 'P' : ' ', - is_fixed_room(rm) ? '*' : ' ', cnt, rm->mesg_cnt, - is_private_room(rm) ? "~FR~OL" : "", rm->name, rm->topic); - } -#ifdef NETLINKS - else { - if (is_private_room(rm)) { - strcpy(rmaccess, " ~FRPRIV"); - } else { - strcpy(rmaccess, " ~FGPUB "); - } - if (is_fixed_room(rm)) { - *rmaccess = '*'; - } - nl = rm->netlink; - *serv = '\0'; - if (!nl) { - if (rm->inlink) { - strcpy(nstat, " ~FRDOWN"); - } else { - strcpy(nstat, " -"); - } - } else { - if (nl->type == UNCONNECTED) { - strcpy(nstat, " ~FRDOWN"); - } else if (nl->stage == UP) { - strcpy(nstat, " ~FGUP"); - } else { - strcpy(nstat, " ~FYVER"); - } - } - if (nl) { - strcpy(serv, nl->service); - } - vwrite_user(user, "%-20s | %9s~RS %5d %5d %-6s %s~RS %s\n", - rm->name, rmaccess, cnt, rm->mesg_cnt, noyes[rm->inlink], - nstat, serv); - } -#endif - ++rm_cnt; - user->wrap_room = rm->next; - } - user->misc_op = 0; - rm_pub = rm_priv = 0; - for (rm = room_first; rm; rm = rm->next) { - if (is_personal_room(rm)) { - continue; - } - if (is_private_room(rm)) { - ++rm_priv; - } else { - ++rm_pub; - } - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, - "There is a total of ~OL%d~RS rooms. ~OL%d~RS %s public, and ~OL%d~RS %s private.\n", - rm_priv + rm_pub, rm_pub, PLTEXT_IS(rm_pub), rm_priv, - PLTEXT_IS(rm_priv)); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - if (!strcasecmp(word[1], "-l")) { - write_user(user, "The following rooms are default...\n\n"); - vwrite_user(user, "Default main room : ~OL%s\n", room_first->name); - vwrite_user(user, "Default warp room : ~OL%s\n", - *amsys->default_warp ? amsys->default_warp : ""); - vwrite_user(user, "Default jail room : ~OL%s\n", - *amsys->default_jail ? amsys->default_jail : ""); -#ifdef GAMES - vwrite_user(user, "Default bank room : ~OL%s\n", - *amsys->default_bank ? amsys->default_bank : ""); - vwrite_user(user, "Default shoot room : ~OL%s\n", - *amsys->default_shoot ? amsys->default_shoot : ""); -#endif - if (!priv_room[0].name) { - write_user(user, - "\nThere are no level specific rooms currently availiable.\n\n"); - return; - } - write_user(user, "\nThe following rooms are level specific...\n\n"); - for (cnt = 0; priv_room[cnt].name; ++cnt) { - vwrite_user(user, - "~FC%s~RS is for users of level ~OL%s~RS and above.\n", - priv_room[cnt].name, user_level[priv_room[cnt].level].name); - } - vwrite_user(user, - "\nThere is a total of ~OL%d~RS level specific rooms.\n\n", - cnt); - return; - } - write_user(user, "Usage: rooms [-l]\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" +#include "rooms.h" + +/* + * Show talker rooms + */ +void +rooms(UR_OBJECT user, int show_topics, int wrap) +{ + RM_OBJECT rm; + UR_OBJECT u; +#ifdef NETLINKS + NL_OBJECT nl; + char serv[SERV_NAME_LEN + 1], nstat[9]; + char rmaccess[9]; +#endif + int cnt, rm_cnt, rm_pub, rm_priv; + + if (word_count < 2) { + if (!wrap) { + user->wrap_room = room_first; + } + if (show_topics) { + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "~FC~OLpl u/m~RS | ~OL~FCname~RS - ~FC~OLtopic\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } else { + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "~FC~OLRoom name ~RS|~FC~OL Access Users Mesgs Inlink LStat Service\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } + rm_cnt = 0; + for (rm = user->wrap_room; rm; rm = rm->next) { + if (is_personal_room(rm)) { + continue; + } + if (rm_cnt == user->pager - 4) { + switch (show_topics) { + case 0: + user->misc_op = 10; + break; + case 1: + user->misc_op = 11; + break; + } + write_user(user, "~BB~FG-=[*]=- PRESS , E TO EXIT:~RS "); + return; + } + cnt = 0; + for (u = user_first; u; u = u->next) + if (u->type != CLONE_TYPE && u->room == rm) { + ++cnt; + } + if (show_topics) { + vwrite_user(user, "%c%c %2d/%-2d | %s%-20.20s~RS - %s\n", + is_private_room(rm) ? 'P' : ' ', + is_fixed_room(rm) ? '*' : ' ', cnt, rm->mesg_cnt, + is_private_room(rm) ? "~FR~OL" : "", rm->name, rm->topic); + } +#ifdef NETLINKS + else { + if (is_private_room(rm)) { + strcpy(rmaccess, " ~FRPRIV"); + } else { + strcpy(rmaccess, " ~FGPUB "); + } + if (is_fixed_room(rm)) { + *rmaccess = '*'; + } + nl = rm->netlink; + *serv = '\0'; + if (!nl) { + if (rm->inlink) { + strcpy(nstat, " ~FRDOWN"); + } else { + strcpy(nstat, " -"); + } + } else { + if (nl->type == UNCONNECTED) { + strcpy(nstat, " ~FRDOWN"); + } else if (nl->stage == UP) { + strcpy(nstat, " ~FGUP"); + } else { + strcpy(nstat, " ~FYVER"); + } + } + if (nl) { + strcpy(serv, nl->service); + } + vwrite_user(user, "%-20s | %9s~RS %5d %5d %-6s %s~RS %s\n", + rm->name, rmaccess, cnt, rm->mesg_cnt, noyes[rm->inlink], + nstat, serv); + } +#endif + ++rm_cnt; + user->wrap_room = rm->next; + } + user->misc_op = 0; + rm_pub = rm_priv = 0; + for (rm = room_first; rm; rm = rm->next) { + if (is_personal_room(rm)) { + continue; + } + if (is_private_room(rm)) { + ++rm_priv; + } else { + ++rm_pub; + } + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, + "There is a total of ~OL%d~RS rooms. ~OL%d~RS %s public, and ~OL%d~RS %s private.\n", + rm_priv + rm_pub, rm_pub, PLTEXT_IS(rm_pub), rm_priv, + PLTEXT_IS(rm_priv)); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + if (!strcasecmp(word[1], "-l")) { + write_user(user, "The following rooms are default...\n\n"); + vwrite_user(user, "Default main room : ~OL%s\n", room_first->name); + vwrite_user(user, "Default warp room : ~OL%s\n", + *amsys->default_warp ? amsys->default_warp : ""); + vwrite_user(user, "Default jail room : ~OL%s\n", + *amsys->default_jail ? amsys->default_jail : ""); +#ifdef GAMES + vwrite_user(user, "Default bank room : ~OL%s\n", + *amsys->default_bank ? amsys->default_bank : ""); + vwrite_user(user, "Default shoot room : ~OL%s\n", + *amsys->default_shoot ? amsys->default_shoot : ""); +#endif + if (!priv_room[0].name) { + write_user(user, + "\nThere are no level specific rooms currently availiable.\n\n"); + return; + } + write_user(user, "\nThe following rooms are level specific...\n\n"); + for (cnt = 0; priv_room[cnt].name; ++cnt) { + vwrite_user(user, + "~FC%s~RS is for users of level ~OL%s~RS and above.\n", + priv_room[cnt].name, user_level[priv_room[cnt].level].name); + } + vwrite_user(user, + "\nThere is a total of ~OL%d~RS level specific rooms.\n\n", + cnt); + return; + } + write_user(user, "Usage: rooms [-l]\n"); +} diff --git a/src/commands/samesite.c b/src/commands/samesite.c index e505e1e..56911d7 100644 --- a/src/commands/samesite.c +++ b/src/commands/samesite.c @@ -1,259 +1,259 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Display all the people logged on from the same site as user - */ -void -samesite(UR_OBJECT user, int stage) -{ - UR_OBJECT u, u_loop; - UD_OBJECT entry; - int found, cnt, same, on; - - on = 0; - if (!stage) { - if (word_count < 2) { - write_user(user, "Usage: samesite user|site [all]\n"); - return; - } - if (word_count == 3 && !strcasecmp(word[2], "all")) { - user->samesite_all_store = 1; - } else { - user->samesite_all_store = 0; - } - if (!strcasecmp(word[1], "user")) { - write_user(user, "Enter the name of the user to be checked against: "); - user->misc_op = 12; - return; - } - if (!strcasecmp(word[1], "site")) { - write_user(user, - "~OL~FRNOTE:~RS Wildcards \"*\" and \"?\" can be used.\n"); - write_user(user, "Enter the site to be checked against: "); - user->misc_op = 13; - return; - } - write_user(user, "Usage: samesite user|site [all]\n"); - return; - } - /* check for users of same site - user supplied */ - if (stage == 1) { - /* check just those logged on */ - if (!user->samesite_all_store) { - found = cnt = same = 0; - u = get_user(user->samesite_check_store); - if (!u) { - write_user(user, notloggedon); - return; - } - for (u_loop = user_first; u_loop; u_loop = u_loop->next) { - ++cnt; - if (u_loop == u) { - continue; - } - if (!strcmp(u->site, u_loop->site)) { - ++same; - if (!found++) { - vwrite_user(user, - "\n~BB~FG*** Users logged on from the same site as ~OL%s~RS~BB~FG ***\n\n", - u->name); - } - sprintf(text, " %s %s\n", u_loop->name, u_loop->desc); - if (u_loop->type == REMOTE_TYPE) { - text[2] = '@'; - } - if (!u_loop->vis) { - text[3] = '*'; - } - write_user(user, text); - } - } - if (!found) { - vwrite_user(user, - "No users currently logged on have the same site as %s.\n", - u->name); - } else { - vwrite_user(user, - "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s~RS ~FG(%s)\n\n", - cnt, same, u->name, u->site); - } - return; - } - /* check all the users.. First, load the name given */ - u = get_user(user->samesite_check_store); - on = !!u; - if (!on) { - u = create_user(); - if (!u) { - vwrite_user(user, "%s: unable to create temporary user session.\n", - syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to create temporary user session in samesite() - stage 1 of all.\n"); - return; - } - strcpy(u->name, user->samesite_check_store); - if (!load_user_details(u)) { - destruct_user(u); - destructed = 0; - vwrite_user(user, "Sorry, unable to load user file for %s.\n", - user->samesite_check_store); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to load user details in samesite() - stage 1 of all.\n"); - return; - } - } - /* read userlist and check against all users */ - found = cnt = same = 0; - for (entry = first_user_entry; entry; entry = entry->next) { - *entry->name = toupper(*entry->name); /* just incase */ - /* create a user object if user not already logged on */ - u_loop = create_user(); - if (!u_loop) { - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to create temporary user session in samesite().\n"); - continue; - } - strcpy(u_loop->name, entry->name); - if (!load_user_details(u_loop)) { - destruct_user(u_loop); - destructed = 0; - continue; - } - ++cnt; - if ((on && !strcmp(u->site, u_loop->last_site)) - || (!on && !strcmp(u->last_site, u_loop->last_site))) { - ++same; - if (!found++) { - vwrite_user(user, - "\n~BB~FG*** All users from the same site as ~OL%s~RS~BB~FG ***\n\n", - u->name); - } - vwrite_user(user, " %s %s\n", u_loop->name, u_loop->desc); - destruct_user(u_loop); - destructed = 0; - continue; - } - destruct_user(u_loop); - destructed = 0; - } - if (!found) { - vwrite_user(user, "No users have the same site as %s.\n", u->name); - } else { - if (!on) { - vwrite_user(user, - "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s~RS ~FG(%s)\n\n", - cnt, same, u->name, u->last_site); - } else { - vwrite_user(user, - "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s~RS ~FG(%s)\n\n", - cnt, same, u->name, u->site); - } - } - if (!on) { - destruct_user(u); - destructed = 0; - } - return; - } - /* check for users of same site - site supplied */ - if (stage == 2) { - /* check any wildcards are correct */ - if (strstr(user->samesite_check_store, "**")) { - write_user(user, "You cannot have ** in your site to check.\n"); - return; - } - if (strstr(user->samesite_check_store, "?*")) { - write_user(user, "You cannot have ?* in your site to check.\n"); - return; - } - if (strstr(user->samesite_check_store, "*?")) { - write_user(user, "You cannot have *? in your site to check.\n"); - return; - } - /* check just those logged on */ - if (!user->samesite_all_store) { - found = cnt = same = 0; - for (u = user_first; u; u = u->next) { - ++cnt; - if (!pattern_match(u->site, user->samesite_check_store)) { - continue; - } - ++same; - if (!found++) { - vwrite_user(user, - "\n~BB~FG*** Users logged on from the same site as ~OL%s~RS~BB~FG ***\n\n", - user->samesite_check_store); - } - sprintf(text, " %s %s\n", u->name, u->desc); - if (u->type == REMOTE_TYPE) { - text[2] = '@'; - } - if (!u->vis) { - text[3] = '*'; - } - write_user(user, text); - } - if (!found) { - vwrite_user(user, - "No users currently logged on have that same site as %s.\n", - user->samesite_check_store); - } else { - vwrite_user(user, - "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s\n\n", - cnt, same, user->samesite_check_store); - } - return; - } - /* check all the users.. */ - /* open userlist to check against all users */ - found = cnt = same = 0; - for (entry = first_user_entry; entry; entry = entry->next) { - *entry->name = toupper(*entry->name); - /* create a user object if user not already logged on */ - u_loop = create_user(); - if (!u_loop) { - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Unable to create temporary user session in samesite().\n"); - continue; - } - strcpy(u_loop->name, entry->name); - if (!load_user_details(u_loop)) { - destruct_user(u_loop); - destructed = 0; - continue; - } - ++cnt; - if ((pattern_match(u_loop->last_site, user->samesite_check_store))) { - ++same; - if (!found++) { - vwrite_user(user, - "\n~BB~FG*** All users that have the site ~OL%s~RS~BB~FG ***\n\n", - user->samesite_check_store); - } - vwrite_user(user, " %s %s\n", u_loop->name, u_loop->desc); - } - destruct_user(u_loop); - destructed = 0; - } - if (!found) { - vwrite_user(user, "No users have the same site as %s.\n", - user->samesite_check_store); - } else { - if (!on) { - vwrite_user(user, - "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s\n\n", - cnt, same, user->samesite_check_store); - } else { - vwrite_user(user, - "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s\n\n", - cnt, same, user->samesite_check_store); - } - } - return; - } -} - + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Display all the people logged on from the same site as user + */ +void +samesite(UR_OBJECT user, int stage) +{ + UR_OBJECT u, u_loop; + UD_OBJECT entry; + int found, cnt, same, on; + + on = 0; + if (!stage) { + if (word_count < 2) { + write_user(user, "Usage: samesite user|site [all]\n"); + return; + } + if (word_count == 3 && !strcasecmp(word[2], "all")) { + user->samesite_all_store = 1; + } else { + user->samesite_all_store = 0; + } + if (!strcasecmp(word[1], "user")) { + write_user(user, "Enter the name of the user to be checked against: "); + user->misc_op = 12; + return; + } + if (!strcasecmp(word[1], "site")) { + write_user(user, + "~OL~FRNOTE:~RS Wildcards \"*\" and \"?\" can be used.\n"); + write_user(user, "Enter the site to be checked against: "); + user->misc_op = 13; + return; + } + write_user(user, "Usage: samesite user|site [all]\n"); + return; + } + /* check for users of same site - user supplied */ + if (stage == 1) { + /* check just those logged on */ + if (!user->samesite_all_store) { + found = cnt = same = 0; + u = get_user(user->samesite_check_store); + if (!u) { + write_user(user, notloggedon); + return; + } + for (u_loop = user_first; u_loop; u_loop = u_loop->next) { + ++cnt; + if (u_loop == u) { + continue; + } + if (!strcmp(u->site, u_loop->site)) { + ++same; + if (!found++) { + vwrite_user(user, + "\n~BB~FG*** Users logged on from the same site as ~OL%s~RS~BB~FG ***\n\n", + u->name); + } + sprintf(text, " %s %s\n", u_loop->name, u_loop->desc); + if (u_loop->type == REMOTE_TYPE) { + text[2] = '@'; + } + if (!u_loop->vis) { + text[3] = '*'; + } + write_user(user, text); + } + } + if (!found) { + vwrite_user(user, + "No users currently logged on have the same site as %s.\n", + u->name); + } else { + vwrite_user(user, + "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s~RS ~FG(%s)\n\n", + cnt, same, u->name, u->site); + } + return; + } + /* check all the users.. First, load the name given */ + u = get_user(user->samesite_check_store); + on = !!u; + if (!on) { + u = create_user(); + if (!u) { + vwrite_user(user, "%s: unable to create temporary user session.\n", + syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to create temporary user session in samesite() - stage 1 of all.\n"); + return; + } + strcpy(u->name, user->samesite_check_store); + if (!load_user_details(u)) { + destruct_user(u); + destructed = 0; + vwrite_user(user, "Sorry, unable to load user file for %s.\n", + user->samesite_check_store); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to load user details in samesite() - stage 1 of all.\n"); + return; + } + } + /* read userlist and check against all users */ + found = cnt = same = 0; + for (entry = first_user_entry; entry; entry = entry->next) { + *entry->name = toupper(*entry->name); /* just in case */ + /* create a user object if user not already logged on */ + u_loop = create_user(); + if (!u_loop) { + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to create temporary user session in samesite().\n"); + continue; + } + strcpy(u_loop->name, entry->name); + if (!load_user_details(u_loop)) { + destruct_user(u_loop); + destructed = 0; + continue; + } + ++cnt; + if ((on && !strcmp(u->site, u_loop->last_site)) + || (!on && !strcmp(u->last_site, u_loop->last_site))) { + ++same; + if (!found++) { + vwrite_user(user, + "\n~BB~FG*** All users from the same site as ~OL%s~RS~BB~FG ***\n\n", + u->name); + } + vwrite_user(user, " %s %s\n", u_loop->name, u_loop->desc); + destruct_user(u_loop); + destructed = 0; + continue; + } + destruct_user(u_loop); + destructed = 0; + } + if (!found) { + vwrite_user(user, "No users have the same site as %s.\n", u->name); + } else { + if (!on) { + vwrite_user(user, + "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s~RS ~FG(%s)\n\n", + cnt, same, u->name, u->last_site); + } else { + vwrite_user(user, + "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s~RS ~FG(%s)\n\n", + cnt, same, u->name, u->site); + } + } + if (!on) { + destruct_user(u); + destructed = 0; + } + return; + } + /* check for users of same site - site supplied */ + if (stage == 2) { + /* check any wildcards are correct */ + if (strstr(user->samesite_check_store, "**")) { + write_user(user, "You cannot have ** in your site to check.\n"); + return; + } + if (strstr(user->samesite_check_store, "?*")) { + write_user(user, "You cannot have ?* in your site to check.\n"); + return; + } + if (strstr(user->samesite_check_store, "*?")) { + write_user(user, "You cannot have *? in your site to check.\n"); + return; + } + /* check just those logged on */ + if (!user->samesite_all_store) { + found = cnt = same = 0; + for (u = user_first; u; u = u->next) { + ++cnt; + if (!pattern_match(u->site, user->samesite_check_store)) { + continue; + } + ++same; + if (!found++) { + vwrite_user(user, + "\n~BB~FG*** Users logged on from the same site as ~OL%s~RS~BB~FG ***\n\n", + user->samesite_check_store); + } + sprintf(text, " %s %s\n", u->name, u->desc); + if (u->type == REMOTE_TYPE) { + text[2] = '@'; + } + if (!u->vis) { + text[3] = '*'; + } + write_user(user, text); + } + if (!found) { + vwrite_user(user, + "No users currently logged on have that same site as %s.\n", + user->samesite_check_store); + } else { + vwrite_user(user, + "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s\n\n", + cnt, same, user->samesite_check_store); + } + return; + } + /* check all the users.. */ + /* open userlist to check against all users */ + found = cnt = same = 0; + for (entry = first_user_entry; entry; entry = entry->next) { + *entry->name = toupper(*entry->name); + /* create a user object if user not already logged on */ + u_loop = create_user(); + if (!u_loop) { + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Unable to create temporary user session in samesite().\n"); + continue; + } + strcpy(u_loop->name, entry->name); + if (!load_user_details(u_loop)) { + destruct_user(u_loop); + destructed = 0; + continue; + } + ++cnt; + if ((pattern_match(u_loop->last_site, user->samesite_check_store))) { + ++same; + if (!found++) { + vwrite_user(user, + "\n~BB~FG*** All users that have the site ~OL%s~RS~BB~FG ***\n\n", + user->samesite_check_store); + } + vwrite_user(user, " %s %s\n", u_loop->name, u_loop->desc); + } + destruct_user(u_loop); + destructed = 0; + } + if (!found) { + vwrite_user(user, "No users have the same site as %s.\n", + user->samesite_check_store); + } else { + if (!on) { + vwrite_user(user, + "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s\n\n", + cnt, same, user->samesite_check_store); + } else { + vwrite_user(user, + "\nChecked ~FM~OL%d~RS users, ~FM~OL%d~RS had the site as ~FG~OL%s\n\n", + cnt, same, user->samesite_check_store); + } + } + return; + } +} + diff --git a/src/commands/search_boards.c b/src/commands/search_boards.c index 2974acd..5e5e0f6 100644 --- a/src/commands/search_boards.c +++ b/src/commands/search_boards.c @@ -1,83 +1,83 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Search all the boards for the words given in the list. Rooms fixed to - * private will be ignore if the users level is less than gatecrash_level - */ -void -search_boards(UR_OBJECT user) -{ - char filename[80], line[82], buff[(MAX_LINES + 1) * 82], w1[81], *s; - FILE *fp; - RM_OBJECT rm; - int w, cnt, message, yes, room_given; - - if (word_count < 2) { - write_user(user, "Usage: search \n"); - return; - } - /* Go through rooms */ - cnt = 0; - for (rm = room_first; rm; rm = rm->next) { - if (!has_room_access(user, rm)) { - continue; - } - if (is_personal_room(rm)) { - sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); - } else { - sprintf(filename, "%s/%s.B", DATAFILES, rm->name); - } - fp = fopen(filename, "r"); - if (!fp) { - continue; - } - /* Go through file */ - *buff = '\0'; - yes = message = room_given = 0; - for (s = fgets(line, 81, fp); s; s = fgets(line, 81, fp)) { - if (*s == '\n') { - if (yes) { - strcat(buff, "\n"); - write_user(user, buff); - } - message = yes = 0; - *buff = '\0'; - } - if (!message) { - *w1 = '\0'; - sscanf(s, "%s", w1); - if (!strcmp(w1, "PT:")) { - message = 1; - strcpy(buff, remove_first(remove_first(s))); - } - } else { - strcat(buff, s); - } - for (w = 1; w < word_count; ++w) { - if (!yes && strstr(s, word[w])) { - if (!room_given) { - vwrite_user(user, "~BB*** %s ***\n\n", rm->name); - room_given = 1; - } - yes = 1; - ++cnt; - } - } - } - if (yes) { - strcat(buff, "\n"); - write_user(user, buff); - } - fclose(fp); - } - if (cnt) { - vwrite_user(user, "Total of %d matching message%s.\n\n", cnt, - PLTEXT_S(cnt)); - } else { - write_user(user, "No occurences found.\n"); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Search all the boards for the words given in the list. Rooms fixed to + * private will be ignore if the users level is less than gatecrash_level + */ +void +search_boards(UR_OBJECT user) +{ + char filename[80], line[82], buff[(MAX_LINES + 1) * 82], w1[81], *s; + FILE *fp; + RM_OBJECT rm; + int w, cnt, message, yes, room_given; + + if (word_count < 2) { + write_user(user, "Usage: search \n"); + return; + } + /* Go through rooms */ + cnt = 0; + for (rm = room_first; rm; rm = rm->next) { + if (!has_room_access(user, rm)) { + continue; + } + if (is_personal_room(rm)) { + sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); + } else { + sprintf(filename, "%s/%s.B", DATAFILES, rm->name); + } + fp = fopen(filename, "r"); + if (!fp) { + continue; + } + /* Go through file */ + *buff = '\0'; + yes = message = room_given = 0; + for (s = fgets(line, 81, fp); s; s = fgets(line, 81, fp)) { + if (*s == '\n') { + if (yes) { + strcat(buff, "\n"); + write_user(user, buff); + } + message = yes = 0; + *buff = '\0'; + } + if (!message) { + *w1 = '\0'; + sscanf(s, "%s", w1); + if (!strcmp(w1, "PT:")) { + message = 1; + strcpy(buff, remove_first(remove_first(s))); + } + } else { + strcat(buff, s); + } + for (w = 1; w < word_count; ++w) { + if (!yes && strstr(s, word[w])) { + if (!room_given) { + vwrite_user(user, "~BB*** %s ***\n\n", rm->name); + room_given = 1; + } + yes = 1; + ++cnt; + } + } + } + if (yes) { + strcat(buff, "\n"); + write_user(user, buff); + } + fclose(fp); + } + if (cnt) { + vwrite_user(user, "Total of %d matching message%s.\n\n", cnt, + PLTEXT_S(cnt)); + } else { + write_user(user, "No occurences found.\n"); + } +} diff --git a/src/commands/semote.c b/src/commands/semote.c index f2d29be..25f7a87 100644 --- a/src/commands/semote.c +++ b/src/commands/semote.c @@ -1,48 +1,48 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Do a shout emote - */ -void -semote(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: semote \n"; - const char *name; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot emote.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - if (!user->vis) { - write_monitor(user, NULL, 0); - } - name = user->vis ? user->recap : invisname; - sprintf(text, "~OL!~RS %s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", - inpstr); - record_shout(text); - write_room_ignore(NULL, user, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Do a shout emote + */ +void +semote(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: semote \n"; + const char *name; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot emote.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + if (!user->vis) { + write_monitor(user, NULL, 0); + } + name = user->vis ? user->recap : invisname; + sprintf(text, "~OL!~RS %s~RS%s%s\n", name, *inpstr != '\'' ? " " : "", + inpstr); + record_shout(text); + write_room_ignore(NULL, user, text); +} diff --git a/src/commands/set.c b/src/commands/set.c index 4daf7d9..fdcacdd 100644 --- a/src/commands/set.c +++ b/src/commands/set.c @@ -1,313 +1,313 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set the user attributes - */ -void -set_attributes(UR_OBJECT user) -{ - char name[USER_NAME_LEN + 1], *recname; - int i, tmp; - - if (word_count < 2) { - i = -1; - } else { - /* FIXME: Add abbreviated matching like help() does */ - for (i = 0; setstr[i].type; ++i) { - if (!strcasecmp(setstr[i].type, word[1])) { - break; - } - } - if (!setstr[i].type) { - i = -1; - } - } - if (i == -1) { - write_user(user, "Attributes you can set are:\n\n"); - for (i = 0; setstr[i].type; ++i) { - vwrite_user(user, "~FC%s~RS : %s\n", setstr[i].type, setstr[i].desc); - } - write_user(user, "\n"); - return; - } - write_user(user, "\n"); - switch (i) { - case SETSHOW: - show_attributes(user); - return; - case SETGEND: - *word[2] = tolower(*word[2]); - if (*word[2] == 'm' || *word[2] == 'f' || *word[2] == 'n') { - switch (*word[2]) { - case 'm': - user->gender = MALE; - write_user(user, "Gender set to Male\n"); - break; - case 'f': - user->gender = FEMALE; - write_user(user, "Gender set to Female\n"); - break; - case 'n': - user->gender = NEUTER; - write_user(user, "Gender set to Unset\n"); - break; - } - check_autopromote(user, 1); - return; - } - write_user(user, "Usage: set gender m|f|n\n"); - return; - case SETAGE: - if (word_count < 3) { - write_user(user, "Usage: set age \n"); - return; - } - tmp = atoi(word[2]); - if (tmp < 0 || tmp > 200) { - write_user(user, - "You can only set your age range between 0 (unset) and 200.\n"); - return; - } - user->age = tmp; - vwrite_user(user, "Age now set to: %d\n", user->age); - return; - case SETWRAP: - switch (user->wrap) { - case 0: - user->wrap = 1; - write_user(user, "Word wrap now ON\n"); - break; - case 1: - user->wrap = 0; - write_user(user, "Word wrap now OFF\n"); - break; - } - return; - case SETEMAIL: - strcpy(word[2], colour_com_strip(word[2])); - if (strlen(word[2]) > 80) { - write_user(user, - "The maximum email length you can have is 80 characters.\n"); - return; - } - if (!validate_email(word[2])) { - write_user(user, - "That email address format is incorrect. Correct format: user@network.net\n"); - return; - } - strcpy(user->email, word[2]); - if (!*user->email) { - write_user(user, "Email set to : ~FRunset\n"); - } else { - vwrite_user(user, "Email set to : ~FC%s\n", user->email); - } - set_forward_email(user); - return; - case SETHOMEP: - strcpy(word[2], colour_com_strip(word[2])); - if (strlen(word[2]) > 80) { - write_user(user, - "The maximum homepage length you can have is 80 characters.\n"); - return; - } - strcpy(user->homepage, word[2]); - if (!*user->homepage) { - write_user(user, "Homepage set to : ~FRunset\n"); - } else { - vwrite_user(user, "Homepage set to : ~FC%s\n", user->homepage); - } - return; - case SETHIDEEMAIL: - switch (user->hideemail) { - case 0: - user->hideemail = 1; - write_user(user, "Email now showing to only the admins.\n"); - break; - case 1: - user->hideemail = 0; - write_user(user, "Email now showing to everyone.\n"); - break; - } - return; - case SETCOLOUR: - switch (user->colour) { - case 0: - user->colour = 1; - write_user(user, "~FCColour now on\n"); - break; - case 1: - user->colour = 0; - write_user(user, "Colour now off\n"); - break; - } - return; - case SETPAGER: - if (word_count < 3) { - write_user(user, "Usage: set pager \n"); - return; - } - user->pager = atoi(word[2]); - if (user->pager < MAX_LINES || user->pager > 99) { - vwrite_user(user, - "Pager can only be set between %d and 99 - setting to default\n", - MAX_LINES); - user->pager = 23; - } - vwrite_user(user, "Pager length now set to: %d\n", user->pager); - return; - case SETROOM: - switch (user->lroom) { - case 0: - user->lroom = 1; - write_user(user, "You will log on into the room you left from.\n"); - break; - case 1: - user->lroom = 0; - write_user(user, "You will log on into the main room.\n"); - break; - } - return; - case SETFWD: - if (!*user->email) { - write_user(user, - "You have not yet set your email address - autofwd cannot be used until you do.\n"); - return; - } - if (!user->mail_verified) { - write_user(user, - "You have not yet verified your email - autofwd cannot be used until you do.\n"); - return; - } - switch (user->autofwd) { - case 0: - user->autofwd = 1; - write_user(user, "You will also receive smails via email.\n"); - break; - case 1: - user->autofwd = 0; - write_user(user, "You will no longer receive smails via email.\n"); - break; - } - return; - case SETPASSWD: - switch (user->show_pass) { - case 0: - user->show_pass = 1; - write_user(user, - "You will now see your password when entering it at login.\n"); - break; - case 1: - user->show_pass = 0; - write_user(user, - "You will no longer see your password when entering it at login.\n"); - break; - } - return; - case SETRDESC: - switch (user->show_rdesc) { - case 0: - user->show_rdesc = 1; - write_user(user, "You will now see the room descriptions.\n"); - break; - case 1: - user->show_rdesc = 0; - write_user(user, "You will no longer see the room descriptions.\n"); - break; - } - return; - case SETCOMMAND: - switch (user->cmd_type) { - case 0: - user->cmd_type = 1; - write_user(user, - "You will now see commands listed by functionality.\n"); - break; - case 1: - user->cmd_type = 0; - write_user(user, "You will now see commands listed by level.\n"); - break; - } - return; - case SETRECAP: - if (!amsys->allow_recaps) { - write_user(user, - "Sorry, names cannot be recapped at this present time.\n"); - return; - } - if (word_count < 3) { - write_user(user, "Usage: set recap \n"); - return; - } - if (strlen(word[2]) > RECAP_NAME_LEN - 3) { - write_user(user, - "The recapped name length is too long - try using fewer colour codes.\n"); - return; - } - recname = colour_com_strip(word[2]); - if (strlen(recname) > USER_NAME_LEN) { - write_user(user, - "The recapped name still has to match your proper name.\n"); - return; - } - strcpy(name, recname); - strtolower(name); - *name = toupper(*name); - if (strcmp(user->name, name)) { - write_user(user, - "The recapped name still has to match your proper name.\n"); - return; - } - strcpy(user->recap, word[2]); - strcat(user->recap, "~RS"); /* user->recap is allways escaped with a reset to its colours... */ - strcpy(user->bw_recap, recname); - vwrite_user(user, - "Your name will now appear as \"%s~RS\" on the \"who\", \"examine\", tells, etc.\n", - user->recap); - return; - case SETICQ: - strcpy(word[2], colour_com_strip(word[2])); - if (strlen(word[2]) > ICQ_LEN) { - vwrite_user(user, - "The maximum ICQ UIN length you can have is %d characters.\n", - ICQ_LEN); - return; - } - strcpy(user->icq, word[2]); - if (!*user->icq) { - write_user(user, "ICQ number set to : ~FRunset\n"); - } else { - vwrite_user(user, "ICQ number set to : ~FC%s\n", user->icq); - } - return; - case SETALERT: - switch (user->alert) { - case 0: - user->alert = 1; - write_user(user, - "You will now be alerted if anyone on your friends list logs on.\n"); - break; - case 1: - user->alert = 0; - write_user(user, - "You will no longer be alerted if anyone on your friends list logs on.\n"); - break; - } - return; - case SETREVBUF: - switch (user->reverse_buffer) { - case 0: - user->reverse_buffer = 1; - write_user(user, "~FCBuffers are now reversed\n"); - break; - case 1: - user->reverse_buffer = 0; - write_user(user, "Buffers now not reversed\n"); - break; - } - return; - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set the user attributes + */ +void +set_attributes(UR_OBJECT user) +{ + char name[USER_NAME_LEN + 1], *recname; + int i, tmp; + + if (word_count < 2) { + i = -1; + } else { + /* FIXME: Add abbreviated matching like help() does */ + for (i = 0; setstr[i].type; ++i) { + if (!strcasecmp(setstr[i].type, word[1])) { + break; + } + } + if (!setstr[i].type) { + i = -1; + } + } + if (i == -1) { + write_user(user, "Attributes you can set are:\n\n"); + for (i = 0; setstr[i].type; ++i) { + vwrite_user(user, "~FC%s~RS : %s\n", setstr[i].type, setstr[i].desc); + } + write_user(user, "\n"); + return; + } + write_user(user, "\n"); + switch (i) { + case SETSHOW: + show_attributes(user); + return; + case SETGEND: + *word[2] = tolower(*word[2]); + if (*word[2] == 'm' || *word[2] == 'f' || *word[2] == 'n') { + switch (*word[2]) { + case 'm': + user->gender = MALE; + write_user(user, "Gender set to Male\n"); + break; + case 'f': + user->gender = FEMALE; + write_user(user, "Gender set to Female\n"); + break; + case 'n': + user->gender = NEUTER; + write_user(user, "Gender set to Unset\n"); + break; + } + check_autopromote(user, 1); + return; + } + write_user(user, "Usage: set gender m|f|n\n"); + return; + case SETAGE: + if (word_count < 3) { + write_user(user, "Usage: set age \n"); + return; + } + tmp = atoi(word[2]); + if (tmp < 0 || tmp > 200) { + write_user(user, + "You can only set your age range between 0 (unset) and 200.\n"); + return; + } + user->age = tmp; + vwrite_user(user, "Age now set to: %d\n", user->age); + return; + case SETWRAP: + switch (user->wrap) { + case 0: + user->wrap = 1; + write_user(user, "Word wrap now ON\n"); + break; + case 1: + user->wrap = 0; + write_user(user, "Word wrap now OFF\n"); + break; + } + return; + case SETEMAIL: + strcpy(word[2], colour_com_strip(word[2])); + if (strlen(word[2]) > 80) { + write_user(user, + "The maximum email length you can have is 80 characters.\n"); + return; + } + if (!validate_email(word[2])) { + write_user(user, + "That email address format is incorrect. Correct format: user@network.net\n"); + return; + } + strcpy(user->email, word[2]); + if (!*user->email) { + write_user(user, "Email set to : ~FRunset\n"); + } else { + vwrite_user(user, "Email set to : ~FC%s\n", user->email); + } + set_forward_email(user); + return; + case SETHOMEP: + strcpy(word[2], colour_com_strip(word[2])); + if (strlen(word[2]) > 80) { + write_user(user, + "The maximum homepage length you can have is 80 characters.\n"); + return; + } + strcpy(user->homepage, word[2]); + if (!*user->homepage) { + write_user(user, "Homepage set to : ~FRunset\n"); + } else { + vwrite_user(user, "Homepage set to : ~FC%s\n", user->homepage); + } + return; + case SETHIDEEMAIL: + switch (user->hideemail) { + case 0: + user->hideemail = 1; + write_user(user, "Email now showing to only the admins.\n"); + break; + case 1: + user->hideemail = 0; + write_user(user, "Email now showing to everyone.\n"); + break; + } + return; + case SETCOLOUR: + switch (user->colour) { + case 0: + user->colour = 1; + write_user(user, "~FCColour now on\n"); + break; + case 1: + user->colour = 0; + write_user(user, "Colour now off\n"); + break; + } + return; + case SETPAGER: + if (word_count < 3) { + write_user(user, "Usage: set pager \n"); + return; + } + user->pager = atoi(word[2]); + if (user->pager < MAX_LINES || user->pager > 99) { + vwrite_user(user, + "Pager can only be set between %d and 99 - setting to default\n", + MAX_LINES); + user->pager = 23; + } + vwrite_user(user, "Pager length now set to: %d\n", user->pager); + return; + case SETROOM: + switch (user->lroom) { + case 0: + user->lroom = 1; + write_user(user, "You will log on into the room you left from.\n"); + break; + case 1: + user->lroom = 0; + write_user(user, "You will log on into the main room.\n"); + break; + } + return; + case SETFWD: + if (!*user->email) { + write_user(user, + "You have not yet set your email address - autofwd cannot be used until you do.\n"); + return; + } + if (!user->mail_verified) { + write_user(user, + "You have not yet verified your email - autofwd cannot be used until you do.\n"); + return; + } + switch (user->autofwd) { + case 0: + user->autofwd = 1; + write_user(user, "You will also receive smails via email.\n"); + break; + case 1: + user->autofwd = 0; + write_user(user, "You will no longer receive smails via email.\n"); + break; + } + return; + case SETPASSWD: + switch (user->show_pass) { + case 0: + user->show_pass = 1; + write_user(user, + "You will now see your password when entering it at login.\n"); + break; + case 1: + user->show_pass = 0; + write_user(user, + "You will no longer see your password when entering it at login.\n"); + break; + } + return; + case SETRDESC: + switch (user->show_rdesc) { + case 0: + user->show_rdesc = 1; + write_user(user, "You will now see the room descriptions.\n"); + break; + case 1: + user->show_rdesc = 0; + write_user(user, "You will no longer see the room descriptions.\n"); + break; + } + return; + case SETCOMMAND: + switch (user->cmd_type) { + case 0: + user->cmd_type = 1; + write_user(user, + "You will now see commands listed by functionality.\n"); + break; + case 1: + user->cmd_type = 0; + write_user(user, "You will now see commands listed by level.\n"); + break; + } + return; + case SETRECAP: + if (!amsys->allow_recaps) { + write_user(user, + "Sorry, names cannot be recapped at this present time.\n"); + return; + } + if (word_count < 3) { + write_user(user, "Usage: set recap \n"); + return; + } + if (strlen(word[2]) > RECAP_NAME_LEN - 3) { + write_user(user, + "The recapped name length is too long - try using fewer colour codes.\n"); + return; + } + recname = colour_com_strip(word[2]); + if (strlen(recname) > USER_NAME_LEN) { + write_user(user, + "The recapped name still has to match your proper name.\n"); + return; + } + strcpy(name, recname); + strtolower(name); + *name = toupper(*name); + if (strcmp(user->name, name)) { + write_user(user, + "The recapped name still has to match your proper name.\n"); + return; + } + strcpy(user->recap, word[2]); + strcat(user->recap, "~RS"); /* user->recap is always escaped with a reset to its colours... */ + strcpy(user->bw_recap, recname); + vwrite_user(user, + "Your name will now appear as \"%s~RS\" on the \"who\", \"examine\", tells, etc.\n", + user->recap); + return; + case SETICQ: + strcpy(word[2], colour_com_strip(word[2])); + if (strlen(word[2]) > ICQ_LEN) { + vwrite_user(user, + "The maximum ICQ UIN length you can have is %d characters.\n", + ICQ_LEN); + return; + } + strcpy(user->icq, word[2]); + if (!*user->icq) { + write_user(user, "ICQ number set to : ~FRunset\n"); + } else { + vwrite_user(user, "ICQ number set to : ~FC%s\n", user->icq); + } + return; + case SETALERT: + switch (user->alert) { + case 0: + user->alert = 1; + write_user(user, + "You will now be alerted if anyone on your friends list logs on.\n"); + break; + case 1: + user->alert = 0; + write_user(user, + "You will no longer be alerted if anyone on your friends list logs on.\n"); + break; + } + return; + case SETREVBUF: + switch (user->reverse_buffer) { + case 0: + user->reverse_buffer = 1; + write_user(user, "~FCBuffers are now reversed\n"); + break; + case 1: + user->reverse_buffer = 0; + write_user(user, "Buffers now not reversed\n"); + break; + } + return; + } +} diff --git a/src/commands/set_desc.c b/src/commands/set_desc.c index 1f67905..e354585 100644 --- a/src/commands/set_desc.c +++ b/src/commands/set_desc.c @@ -1,29 +1,29 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set user description - */ -void -set_desc(UR_OBJECT user, char *inpstr) -{ - if (word_count < 2) { - vwrite_user(user, "Your current description is: %s\n", user->desc); - return; - } - if (strstr(colour_com_strip(inpstr), "(CLONE)")) { - write_user(user, "You cannot have that description.\n"); - return; - } - if (strlen(inpstr) > USER_DESC_LEN) { - write_user(user, "Description too long.\n"); - return; - } - strcpy(user->desc, inpstr); - write_user(user, "Description set.\n"); - /* check to see if user should be promoted */ - check_autopromote(user, 2); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set user description + */ +void +set_desc(UR_OBJECT user, char *inpstr) +{ + if (word_count < 2) { + vwrite_user(user, "Your current description is: %s\n", user->desc); + return; + } + if (strstr(colour_com_strip(inpstr), "(CLONE)")) { + write_user(user, "You cannot have that description.\n"); + return; + } + if (strlen(inpstr) > USER_DESC_LEN) { + write_user(user, "Description too long.\n"); + return; + } + strcpy(user->desc, inpstr); + write_user(user, "Description set.\n"); + /* check to see if user should be promoted */ + check_autopromote(user, 2); +} diff --git a/src/commands/set_ignore.c b/src/commands/set_ignore.c index 5b2c6c3..b4d9d9b 100644 --- a/src/commands/set_ignore.c +++ b/src/commands/set_ignore.c @@ -1,102 +1,102 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * sets up a channel for the user to ignore - */ -void -set_ignore(UR_OBJECT user) -{ - switch (com_num) { - case IGNTELLS: - switch (user->igntells) { - case 0: - user->igntells = 1; - write_user(user, "You will now ignore tells.\n"); - break; - case 1: - user->igntells = 0; - write_user(user, "You will now hear tells.\n"); - break; - } - break; - case IGNSHOUTS: - switch (user->ignshouts) { - case 0: - user->ignshouts = 1; - write_user(user, "You will now ignore shouts.\n"); - break; - case 1: - user->ignshouts = 0; - write_user(user, "You will now hear shouts.\n"); - break; - } - break; - case IGNPICS: - switch (user->ignpics) { - case 0: - user->ignpics = 1; - write_user(user, "You will now ignore pictures.\n"); - break; - case 1: - user->ignpics = 0; - write_user(user, "You will now see pictures.\n"); - break; - } - break; - case IGNWIZ: - switch (user->ignwiz) { - case 0: - user->ignwiz = 1; - write_user(user, "You will now ignore all wiztells and wizemotes.\n"); - break; - case 1: - user->ignwiz = 0; - write_user(user, - "You will now listen to all wiztells and wizemotes.\n"); - break; - } - break; - case IGNLOGONS: - switch (user->ignlogons) { - case 0: - user->ignlogons = 1; - write_user(user, "You will now ignore all logons and logoffs.\n"); - break; - case 1: - user->ignlogons = 0; - write_user(user, "You will now see all logons and logoffs.\n"); - break; - } - break; - case IGNGREETS: - switch (user->igngreets) { - case 0: - user->igngreets = 1; - write_user(user, "You will now ignore all greets.\n"); - break; - case 1: - user->igngreets = 0; - write_user(user, "You will now see all greets.\n"); - break; - } - break; - case IGNBEEPS: - switch (user->ignbeeps) { - case 0: - user->ignbeeps = 1; - write_user(user, "You will now ignore all beeps from users.\n"); - break; - case 1: - user->ignbeeps = 0; - write_user(user, "You will now hear all beeps from users.\n"); - break; - } - break; - default: - break; - } + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * sets up a channel for the user to ignore + */ +void +set_ignore(UR_OBJECT user) +{ + switch (com_num) { + case IGNTELLS: + switch (user->igntells) { + case 0: + user->igntells = 1; + write_user(user, "You will now ignore tells.\n"); + break; + case 1: + user->igntells = 0; + write_user(user, "You will now hear tells.\n"); + break; + } + break; + case IGNSHOUTS: + switch (user->ignshouts) { + case 0: + user->ignshouts = 1; + write_user(user, "You will now ignore shouts.\n"); + break; + case 1: + user->ignshouts = 0; + write_user(user, "You will now hear shouts.\n"); + break; + } + break; + case IGNPICS: + switch (user->ignpics) { + case 0: + user->ignpics = 1; + write_user(user, "You will now ignore pictures.\n"); + break; + case 1: + user->ignpics = 0; + write_user(user, "You will now see pictures.\n"); + break; + } + break; + case IGNWIZ: + switch (user->ignwiz) { + case 0: + user->ignwiz = 1; + write_user(user, "You will now ignore all wiztells and wizemotes.\n"); + break; + case 1: + user->ignwiz = 0; + write_user(user, + "You will now listen to all wiztells and wizemotes.\n"); + break; + } + break; + case IGNLOGONS: + switch (user->ignlogons) { + case 0: + user->ignlogons = 1; + write_user(user, "You will now ignore all logons and logoffs.\n"); + break; + case 1: + user->ignlogons = 0; + write_user(user, "You will now see all logons and logoffs.\n"); + break; + } + break; + case IGNGREETS: + switch (user->igngreets) { + case 0: + user->igngreets = 1; + write_user(user, "You will now ignore all greets.\n"); + break; + case 1: + user->igngreets = 0; + write_user(user, "You will now see all greets.\n"); + break; + } + break; + case IGNBEEPS: + switch (user->ignbeeps) { + case 0: + user->ignbeeps = 1; + write_user(user, "You will now ignore all beeps from users.\n"); + break; + case 1: + user->ignbeeps = 0; + write_user(user, "You will now hear all beeps from users.\n"); + break; + } + break; + default: + break; + } } \ No newline at end of file diff --git a/src/commands/set_iophrase.c b/src/commands/set_iophrase.c index 49a47ad..6da2f98 100644 --- a/src/commands/set_iophrase.c +++ b/src/commands/set_iophrase.c @@ -1,32 +1,32 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set in and out phrases - */ -void -set_iophrase(UR_OBJECT user, char *inpstr) -{ - if (strlen(inpstr) > PHRASE_LEN) { - write_user(user, "Phrase too long.\n"); - return; - } - if (com_num == INPHRASE) { - if (word_count < 2) { - vwrite_user(user, "Your current in phrase is: %s\n", user->in_phrase); - return; - } - strcpy(user->in_phrase, inpstr); - write_user(user, "In phrase set.\n"); - return; - } - if (word_count < 2) { - vwrite_user(user, "Your current out phrase is: %s\n", user->out_phrase); - return; - } - strcpy(user->out_phrase, inpstr); - write_user(user, "Out phrase set.\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set in and out phrases + */ +void +set_iophrase(UR_OBJECT user, char *inpstr) +{ + if (strlen(inpstr) > PHRASE_LEN) { + write_user(user, "Phrase too long.\n"); + return; + } + if (com_num == INPHRASE) { + if (word_count < 2) { + vwrite_user(user, "Your current in phrase is: %s\n", user->in_phrase); + return; + } + strcpy(user->in_phrase, inpstr); + write_user(user, "In phrase set.\n"); + return; + } + if (word_count < 2) { + vwrite_user(user, "Your current out phrase is: %s\n", user->out_phrase); + return; + } + strcpy(user->out_phrase, inpstr); + write_user(user, "Out phrase set.\n"); +} diff --git a/src/commands/set_room_access.c b/src/commands/set_room_access.c index 6da446b..f46c1be 100644 --- a/src/commands/set_room_access.c +++ b/src/commands/set_room_access.c @@ -1,91 +1,91 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set rooms to public or private - */ -void -set_room_access(UR_OBJECT user, int priv) -{ - UR_OBJECT u; - RM_OBJECT rm; - const char *name; - - if (word_count < 2) { - rm = user->room; - } else { - if (user->level < amsys->gatecrash_level) { - write_user(user, - "You are not a high enough level to use the room option.\n"); - return; - } - rm = get_room(word[1]); - if (!rm) { - write_user(user, nosuchroom); - return; - } - } - if (is_personal_room(rm)) { - if (rm == user->room) { - write_user(user, "This room's access is personal.\n"); - } else { - write_user(user, "That room's access is personal.\n"); - } - return; - } - if (is_fixed_room(rm)) { - if (rm == user->room) { - write_user(user, "This room's access is fixed.\n"); - } else { - write_user(user, "That room's access is fixed.\n"); - } - return; - } - if (priv) { - if (is_private_room(rm)) { - if (rm == user->room) { - write_user(user, "This room is already private.\n"); - } else { - write_user(user, "That room is already private.\n"); - } - return; - } - if (room_visitor_count(rm) < amsys->min_private_users - && user->level < amsys->ignore_mp_level) { - vwrite_user(user, - "You need at least %d users/clones in a room before it can be made private.\n", - amsys->min_private_users); - return; - } - } else { - if (!is_private_room(rm)) { - if (rm == user->room) { - write_user(user, "This room is already public.\n"); - } else { - write_user(user, "That room is already public.\n"); - } - return; - } - /* Reset any invites into the room & clear review buffer */ - for (u = user_first; u; u = u->next) { - if (u->invite_room == rm) { - u->invite_room = NULL; - } - } - clear_revbuff(rm); - } - rm->access ^= PRIVATE; - name = user->vis ? user->recap : invisname; - if (rm == user->room) { - vwrite_room_except(rm, user, "%s~RS has set the room to %s~RS.\n", name, - is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); - } else { - vwrite_room(rm, "This room has been set to %s~RS.\n", - is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); - } - vwrite_user(user, "Room set to %s~RS.\n", - is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set rooms to public or private + */ +void +set_room_access(UR_OBJECT user, int priv) +{ + UR_OBJECT u; + RM_OBJECT rm; + const char *name; + + if (word_count < 2) { + rm = user->room; + } else { + if (user->level < amsys->gatecrash_level) { + write_user(user, + "You are not a high enough level to use the room option.\n"); + return; + } + rm = get_room(word[1]); + if (!rm) { + write_user(user, nosuchroom); + return; + } + } + if (is_personal_room(rm)) { + if (rm == user->room) { + write_user(user, "This room's access is personal.\n"); + } else { + write_user(user, "That room's access is personal.\n"); + } + return; + } + if (is_fixed_room(rm)) { + if (rm == user->room) { + write_user(user, "This room's access is fixed.\n"); + } else { + write_user(user, "That room's access is fixed.\n"); + } + return; + } + if (priv) { + if (is_private_room(rm)) { + if (rm == user->room) { + write_user(user, "This room is already private.\n"); + } else { + write_user(user, "That room is already private.\n"); + } + return; + } + if (room_visitor_count(rm) < amsys->min_private_users + && user->level < amsys->ignore_mp_level) { + vwrite_user(user, + "You need at least %d users/clones in a room before it can be made private.\n", + amsys->min_private_users); + return; + } + } else { + if (!is_private_room(rm)) { + if (rm == user->room) { + write_user(user, "This room is already public.\n"); + } else { + write_user(user, "That room is already public.\n"); + } + return; + } + /* Reset any invites into the room & clear review buffer */ + for (u = user_first; u; u = u->next) { + if (u->invite_room == rm) { + u->invite_room = NULL; + } + } + clear_revbuff(rm); + } + rm->access ^= PRIVATE; + name = user->vis ? user->recap : invisname; + if (rm == user->room) { + vwrite_room_except(rm, user, "%s~RS has set the room to %s~RS.\n", name, + is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); + } else { + vwrite_room(rm, "This room has been set to %s~RS.\n", + is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); + } + vwrite_user(user, "Room set to %s~RS.\n", + is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); +} diff --git a/src/commands/set_topic.c b/src/commands/set_topic.c index c816405..9f1e33c 100644 --- a/src/commands/set_topic.c +++ b/src/commands/set_topic.c @@ -1,51 +1,51 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set the room topic - */ -void -set_topic(UR_OBJECT user, char *inpstr) -{ - RM_OBJECT rm; - const char *name; - - rm = user->room; - if (word_count < 2) { - if (!*rm->topic) { - write_user(user, "No topic has been set yet.\n"); - return; - } - vwrite_user(user, "The current topic is: %s\n", rm->topic); - return; - } - if (strlen(inpstr) > TOPIC_LEN) { - write_user(user, "Topic too long.\n"); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_personal_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - vwrite_user(user, "Topic set to: %s\n", inpstr); - name = user->vis ? user->recap : invisname; - vwrite_room_except(rm, user, "%s~RS has set the topic to: %s\n", name, - inpstr); - strcpy(rm->topic, inpstr); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set the room topic + */ +void +set_topic(UR_OBJECT user, char *inpstr) +{ + RM_OBJECT rm; + const char *name; + + rm = user->room; + if (word_count < 2) { + if (!*rm->topic) { + write_user(user, "No topic has been set yet.\n"); + return; + } + vwrite_user(user, "The current topic is: %s\n", rm->topic); + return; + } + if (strlen(inpstr) > TOPIC_LEN) { + write_user(user, "Topic too long.\n"); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_personal_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + vwrite_user(user, "Topic set to: %s\n", inpstr); + name = user->vis ? user->recap : invisname; + vwrite_room_except(rm, user, "%s~RS has set the topic to: %s\n", name, + inpstr); + strcpy(rm->topic, inpstr); +} diff --git a/src/commands/setcmdlev.c b/src/commands/setcmdlev.c index 0b1342c..edf8934 100644 --- a/src/commands/setcmdlev.c +++ b/src/commands/setcmdlev.c @@ -1,74 +1,74 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Allows a user to alter the minimum level which can use the command given - */ -void -set_command_level(UR_OBJECT user) -{ - CMD_OBJECT cmd; - size_t len; - enum lvl_value lvl; - - if (word_count < 3) { - write_user(user, "Usage: setcmdlev |norm\n"); - return; - } - /* FIXME: command search order is different than command_table/exec_com() - * because it uses the alpha sorted command list instead! */ - len = strlen(word[1]); - for (cmd = first_command; cmd; cmd = cmd->next) { - if (!strncmp(word[1], cmd->name, len)) { - break; - } - } - if (!cmd) { - vwrite_user(user, "The command \"~OL%s~RS\" could not be found.\n", - word[1]); - return; - } - /* levels and "norm" are checked in upper case */ - strtoupper(word[2]); - if (!strcmp(word[2], "NORM")) { - /* FIXME: Permissions are weak setting level via "norm" */ - if (cmd->level == (enum lvl_value) command_table[cmd->id].level) { - write_user(user, "That command is already at its normal level.\n"); - return; - } - cmd->level = (enum lvl_value) command_table[cmd->id].level; - write_syslog(SYSLOG, 1, - "%s has returned level to normal for cmd \"%s\"\n", - user->name, cmd->name); - write_monitor(user, NULL, 0); - vwrite_room(NULL, - "~OL~FR--==<~RS The level for command ~OL%s~RS has been returned to %s ~OL~FR>==--\n", - cmd->name, user_level[cmd->level].name); - return; - } - lvl = get_level(word[2]); - if (lvl == NUM_LEVELS) { - write_user(user, "Usage: setcmdlev |norm\n"); - return; - } - if (lvl > user->level) { - write_user(user, - "You cannot set a command level to one greater than your own.\n"); - return; - } - if (user->level < (enum lvl_value) command_table[cmd->id].level) { - write_user(user, - "You are not a high enough level to alter that command level.\n"); - return; - } - cmd->level = lvl; - write_syslog(SYSLOG, 1, "%s has set the level for cmd \"%s\" to %d (%s)\n", - user->name, cmd->name, cmd->level, - user_level[cmd->level].name); - write_monitor(user, NULL, 0); - vwrite_room(NULL, - "~OL~FR--==<~RS The level for command ~OL%s~RS has been set to %s ~OL~FR>==--\n", - cmd->name, user_level[cmd->level].name); +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Allows a user to alter the minimum level which can use the command given + */ +void +set_command_level(UR_OBJECT user) +{ + CMD_OBJECT cmd; + size_t len; + enum lvl_value lvl; + + if (word_count < 3) { + write_user(user, "Usage: setcmdlev |norm\n"); + return; + } + /* FIXME: command search order is different than command_table/exec_com() + * because it uses the alpha sorted command list instead! */ + len = strlen(word[1]); + for (cmd = first_command; cmd; cmd = cmd->next) { + if (!strncmp(word[1], cmd->name, len)) { + break; + } + } + if (!cmd) { + vwrite_user(user, "The command \"~OL%s~RS\" could not be found.\n", + word[1]); + return; + } + /* levels and "norm" are checked in upper case */ + strtoupper(word[2]); + if (!strcmp(word[2], "NORM")) { + /* FIXME: Permissions are weak setting level via "norm" */ + if (cmd->level == (enum lvl_value) command_table[cmd->id].level) { + write_user(user, "That command is already at its normal level.\n"); + return; + } + cmd->level = (enum lvl_value) command_table[cmd->id].level; + write_syslog(SYSLOG, 1, + "%s has returned level to normal for cmd \"%s\"\n", + user->name, cmd->name); + write_monitor(user, NULL, 0); + vwrite_room(NULL, + "~OL~FR--==<~RS The level for command ~OL%s~RS has been returned to %s ~OL~FR>==--\n", + cmd->name, user_level[cmd->level].name); + return; + } + lvl = get_level(word[2]); + if (lvl == NUM_LEVELS) { + write_user(user, "Usage: setcmdlev |norm\n"); + return; + } + if (lvl > user->level) { + write_user(user, + "You cannot set a command level to one greater than your own.\n"); + return; + } + if (user->level < (enum lvl_value) command_table[cmd->id].level) { + write_user(user, + "You are not a high enough level to alter that command level.\n"); + return; + } + cmd->level = lvl; + write_syslog(SYSLOG, 1, "%s has set the level for cmd \"%s\" to %d (%s)\n", + user->name, cmd->name, cmd->level, + user_level[cmd->level].name); + write_monitor(user, NULL, 0); + vwrite_room(NULL, + "~OL~FR--==<~RS The level for command ~OL%s~RS has been set to %s ~OL~FR>==--\n", + cmd->name, user_level[cmd->level].name); } \ No newline at end of file diff --git a/src/commands/sfrom.c b/src/commands/sfrom.c index fba2b93..3e96266 100644 --- a/src/commands/sfrom.c +++ b/src/commands/sfrom.c @@ -1,49 +1,49 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show list of people suggestions are from without seeing the whole lot - */ -void -suggestions_from(UR_OBJECT user) -{ - char id[ARR_SIZE], line[ARR_SIZE], filename[80], *s, *str; - FILE *fp; - int valid; - int cnt; - - if (!amsys->suggestion_count) { - write_user(user, "There are currently no suggestions.\n"); - return; - } - sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); - fp = fopen(filename, "r"); - if (!fp) { - write_user(user, - "There was an error trying to read the suggestion board.\n"); - write_syslog(SYSLOG, 0, - "Unable to open suggestion board in suggestions_from().\n"); - return; - } - vwrite_user(user, "\n~BB*** Suggestions on the %s board from ***\n\n", - SUGBOARD); - valid = 1; - cnt = 0; - for (s = fgets(line, ARR_SIZE - 1, fp); s; - s = fgets(line, ARR_SIZE - 1, fp)) { - if (*s == '\n') { - valid = 1; - } - sscanf(s, "%s", id); - str = colour_com_strip(id); - if (valid && !strcmp(str, "From:")) { - vwrite_user(user, "~FC%2d)~RS %s", ++cnt, remove_first(s)); - valid = 0; - } - } - fclose(fp); - vwrite_user(user, "\nTotal of ~OL%d~RS suggestions.\n\n", - amsys->suggestion_count); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show list of people suggestions are from without seeing the whole lot + */ +void +suggestions_from(UR_OBJECT user) +{ + char id[ARR_SIZE], line[ARR_SIZE], filename[80], *s, *str; + FILE *fp; + int valid; + int cnt; + + if (!amsys->suggestion_count) { + write_user(user, "There are currently no suggestions.\n"); + return; + } + sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); + fp = fopen(filename, "r"); + if (!fp) { + write_user(user, + "There was an error trying to read the suggestion board.\n"); + write_syslog(SYSLOG, 0, + "Unable to open suggestion board in suggestions_from().\n"); + return; + } + vwrite_user(user, "\n~BB*** Suggestions on the %s board from ***\n\n", + SUGBOARD); + valid = 1; + cnt = 0; + for (s = fgets(line, ARR_SIZE - 1, fp); s; + s = fgets(line, ARR_SIZE - 1, fp)) { + if (*s == '\n') { + valid = 1; + } + sscanf(s, "%s", id); + str = colour_com_strip(id); + if (valid && !strcmp(str, "From:")) { + vwrite_user(user, "~FC%2d)~RS %s", ++cnt, remove_first(s)); + valid = 0; + } + } + fclose(fp); + vwrite_user(user, "\nTotal of ~OL%d~RS suggestions.\n\n", + amsys->suggestion_count); +} diff --git a/src/commands/shackle.c b/src/commands/shackle.c index c72c2d7..6d24e0e 100644 --- a/src/commands/shackle.c +++ b/src/commands/shackle.c @@ -1,55 +1,55 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Stop a user from using the go command and leaving the room they are currently in - */ -void -shackle(UR_OBJECT user) -{ - UR_OBJECT u; - - if (word_count < 2) { - write_user(user, "Usage: shackle \n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (user == u) { - write_user(user, "You cannot shackle yourself!\n"); - return; - } -#ifdef NETLINKS - if (!u->room) { - vwrite_user(user, - "%s~RS is currently off site and cannot be shackled there.\n", - u->recap); - return; - } -#endif - if (u->level >= user->level) { - write_user(user, - "You cannot shackle someone of the same or higher level as yourself.\n"); - return; - } - if (u->lroom == 2) { - vwrite_user(user, "%s~RS has already been shackled.\n", u->recap); - return; - } - u->lroom = 2; - vwrite_user(u, "\n~FR~OLYou have been shackled to the %s room.\n", - u->room->name); - vwrite_user(user, "~FR~OLYou shackled~RS %s~RS ~FR~OLto the %s room.\n", - u->recap, u->room->name); - sprintf(text, "~FRShackled~RS to the ~FB%s~RS room by ~FB~OL%s~RS.\n", - u->room->name, user->name); - add_history(u->name, 1, "%s", text); - write_syslog(SYSLOG, 1, "%s SHACKLED %s to the room: %s\n", user->name, - u->name, u->room->name); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Stop a user from using the go command and leaving the room they are currently in + */ +void +shackle(UR_OBJECT user) +{ + UR_OBJECT u; + + if (word_count < 2) { + write_user(user, "Usage: shackle \n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (user == u) { + write_user(user, "You cannot shackle yourself!\n"); + return; + } +#ifdef NETLINKS + if (!u->room) { + vwrite_user(user, + "%s~RS is currently off site and cannot be shackled there.\n", + u->recap); + return; + } +#endif + if (u->level >= user->level) { + write_user(user, + "You cannot shackle someone of the same or higher level as yourself.\n"); + return; + } + if (u->lroom == 2) { + vwrite_user(user, "%s~RS has already been shackled.\n", u->recap); + return; + } + u->lroom = 2; + vwrite_user(u, "\n~FR~OLYou have been shackled to the %s room.\n", + u->room->name); + vwrite_user(user, "~FR~OLYou shackled~RS %s~RS ~FR~OLto the %s room.\n", + u->recap, u->room->name); + sprintf(text, "~FRShackled~RS to the ~FB%s~RS room by ~FB~OL%s~RS.\n", + u->room->name, user->name); + add_history(u->name, 1, "%s", text); + write_syslog(SYSLOG, 1, "%s SHACKLED %s to the room: %s\n", user->name, + u->name, u->room->name); +} diff --git a/src/commands/show.c b/src/commands/show.c index ce29228..5b0ca21 100644 --- a/src/commands/show.c +++ b/src/commands/show.c @@ -1,43 +1,43 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show command, i.e., "Type --> " - */ -void -show(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: show \n"; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are currently muzzled and cannot show.\n"); - return; - } - if (word_count < 2 && strlen(inpstr) < 2) { - write_user(user, usage); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_private_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - write_monitor(user, user->room, 0); - vwrite_room(user->room, "~OL~FCType -->~RS %s\n", inpstr); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show command, i.e., "Type --> " + */ +void +show(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: show \n"; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are currently muzzled and cannot show.\n"); + return; + } + if (word_count < 2 && strlen(inpstr) < 2) { + write_user(user, usage); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_private_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + write_monitor(user, user->room, 0); + vwrite_room(user->room, "~OL~FCType -->~RS %s\n", inpstr); +} diff --git a/src/commands/show_version.c b/src/commands/show_version.c index 350c872..7aa9fe2 100644 --- a/src/commands/show_version.c +++ b/src/commands/show_version.c @@ -1,73 +1,73 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show version number and some small stats of the talker - */ -void -show_version(UR_OBJECT user) -{ - int rms; - RM_OBJECT rm; - - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, align_string(1, 78, 1, "|", "~OL%s~RS", TALKER_NAME)); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, - "| Logons this current boot : ~OL%4d~RS new users, ~OL%4d~RS old users~RS |\n", - amsys->logons_new, amsys->logons_old); - vwrite_user(user, - "| Total number of users : ~OL%-4d~RS Maximum online users : ~OL%-3d~RS |\n", - amsys->user_count, amsys->max_users); - rms = 0; - for (rm = room_first; rm; rm = rm->next) { - ++rms; - } - vwrite_user(user, - "| Total number of rooms : ~OL%-3d~RS Swear ban currently on : ~OL%s~RS |\n", - rms, minmax[amsys->ban_swearing]); - vwrite_user(user, - "| Smail auto-forwarding on : ~OL%-3s~RS Auto purge on : ~OL%-3s~RS |\n", - noyes[amsys->forwarding], noyes[amsys->auto_purge_date != -1]); - vwrite_user(user, - "| Maximum smail copies : ~OL%-3d~RS Names can be recapped : ~OL%-3s~RS |\n", - MAX_COPIES, noyes[amsys->allow_recaps]); - vwrite_user(user, - "| Personal rooms active : ~OL%-3s~RS Maximum user idle time : ~OL%-3d~RS mins~RS |\n", - noyes[amsys->personal_rooms], amsys->user_idle_time / 60); - if (user->level >= WIZ) { -#ifdef NETLINKS - write_user(user, - "| Compiled netlinks : ~OLYES~RS |\n"); -#else - write_user(user, - "| Compiled netlinks : ~OLNO~RS |\n"); -#endif - } - /* YOU MUST *NOT* ALTER THE REMAINING LINES */ - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, - "| ~FC~OLAmnuts version %-21.21s (C) Andrew Collington, September 2001~RS |\n", - AMNUTSVER); - vwrite_user(user, - "| ~FC~OLBuilt %s %s~RS |\n", - __DATE__, __TIME__); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| Running Ardant's Ident Daemon (ArIdent) code, version 2.0.2 |\n"); - write_user(user, - "| Running Ardant's Universal Pager code |\n"); - write_user(user, - "| Running Arny's Seamless reboot code (based on phypor's EWTOO sreboot) |\n"); - write_user(user, - "| Running Silver's spodlist code (converted from PG+ spodlist) |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show version number and some small stats of the talker + */ +void +show_version(UR_OBJECT user) +{ + int rms; + RM_OBJECT rm; + + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, align_string(ALIGN_CENTRE, 78, 1, "|", "~OL%s~RS", TALKER_NAME)); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, + "| Logons this current boot : ~OL%4d~RS new users, ~OL%4d~RS old users~RS |\n", + amsys->logons_new, amsys->logons_old); + vwrite_user(user, + "| Total number of users : ~OL%-4d~RS Maximum online users : ~OL%-3d~RS |\n", + amsys->user_count, amsys->max_users); + rms = 0; + for (rm = room_first; rm; rm = rm->next) { + ++rms; + } + vwrite_user(user, + "| Total number of rooms : ~OL%-3d~RS Swear ban currently on : ~OL%s~RS |\n", + rms, minmax[amsys->ban_swearing]); + vwrite_user(user, + "| Smail auto-forwarding on : ~OL%-3s~RS Auto purge on : ~OL%-3s~RS |\n", + noyes[amsys->forwarding], noyes[amsys->auto_purge_date != -1]); + vwrite_user(user, + "| Maximum smail copies : ~OL%-3d~RS Names can be recapped : ~OL%-3s~RS |\n", + MAX_COPIES, noyes[amsys->allow_recaps]); + vwrite_user(user, + "| Personal rooms active : ~OL%-3s~RS Maximum user idle time : ~OL%-3d~RS mins~RS |\n", + noyes[amsys->personal_rooms], amsys->user_idle_time / 60); + if (user->level >= WIZ) { +#ifdef NETLINKS + write_user(user, + "| Compiled netlinks : ~OLYES~RS |\n"); +#else + write_user(user, + "| Compiled netlinks : ~OLNO~RS |\n"); +#endif + } + /* YOU MUST *NOT* ALTER THE REMAINING LINES */ + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, + "| ~FC~OLAmnuts version %-21.21s (C) Andrew Collington, September 2001~RS |\n", + AMNUTSVER); + vwrite_user(user, + "| ~FC~OLBuilt %s %s~RS |\n", + __DATE__, __TIME__); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| Running Ardant's Ident Daemon (ArIdent) code, version 2.0.2 |\n"); + write_user(user, + "| Running Ardant's Universal Pager code |\n"); + write_user(user, + "| Running Arny's Seamless reboot code (based on phypor's EWTOO sreboot) |\n"); + write_user(user, + "| Running Silver's spodlist code (converted from PG+ spodlist) |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); +} diff --git a/src/commands/shutdown_com.c b/src/commands/shutdown_com.c index 40dbcc7..b7df079 100644 --- a/src/commands/shutdown_com.c +++ b/src/commands/shutdown_com.c @@ -1,60 +1,60 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Shutdown talker interface func. Countdown time is entered in seconds so - * we can specify less than a minute till reboot. - */ -void -shutdown_com(UR_OBJECT user) -{ - if (amsys->rs_which == 1) { - write_user(user, - "The reboot countdown is currently active, you must cancel it first.\n"); - return; - } - if (!strcmp(word[1], "cancel")) { - if (!amsys->rs_countdown || amsys->rs_which) { - write_user(user, "The shutdown countdown is not currently active.\n"); - return; - } - if (amsys->rs_countdown && !amsys->rs_which && !amsys->rs_user) { - write_user(user, - "Someone else is currently setting the shutdown countdown.\n"); - return; - } - write_room(NULL, "~OLSYSTEM:~RS~FG Shutdown cancelled.\n"); - write_syslog(SYSLOG, 1, "%s cancelled the shutdown countdown.\n", - user->name); - amsys->rs_countdown = 0; - amsys->rs_announce = 0; - amsys->rs_which = -1; - amsys->rs_user = NULL; - return; - } - if (word_count > 1 && !is_number(word[1])) { - write_user(user, "Usage: shutdown [|cancel]\n"); - return; - } - if (amsys->rs_countdown && !amsys->rs_which) { - write_user(user, - "The shutdown countdown is currently active, you must cancel it first.\n"); - return; - } - if (word_count < 2) { - amsys->rs_countdown = 0; - amsys->rs_announce = 0; - amsys->rs_which = -1; - amsys->rs_user = NULL; - } else { - amsys->rs_countdown = atoi(word[1]); - amsys->rs_which = 0; - } - write_user(user, - "\n\07~FR~OL~LI*** WARNING - This will shutdown the talker! ***\n\nAre you sure about this (y|n)? "); - user->misc_op = 1; - no_prompt = 1; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Shutdown talker interface func. Countdown time is entered in seconds so + * we can specify less than a minute till reboot. + */ +void +shutdown_com(UR_OBJECT user) +{ + if (amsys->rs_which == 1) { + write_user(user, + "The reboot countdown is currently active, you must cancel it first.\n"); + return; + } + if (!strcmp(word[1], "cancel")) { + if (!amsys->rs_countdown || amsys->rs_which) { + write_user(user, "The shutdown countdown is not currently active.\n"); + return; + } + if (amsys->rs_countdown && !amsys->rs_which && !amsys->rs_user) { + write_user(user, + "Someone else is currently setting the shutdown countdown.\n"); + return; + } + write_room(NULL, "~OLSYSTEM:~RS~FG Shutdown cancelled.\n"); + write_syslog(SYSLOG, 1, "%s cancelled the shutdown countdown.\n", + user->name); + amsys->rs_countdown = 0; + amsys->rs_announce = 0; + amsys->rs_which = -1; + amsys->rs_user = NULL; + return; + } + if (word_count > 1 && !is_number(word[1])) { + write_user(user, "Usage: shutdown [|cancel]\n"); + return; + } + if (amsys->rs_countdown && !amsys->rs_which) { + write_user(user, + "The shutdown countdown is currently active, you must cancel it first.\n"); + return; + } + if (word_count < 2) { + amsys->rs_countdown = 0; + amsys->rs_announce = 0; + amsys->rs_which = -1; + amsys->rs_user = NULL; + } else { + amsys->rs_countdown = atoi(word[1]); + amsys->rs_which = 0; + } + write_user(user, + "\n\07~FR~OL~LI*** WARNING - This will shutdown the talker! ***\n\nAre you sure about this (y|n)? "); + user->misc_op = 1; + no_prompt = 1; +} diff --git a/src/commands/sing_it.c b/src/commands/sing_it.c index 960a070..0c27d38 100644 --- a/src/commands/sing_it.c +++ b/src/commands/sing_it.c @@ -1,51 +1,51 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * put speech in a music notes - */ -void -sing_it(UR_OBJECT user, char *inpstr) -{ -#if !!0 - static const char usage[] = "Usage: sing []\n"; -#endif - const char *name; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot sing.\n"); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_private_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - if (!user->vis) { - write_monitor(user, user->room, 0); - } - name = user->vis ? user->recap : invisname; - if (word_count < 2) { - sprintf(text, "%s~RS sings a tune...BADLY!\n", name); - } else { - sprintf(text, "%s~RS sings o/~ %s~RS o/~\n", name, inpstr); - } - record(user->room, text); - write_room(user->room, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * put speech in a music notes + */ +void +sing_it(UR_OBJECT user, char *inpstr) +{ +#if !!0 + static const char usage[] = "Usage: sing []\n"; +#endif + const char *name; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot sing.\n"); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_private_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + if (!user->vis) { + write_monitor(user, user->room, 0); + } + name = user->vis ? user->recap : invisname; + if (word_count < 2) { + sprintf(text, "%s~RS sings a tune...BADLY!\n", name); + } else { + sprintf(text, "%s~RS sings o/~ %s~RS o/~\n", name, inpstr); + } + record(user->room, text); + write_room(user->room, text); +} diff --git a/src/commands/site.c b/src/commands/site.c index a4b80b9..2e480d4 100644 --- a/src/commands/site.c +++ b/src/commands/site.c @@ -1,40 +1,40 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Site a user - */ -void -site(UR_OBJECT user) -{ - UR_OBJECT u; - - if (word_count < 2) { - write_user(user, "Usage: site \n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } -#ifdef NETLINKS - /* if the user is remotely connected */ - if (u->type == REMOTE_TYPE) { - vwrite_user(user, "%s~RS is remotely connected from %s.\n", u->recap, - u->site); - done_retrieve(u); - return; - } -#endif - if (retrieve_user_type == 1) { - vwrite_user(user, "%s~RS is logged in from ~OL~FC%s~RS (%s:%s).\n", - u->recap, u->site, u->ipsite, u->site_port); - } else { - vwrite_user(user, "%s~RS was last logged in from ~OL~FC%s~RS.\n", - u->recap, u->last_site); - } - done_retrieve(u); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Site a user + */ +void +site(UR_OBJECT user) +{ + UR_OBJECT u; + + if (word_count < 2) { + write_user(user, "Usage: site \n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } +#ifdef NETLINKS + /* if the user is remotely connected */ + if (u->type == REMOTE_TYPE) { + vwrite_user(user, "%s~RS is remotely connected from %s.\n", u->recap, + u->site); + done_retrieve(u); + return; + } +#endif + if (retrieve_user_type == 1) { + vwrite_user(user, "%s~RS is logged in from ~OL~FC%s~RS (%s:%s).\n", + u->recap, u->site, u->ipsite, u->site_port); + } else { + vwrite_user(user, "%s~RS was last logged in from ~OL~FC%s~RS.\n", + u->recap, u->last_site); + } + done_retrieve(u); +} diff --git a/src/commands/smail.c b/src/commands/smail.c index 73a0cfc..082e50c 100644 --- a/src/commands/smail.c +++ b/src/commands/smail.c @@ -1,88 +1,88 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Send mail message - */ -void -smail(UR_OBJECT user, char *inpstr) -{ - if (inpstr) { - static const char usage[] = "Usage: smail [@] []\n"; - char *remote; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot mail anyone.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - *word[1] = toupper(*word[1]); - remote = strchr(word[1], '@'); - /* See if user exists */ - if (!remote) { - UR_OBJECT u = get_user(word[1]); - - /* See if user has local account */ - if (!find_user_listed(word[1])) { - if (!u) { - write_user(user, nosuchuser); - } else { - vwrite_user(user, - "%s is a remote user and does not have a local account.\n", - u->name); - } - return; - } - if (u) { - if (u == user && user->level < ARCH) { - write_user(user, - "Trying to mail yourself is the fifth sign of madness.\n"); - return; - } - /* FIXME: Should check for offline users as well */ - if (check_igusers(u, user) && user->level < GOD) { - vwrite_user(user, "%s~RS is ignoring smails from you.\n", u->recap); - return; - } - strcpy(word[1], u->name); - } - } else if (remote == word[1]) { - write_user(user, "Users name missing before @ sign.\n"); - return; - } - strcpy(user->mail_to, word[1]); - if (word_count < 3) { -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - write_user(user, - "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".smail \" method instead.\n"); - return; - } -#endif - vwrite_user(user, "\n~BB*** Writing mail message to %s ***\n\n", - user->mail_to); - user->misc_op = 4; - editor(user, NULL); - return; - } - /* One line mail */ - strcat(inpstr, "\n"); - inpstr = remove_first(inpstr); - } else { - if (*user->malloc_end-- != '\n') { - *user->malloc_end-- = '\n'; - } - inpstr = user->malloc_start; - } - strtoname(user->mail_to); - send_mail(user, user->mail_to, inpstr, 0); - send_copies(user, inpstr); - *user->mail_to = '\0'; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Send mail message + */ +void +smail(UR_OBJECT user, char *inpstr) +{ + if (inpstr) { + static const char usage[] = "Usage: smail [@] []\n"; + char *remote; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot mail anyone.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + *word[1] = toupper(*word[1]); + remote = strchr(word[1], '@'); + /* See if user exists */ + if (!remote) { + UR_OBJECT u = get_user(word[1]); + + /* See if user has local account */ + if (!find_user_listed(word[1])) { + if (!u) { + write_user(user, nosuchuser); + } else { + vwrite_user(user, + "%s is a remote user and does not have a local account.\n", + u->name); + } + return; + } + if (u) { + if (u == user && user->level < ARCH) { + write_user(user, + "Trying to mail yourself is the fifth sign of madness.\n"); + return; + } + /* FIXME: Should check for offline users as well */ + if (check_igusers(u, user) && user->level < GOD) { + vwrite_user(user, "%s~RS is ignoring smails from you.\n", u->recap); + return; + } + strcpy(word[1], u->name); + } + } else if (remote == word[1]) { + write_user(user, "Users name missing before @ sign.\n"); + return; + } + strcpy(user->mail_to, word[1]); + if (word_count < 3) { +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + write_user(user, + "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".smail \" method instead.\n"); + return; + } +#endif + vwrite_user(user, "\n~BB*** Writing mail message to %s ***\n\n", + user->mail_to); + user->misc_op = 4; + editor(user, NULL); + return; + } + /* One line mail */ + strcat(inpstr, "\n"); + inpstr = remove_first(inpstr); + } else { + if (*user->malloc_end-- != '\n') { + *user->malloc_end-- = '\n'; + } + inpstr = user->malloc_start; + } + strtoname(user->mail_to); + send_mail(user, user->mail_to, inpstr, 0); + send_copies(user, inpstr); + *user->mail_to = '\0'; +} diff --git a/src/commands/sreboot.c b/src/commands/sreboot.c index 5a5a582..c9c1d64 100644 --- a/src/commands/sreboot.c +++ b/src/commands/sreboot.c @@ -1,59 +1,59 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Seamless reboot talker interface func - */ -void -sreboot_com(UR_OBJECT user) -{ - if (!amsys->rs_which) { - write_user(user, - "The shutdown countdown is currently active, you must cancel it first.\n"); - return; - } - if (!strcmp(word[1], "cancel")) { - if (!amsys->rs_countdown) { - write_user(user, - "The seamless reboot countdown is not currently active.\n"); - return; - } - if (amsys->rs_countdown && !amsys->rs_user) { - write_user(user, - "Someone else is currently setting the seamless reboot countdown.\n"); - return; - } - write_room(NULL, "~OLSYSTEM:~RS~FG Seamless reboot cancelled.\n"); - write_syslog(SYSLOG, 1, "%s cancelled the seamless reboot countdown.\n", - user->name); - amsys->rs_countdown = 0; - amsys->rs_announce = 0; - amsys->rs_which = -1; - amsys->rs_user = NULL; - return; - } - if (word_count > 1 && !is_number(word[1])) { - write_user(user, "Usage: sreboot [|cancel]\n"); - return; - } - if (amsys->rs_countdown) { - write_user(user, - "The seamless reboot countdown is currently active, you must cancel it first.\n"); - return; - } - if (word_count < 2) { - amsys->rs_countdown = 0; - amsys->rs_announce = 0; - amsys->rs_which = 2; - amsys->rs_user = NULL; - } else { - amsys->rs_countdown = atoi(word[1]); - amsys->rs_which = 2; - } - write_user(user, - "\n\07~FY~OL~LI*** WARNING - This will seamlessly reboot the talker! ***\n\nAre you sure about this (y|n)? "); - user->misc_op = 7; - no_prompt = 1; +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Seamless reboot talker interface func + */ +void +sreboot_com(UR_OBJECT user) +{ + if (!amsys->rs_which) { + write_user(user, + "The shutdown countdown is currently active, you must cancel it first.\n"); + return; + } + if (!strcmp(word[1], "cancel")) { + if (!amsys->rs_countdown) { + write_user(user, + "The seamless reboot countdown is not currently active.\n"); + return; + } + if (amsys->rs_countdown && !amsys->rs_user) { + write_user(user, + "Someone else is currently setting the seamless reboot countdown.\n"); + return; + } + write_room(NULL, "~OLSYSTEM:~RS~FG Seamless reboot cancelled.\n"); + write_syslog(SYSLOG, 1, "%s cancelled the seamless reboot countdown.\n", + user->name); + amsys->rs_countdown = 0; + amsys->rs_announce = 0; + amsys->rs_which = -1; + amsys->rs_user = NULL; + return; + } + if (word_count > 1 && !is_number(word[1])) { + write_user(user, "Usage: sreboot [|cancel]\n"); + return; + } + if (amsys->rs_countdown) { + write_user(user, + "The seamless reboot countdown is currently active, you must cancel it first.\n"); + return; + } + if (word_count < 2) { + amsys->rs_countdown = 0; + amsys->rs_announce = 0; + amsys->rs_which = 2; + amsys->rs_user = NULL; + } else { + amsys->rs_countdown = atoi(word[1]); + amsys->rs_which = 2; + } + write_user(user, + "\n\07~FY~OL~LI*** WARNING - This will seamlessly reboot the talker! ***\n\nAre you sure about this (y|n)? "); + user->misc_op = 7; + no_prompt = 1; } \ No newline at end of file diff --git a/src/commands/status.c b/src/commands/status.c index 588a0e1..bae4002 100644 --- a/src/commands/status.c +++ b/src/commands/status.c @@ -1,193 +1,193 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show some user stats - */ -void -status(UR_OBJECT user) -{ - char ir[ROOM_NAME_LEN + 1], text2[ARR_SIZE], text3[ARR_SIZE], rm[4], - qcall[USER_NAME_LEN]; - char email[82], nm[5], muzlev[20], arrlev[20]; - UR_OBJECT u; - int days, hours, mins, hs, on, cnt, newmail; - time_t t_expire; - - if (word_count < 2) { - u = user; - on = 1; - } else { - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - } - write_user(user, "\n\n"); - if (!on) { - write_user(user, - "+----- ~FCUser Info~RS -- ~FB(not currently logged on)~RS -------------------------------+\n"); - } else { - write_user(user, - "+----- ~FCUser Info~RS -- ~OL~FY(currently logged on)~RS -----------------------------------+\n"); - } - sprintf(text2, "%s~RS %s", u->recap, u->desc); - cnt = 45 + teslen(text2, 45); - vwrite_user(user, "Name : %-*.*s~RS Level : %s\n", cnt, cnt, text2, - user_level[u->level].name); - mins = (int) (time(0) - u->last_login) / 60; - days = u->total_login / 86400; - hours = (u->total_login % 86400) / 3600; - if (!u->invite_room) { - strcpy(ir, ""); - } else { - strcpy(ir, u->invite_room->name); - } - if (!u->age) { - sprintf(text2, "Unknown"); - } else { - sprintf(text2, "%d", u->age); - } - if (!on || u->login) { - *text3 = '\0'; - } else { - sprintf(text3, " Online for : %d min%s", mins, PLTEXT_S(mins)); - } - vwrite_user(user, "Gender : %-8s Age : %-8s %s\n", sex[u->gender], - text2, text3); - if (!*u->email) { - strcpy(email, "Currently unset"); - } else { - strcpy(email, u->email); - if (u->mail_verified) { - strcat(email, " ~FB~OL(VERIFIED)~RS"); - } - if (u->hideemail) { - if (user->level >= WIZ || u == user) { - strcat(email, " ~FB~OL(HIDDEN)~RS"); - } else { - strcpy(email, "Currently only on view to the Wizzes"); - } - } - } - vwrite_user(user, "Email Address : %s\n", email); - vwrite_user(user, "Homepage URL : %s\n", - !*u->homepage ? "Currently unset" : u->homepage); - vwrite_user(user, "ICQ Number : %s\n", - !*u->icq ? "Currently unset" : u->icq); - mins = (u->total_login % 3600) / 60; - vwrite_user(user, - "Total Logins : %-9d Total login : %d day%s, %d hour%s, %d minute%s\n", - u->logons, days, PLTEXT_S(days), hours, PLTEXT_S(hours), mins, - PLTEXT_S(mins)); - write_user(user, - "+----- ~FCGeneral Info~RS ---------------------------------------------------------+\n"); - vwrite_user(user, "Enter Msg : %s~RS %s\n", u->recap, u->in_phrase); - vwrite_user(user, "Exit Msg : %s~RS %s~RS to the...\n", u->recap, - u->out_phrase); - newmail = mail_sizes(u->name, 1); - if (!newmail) { - sprintf(nm, "NO"); - } else { - sprintf(nm, "%d", newmail); - } - /* FIXME: Use sentinel other JAILED */ - if (!on || u->login) { - vwrite_user(user, "New Mail : %-13.13s Muzzled : %-13.13s\n", nm, - noyes[(u->muzzled != JAILED)]); - } else { - vwrite_user(user, - "Invited to : %-13.13s Muzzled : %-13.13s Ignoring : %-13.13s\n", - ir, noyes[(u->muzzled != JAILED)], noyes[u->ignall]); -#ifdef NETLINKS - if (u->type == REMOTE_TYPE || !u->room) { - hs = 0; - sprintf(ir, ""); - } else { -#endif - hs = 1; - sprintf(ir, "%s", u->room->name); -#ifdef NETLINKS - } -#endif - vwrite_user(user, - "In Area : %-13.13s At home : %-13.13s New Mail : %-13.13s\n", - ir, noyes[hs], nm); - } - vwrite_user(user, - "Killed %d people, and died %d times. Energy : %d, Bullets : %d\n", - u->kills, u->deaths, u->hps, u->bullets); - if (u == user || user->level >= WIZ) { - write_user(user, - "+----- ~FCUser Only Info~RS -------------------------------------------------------+\n"); - vwrite_user(user, - "Char echo : %-13.13s Wrap : %-13.13s Monitor : %-13.13s\n", - noyes[u->charmode_echo], noyes[u->wrap], noyes[u->monitor]); - if (u->lroom == 2) { - strcpy(rm, "YES"); - } else { - strcpy(rm, noyes[u->lroom]); - } - vwrite_user(user, - "Colours : %-13.13s Pager : %-13d Logon rm : %-13.13s\n", - noyes[u->colour], u->pager, rm); - if (!*u->call) { - strcpy(qcall, ""); - } else { - strcpy(qcall, u->call); - } - vwrite_user(user, - "Quick call to : %-13.13s Autofwd : %-13.13s Verified : %-13.13s\n", - qcall, noyes[u->autofwd], noyes[u->mail_verified]); - if (on && !u->login) { - if (u == user && user->level < WIZ) { - vwrite_user(user, "On from site : %s\n", u->site); - } else { - vwrite_user(user, "On from site : %-42.42s Port : %s\n", u->site, - u->site_port); - } - } - } - if (user->level >= WIZ) { - write_user(user, - "+----- ~OL~FCWiz Only Info~RS --------------------------------------------------------+\n"); - /* FIXME: Use sentinel other JAILED */ - if (u->muzzled == JAILED) { - strcpy(muzlev, "Unmuzzled"); - } else { - strcpy(muzlev, user_level[u->muzzled].name); - } - /* FIXME: Use sentinel other JAILED */ - if (u->arrestby == JAILED) { - strcpy(arrlev, "Unarrested"); - } else { - strcpy(arrlev, user_level[u->arrestby].name); - } - vwrite_user(user, - "Unarrest Lev : %-13.13s Arr lev : %-13.13s Muz Lev : %-13.13s\n", - user_level[u->unarrest].name, arrlev, muzlev); - if (u->lroom == 2) { - sprintf(rm, "YES"); - } else { - sprintf(rm, "NO"); - } - vwrite_user(user, "Logon room : %-38.38s Shackled : %s\n", - u->logout_room, rm); - vwrite_user(user, "Last site : %s\n", u->last_site); - t_expire = - u->last_login + 86400 * (u->level == - NEW ? NEWBIE_EXPIRES : USER_EXPIRES); - strftime(text2, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", localtime(&t_expire)); - vwrite_user(user, "User Expires : %-13.13s On date : %s\n", - noyes[u->expire], text2); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - if (u != user) { - done_retrieve(u); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show some user stats + */ +void +status(UR_OBJECT user) +{ + char ir[ROOM_NAME_LEN + 1], text2[ARR_SIZE], text3[ARR_SIZE], rm[4], + qcall[USER_NAME_LEN]; + char email[82], nm[5], muzlev[20], arrlev[20]; + UR_OBJECT u; + int days, hours, mins, hs, on, cnt, newmail; + time_t t_expire; + + if (word_count < 2) { + u = user; + on = 1; + } else { + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + } + write_user(user, "\n\n"); + if (!on) { + write_user(user, + "+----- ~FCUser Info~RS -- ~FB(not currently logged on)~RS -------------------------------+\n"); + } else { + write_user(user, + "+----- ~FCUser Info~RS -- ~OL~FY(currently logged on)~RS -----------------------------------+\n"); + } + sprintf(text2, "%s~RS %s", u->recap, u->desc); + cnt = 45 + teslen(text2, 45); + vwrite_user(user, "Name : %-*.*s~RS Level : %s\n", cnt, cnt, text2, + user_level[u->level].name); + mins = (int) (time(0) - u->last_login) / 60; + days = u->total_login / 86400; + hours = (u->total_login % 86400) / 3600; + if (!u->invite_room) { + strcpy(ir, ""); + } else { + strcpy(ir, u->invite_room->name); + } + if (!u->age) { + sprintf(text2, "Unknown"); + } else { + sprintf(text2, "%d", u->age); + } + if (!on || u->login) { + *text3 = '\0'; + } else { + sprintf(text3, " Online for : %d min%s", mins, PLTEXT_S(mins)); + } + vwrite_user(user, "Gender : %-8s Age : %-8s %s\n", sex[u->gender], + text2, text3); + if (!*u->email) { + strcpy(email, "Currently unset"); + } else { + strcpy(email, u->email); + if (u->mail_verified) { + strcat(email, " ~FB~OL(VERIFIED)~RS"); + } + if (u->hideemail) { + if (user->level >= WIZ || u == user) { + strcat(email, " ~FB~OL(HIDDEN)~RS"); + } else { + strcpy(email, "Currently only on view to the Wizzes"); + } + } + } + vwrite_user(user, "Email Address : %s\n", email); + vwrite_user(user, "Homepage URL : %s\n", + !*u->homepage ? "Currently unset" : u->homepage); + vwrite_user(user, "ICQ Number : %s\n", + !*u->icq ? "Currently unset" : u->icq); + mins = (u->total_login % 3600) / 60; + vwrite_user(user, + "Total Logins : %-9d Total login : %d day%s, %d hour%s, %d minute%s\n", + u->logons, days, PLTEXT_S(days), hours, PLTEXT_S(hours), mins, + PLTEXT_S(mins)); + write_user(user, + "+----- ~FCGeneral Info~RS ---------------------------------------------------------+\n"); + vwrite_user(user, "Enter Msg : %s~RS %s\n", u->recap, u->in_phrase); + vwrite_user(user, "Exit Msg : %s~RS %s~RS to the...\n", u->recap, + u->out_phrase); + newmail = mail_sizes(u->name, 1); + if (!newmail) { + sprintf(nm, "NO"); + } else { + sprintf(nm, "%d", newmail); + } + /* FIXME: Use sentinel other JAILED */ + if (!on || u->login) { + vwrite_user(user, "New Mail : %-13.13s Muzzled : %-13.13s\n", nm, + noyes[(u->muzzled != JAILED)]); + } else { + vwrite_user(user, + "Invited to : %-13.13s Muzzled : %-13.13s Ignoring : %-13.13s\n", + ir, noyes[(u->muzzled != JAILED)], noyes[u->ignall]); +#ifdef NETLINKS + if (u->type == REMOTE_TYPE || !u->room) { + hs = 0; + sprintf(ir, ""); + } else { +#endif + hs = 1; + sprintf(ir, "%s", u->room->name); +#ifdef NETLINKS + } +#endif + vwrite_user(user, + "In Area : %-13.13s At home : %-13.13s New Mail : %-13.13s\n", + ir, noyes[hs], nm); + } + vwrite_user(user, + "Killed %d people, and died %d times. Energy : %d, Bullets : %d\n", + u->kills, u->deaths, u->hps, u->bullets); + if (u == user || user->level >= WIZ) { + write_user(user, + "+----- ~FCUser Only Info~RS -------------------------------------------------------+\n"); + vwrite_user(user, + "Char echo : %-13.13s Wrap : %-13.13s Monitor : %-13.13s\n", + noyes[u->charmode_echo], noyes[u->wrap], noyes[u->monitor]); + if (u->lroom == 2) { + strcpy(rm, "YES"); + } else { + strcpy(rm, noyes[u->lroom]); + } + vwrite_user(user, + "Colours : %-13.13s Pager : %-13d Logon rm : %-13.13s\n", + noyes[u->colour], u->pager, rm); + if (!*u->call) { + strcpy(qcall, ""); + } else { + strcpy(qcall, u->call); + } + vwrite_user(user, + "Quick call to : %-13.13s Autofwd : %-13.13s Verified : %-13.13s\n", + qcall, noyes[u->autofwd], noyes[u->mail_verified]); + if (on && !u->login) { + if (u == user && user->level < WIZ) { + vwrite_user(user, "On from site : %s\n", u->site); + } else { + vwrite_user(user, "On from site : %-42.42s Port : %s\n", u->site, + u->site_port); + } + } + } + if (user->level >= WIZ) { + write_user(user, + "+----- ~OL~FCWiz Only Info~RS --------------------------------------------------------+\n"); + /* FIXME: Use sentinel other JAILED */ + if (u->muzzled == JAILED) { + strcpy(muzlev, "Unmuzzled"); + } else { + strcpy(muzlev, user_level[u->muzzled].name); + } + /* FIXME: Use sentinel other JAILED */ + if (u->arrestby == JAILED) { + strcpy(arrlev, "Unarrested"); + } else { + strcpy(arrlev, user_level[u->arrestby].name); + } + vwrite_user(user, + "Unarrest Lev : %-13.13s Arr lev : %-13.13s Muz Lev : %-13.13s\n", + user_level[u->unarrest].name, arrlev, muzlev); + if (u->lroom == 2) { + sprintf(rm, "YES"); + } else { + sprintf(rm, "NO"); + } + vwrite_user(user, "Logon room : %-38.38s Shackled : %s\n", + u->logout_room, rm); + vwrite_user(user, "Last site : %s\n", u->last_site); + t_expire = + u->last_login + 86400 * (u->level == + NEW ? NEWBIE_EXPIRES : USER_EXPIRES); + strftime(text2, ARR_SIZE, "%a %Y-%m-%d %H:%M:%S", localtime(&t_expire)); + vwrite_user(user, "User Expires : %-13.13s On date : %s\n", + noyes[u->expire], text2); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + if (u != user) { + done_retrieve(u); + } +} diff --git a/src/commands/suggestions.c b/src/commands/suggestions.c index 2106f7e..362a03c 100644 --- a/src/commands/suggestions.c +++ b/src/commands/suggestions.c @@ -1,82 +1,82 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Write a suggestion to the board, or read if if you can - */ -void -suggestions(UR_OBJECT user, char *inpstr) -{ - char filename[30], *c; - FILE *fp; - int cnt; - - if (com_num == RSUG) { - sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); - write_user(user, - "~BB~FG*** The Suggestions board has the following ideas ***\n\n"); - switch (more(user, user->socket, filename)) { - case 0: - write_user(user, "There are no suggestions.\n\n"); - break; - case 1: - user->misc_op = 2; - break; - } - return; - } - if (inpstr) { - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot make suggestions.\n"); - return; - } - if (word_count < 2) { -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - write_user(user, - "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".suggest \" method instead.\n"); - return; - } -#endif - write_user(user, "~BB~FG*** Writing a suggestion ***\n\n"); - user->misc_op = 8; - editor(user, NULL); - return; - } - strcat(inpstr, "\n"); /* XXX: risky but hopefully it will be ok */ - } else { - inpstr = user->malloc_start; - } - sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); - fp = fopen(filename, "a"); - if (!fp) { - vwrite_user(user, "%s: cannot add suggestion.\n", syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Cannot open file %s to write in suggestions().\n", - filename); - return; - } - sprintf(text, "~OLFrom: %s %s\n", user->bw_recap, long_date(0)); - fputs(text, fp); - cnt = 0; - for (c = inpstr; *c; ++c) { - putc(*c, fp); - if (*c == '\n') { - cnt = 0; - } else { - ++cnt; - } - if (cnt == 80) { - putc('\n', fp); - cnt = 0; - } - } - putc('\n', fp); - fclose(fp); - write_user(user, "Suggestion written. Thank you for your contribution.\n"); - ++amsys->suggestion_count; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Write a suggestion to the board, or read if if you can + */ +void +suggestions(UR_OBJECT user, char *inpstr) +{ + char filename[30], *c; + FILE *fp; + int cnt; + + if (com_num == RSUG) { + sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); + write_user(user, + "~BB~FG*** The Suggestions board has the following ideas ***\n\n"); + switch (more(user, user->socket, filename)) { + case 0: + write_user(user, "There are no suggestions.\n\n"); + break; + case 1: + user->misc_op = 2; + break; + } + return; + } + if (inpstr) { + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot make suggestions.\n"); + return; + } + if (word_count < 2) { +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + write_user(user, + "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".suggest \" method instead.\n"); + return; + } +#endif + write_user(user, "~BB~FG*** Writing a suggestion ***\n\n"); + user->misc_op = 8; + editor(user, NULL); + return; + } + strcat(inpstr, "\n"); /* XXX: risky but hopefully it will be ok */ + } else { + inpstr = user->malloc_start; + } + sprintf(filename, "%s/%s", MISCFILES, SUGBOARD); + fp = fopen(filename, "a"); + if (!fp) { + vwrite_user(user, "%s: cannot add suggestion.\n", syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Cannot open file %s to write in suggestions().\n", + filename); + return; + } + sprintf(text, "~OLFrom: %s %s\n", user->bw_recap, long_date(0)); + fputs(text, fp); + cnt = 0; + for (c = inpstr; *c; ++c) { + putc(*c, fp); + if (*c == '\n') { + cnt = 0; + } else { + ++cnt; + } + if (cnt == 80) { + putc('\n', fp); + cnt = 0; + } + } + putc('\n', fp); + fclose(fp); + write_user(user, "Suggestion written. Thank you for your contribution.\n"); + ++amsys->suggestion_count; +} diff --git a/src/commands/suicide.c b/src/commands/suicide.c index 51ce7c1..4ce9222 100644 --- a/src/commands/suicide.c +++ b/src/commands/suicide.c @@ -1,25 +1,25 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Allow a user to delete their own account - */ -void -suicide(UR_OBJECT user) -{ - if (word_count < 2) { - write_user(user, "Usage: suicide \n"); - return; - } - if (strcmp(user->pass, crypt(word[1], user->pass))) { - write_user(user, "Password incorrect.\n"); - return; - } - write_user(user, - "\n\07~FR~OL~LI*** WARNING - This will delete your account! ***\n\nAre you sure about this (y|n)? "); - user->misc_op = 6; - no_prompt = 1; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Allow a user to delete their own account + */ +void +suicide(UR_OBJECT user) +{ + if (word_count < 2) { + write_user(user, "Usage: suicide \n"); + return; + } + if (strcmp(user->pass, crypt(word[1], user->pass))) { + write_user(user, "Password incorrect.\n"); + return; + } + write_user(user, + "\n\07~FR~OL~LI*** WARNING - This will delete your account! ***\n\nAre you sure about this (y|n)? "); + user->misc_op = 6; + no_prompt = 1; +} diff --git a/src/commands/system.c b/src/commands/system.c index 05b838b..9cc4fde 100644 --- a/src/commands/system.c +++ b/src/commands/system.c @@ -1,408 +1,408 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show talker system parameters etc - */ -void -system_details(UR_OBJECT user) -{ - static const char *const ca[] ={"NONE", "SHUTDOWN", "REBOOT", "SEAMLESS"}; - static const char *const rip[] = {"OFF", "AUTO", "MANUAL", "IDENTD"}; - char bstr[32], foo[ARR_SIZE]; - UR_OBJECT u; - UD_OBJECT d; - RM_OBJECT rm; - CMD_OBJECT cmd; - size_t l; - int ucount, dcount, rmcount, cmdcount, lcount; - int tsize; - int uccount, rmpcount; -#ifdef NETLINKS - NL_OBJECT nl; - int nlcount, nlupcount, nlicount, nlocount, rmnlicount; -#endif - enum lvl_value lvl; - int days, hours, mins, secs; - - if (word_count < 2 || !strcasecmp("-a", word[1])) { - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - sprintf(text, "System Details for %s (Amnuts version %s)", TALKER_NAME, - AMNUTSVER); - vwrite_user(user, "| ~OL~FC%-74.74s~RS |\n", text); - write_user(user, - "|----------------------------------------------------------------------------|\n"); - /* Get some values */ - strftime(bstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&amsys->boot_time)); - secs = (int) (time(0) - amsys->boot_time); - days = secs / 86400; - hours = (secs % 86400) / 3600; - mins = (secs % 3600) / 60; - secs = secs % 60; - /* Show header parameters */ -#ifdef NETLINKS -#ifdef IDENTD - if (amsys->ident_state) { -#ifdef WIZPORT - write_user(user, - "| talker pid identd pid main port wiz port netlinks port |\n"); - vwrite_user(user, - "| %-5u %-5u %-5.5s %-5.5s %-5.5s |\n", - getpid(), amsys->ident_pid, amsys->mport_port, - amsys->wport_port, amsys->nlink_port); -#else - write_user(user, - "| talker pid identd pid main port netlinks port |\n"); - vwrite_user(user, - "| %-5u %-5u %-5.5s %-5.5s |\n", - getpid(), amsys->ident_pid, amsys->mport_port, - amsys->nlink_port); -#endif - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } else -#endif - { -#ifdef WIZPORT - write_user(user, - "| talker pid main port wiz port netlinks port |\n"); - vwrite_user(user, - "| %-5u %-5.5s %-5.5s %-5.5s |\n", - getpid(), amsys->mport_port, amsys->wport_port, - amsys->nlink_port); -#else - write_user(user, - "| talker pid main port netlinks port |\n"); - vwrite_user(user, - "| %-5u %-5.5s %-5.5s |\n", - getpid(), amsys->mport_port, amsys->nlink_port); -#endif - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } -#else -#ifdef IDENTD - if (amsys->ident_state) { -#ifdef WIZPORT - write_user(user, - "| talker pid identd pid main port wiz port |\n"); - vwrite_user(user, - "| %-5u %-5u %-5.5s %-5.5s |\n", - getpid(), amsys->ident_pid, amsys->mport_port, - amsys->wport_port); -#else - write_user(user, - "| talker pid identd pid main port |\n"); - vwrite_user(user, - "| %-5u %-5u %-5.5s |\n", - getpid(), amsys->ident_pid, amsys->mport_port); -#endif - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } else -#endif - { -#ifdef WIZPORT - write_user(user, - "| talker pid main port wiz port |\n"); - vwrite_user(user, - "| %-5u %-5.5s %-5.5s |\n", - getpid(), amsys->mport_port, amsys->wport_port); -#else - write_user(user, - "| talker pid main port |\n"); - vwrite_user(user, - "| %-5u %-5.5s |\n", - getpid(), amsys->mport_port); -#endif - write_user(user, - "+----------------------------------------------------------------------------+\n"); - } -#endif - vwrite_user(user, "| %-17.17s : %-54.54s |\n", "talker booted", bstr); - sprintf(text, "%d day%s, %d hour%s, %d minute%s, %d second%s", days, - PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins), - secs, PLTEXT_S(secs)); - vwrite_user(user, "| %-17.17s : %-54.54s |\n", "uptime", text); - vwrite_user(user, - "| %-17.17s : %-6.6s %-17.17s : %-10.10s |\n", - "system logging", offon[(amsys->logging) ? 1 : 0], - "flood protection", offon[amsys->flood_protect]); - vwrite_user(user, - "| %-17.17s : %-6.6s %-17.17s : %-10.10s |\n", - "ignoring sigterms", noyes[amsys->ignore_sigterm], - "crash action", ca[amsys->crash_action]); - sprintf(text, "every %d sec%s", amsys->heartbeat, - PLTEXT_S(amsys->heartbeat)); - vwrite_user(user, - "| %-17.17s : %-20.20s %-17.17s : %-10.10s |\n", - "heartbeat", text, "resolving IP", rip[amsys->resolve_ip]); - vwrite_user(user, "| %-17.17s : %-54.54s |\n", - "swear ban", minmax[amsys->ban_swearing]); - if (word_count < 2) { - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| For other options, see: system -m, -n, -r, -u, -a |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - } - /* user option */ - if (!strcasecmp("-u", word[1]) || !strcasecmp("-a", word[1])) { - uccount = 0; - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE) { - ++uccount; - } - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCSystem Details - Users~RS |\n"); - write_user(user, - "|----------------------------------------------------------------------------|\n"); - for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { - vwrite_user(user, - "| users at level %-8.8s : %-5d |\n", - user_level[lvl].name, amsys->level_count[lvl]); - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, - "| %-24.24s: %-5d %-24.24s: %-5d |\n", - "online now", amsys->num_of_users, "max allowed online", - amsys->max_users); - vwrite_user(user, "| %-24.24s: %-5d %-24.24s: %-5d |\n", - "new this boot", amsys->logons_new, "returning this boot", - amsys->logons_old); - vwrite_user(user, "| %-24.24s: %-5d %-24.24s: %-5d |\n", - "clones now on", uccount, "max allowed clones", - amsys->max_clones); - sprintf(text, "%d sec%s", amsys->login_idle_time, - PLTEXT_S(amsys->login_idle_time)); - sprintf(foo, "%d sec%s", amsys->user_idle_time, - PLTEXT_S(amsys->user_idle_time)); - vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", - "login idle time out", text, "user idle time out", foo); - vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", - "time out maxlevel", - user_level[amsys->time_out_maxlevel].name, "time out afks", - noyes[amsys->time_out_afks]); - vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", - "current minlogin level", - amsys->minlogin_level == - NUM_LEVELS ? "NONE" : user_level[amsys->minlogin_level].name, - "min login disconnect", noyes[amsys->boot_off_min]); - vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", - "newbie prompt default", offon[amsys->prompt_def], - "newbie colour default", offon[amsys->colour_def]); - vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", - "newbie charecho default", offon[amsys->charecho_def], - "echoing password default", offon[amsys->passwordecho_def]); - vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", - "name recaps allowed", noyes[amsys->allow_recaps], - "smail auto-forwarding", offon[amsys->forwarding]); - strftime(text, ARR_SIZE * 2, "%a %Y-%m-%d %H:%M:%S", - localtime(&amsys->auto_purge_date)); - vwrite_user(user, "| %-24.24s: %-4s %-15.15s: %-25s |\n", "autopurge on", - noyes[amsys->auto_purge_date != -1], "next autopurge", text); - sprintf(text, "%d day%s", USER_EXPIRES, PLTEXT_S(USER_EXPIRES)); - sprintf(foo, "%d day%s", NEWBIE_EXPIRES, PLTEXT_S(NEWBIE_EXPIRES)); - vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", - "purge length (newbies)", foo, "purge length (users)", text); -#ifdef WIZPORT - vwrite_user(user, - "| %-24.24s: %-10.10s |\n", - "wizport min login level", - user_level[amsys->wizport_level].name); -#endif - if (!strcasecmp("-u", word[1])) { - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - } - /* Netlinks Option */ - if (!strcasecmp("-n", word[1]) || !strcasecmp("-a", word[1])) { - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCSystem Details - Netlinks~RS |\n"); - write_user(user, - "|----------------------------------------------------------------------------|\n"); -#ifdef NETLINKS - rmnlicount = 0; - for (rm = room_first; rm; rm = rm->next) { - if (rm->inlink) { - ++rmnlicount; - } - } - nlcount = nlupcount = nlicount = nlocount = 0; - for (nl = nl_first; nl; nl = nl->next) { - ++nlcount; - if (nl->type != UNCONNECTED && nl->stage == UP) { - ++nlupcount; - } - if (nl->type == INCOMING) { - ++nlicount; - } - if (nl->type == OUTGOING) { - ++nlocount; - } - } - vwrite_user(user, "| %-21.21s: %5d %45s |\n", - "total netlinks", nlcount, " "); - vwrite_user(user, "| %-21.21s: %5d secs %-21.21s: %5d secs |\n", - "idle time out", amsys->net_idle_time, - "keepalive interval", amsys->keepalive_interval); - vwrite_user(user, "| %-21.21s: %5d %-21.21s: %5d |\n", - "accepting connects", rmnlicount, - "live connects", nlupcount); - vwrite_user(user, "| %-21.21s: %5d %-21.21s: %5d |\n", - "incoming connections", nlicount, - "outgoing connections", nlocount); - vwrite_user(user, "| %-21.21s: %-13.13s %-21.21s: %-13.13s |\n", - "remote user maxlevel", user_level[amsys->rem_user_maxlevel].name, - "remote user deflevel", user_level[amsys->rem_user_deflevel].name); - vwrite_user(user, "| %-21.21s: %5d bytes %-21.21s: %5d bytes |\n", - "netlink structure", (int) (sizeof *nl), - "total memory", nlcount * (int) (sizeof *nl)); -#else - write_user(user, - "| Netlinks are not currently compiled into the talker. |\n"); -#endif - if (!strcasecmp("-n", word[1])) { - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - } - /* Room Option */ - if (!strcasecmp("-r", word[1]) || !strcasecmp("-a", word[1])) { - rmcount = rmpcount = 0; - for (rm = room_first; rm; rm = rm->next) { - ++rmcount; - if (is_personal_room(rm)) { - ++rmpcount; - } - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCSystem Details - Rooms~RS |\n"); - write_user(user, - "|----------------------------------------------------------------------------|\n"); - vwrite_user(user, - "| %-16.16s: %-15.15s %-20.20s: %5d |\n", - "gatecrash level", user_level[amsys->gatecrash_level].name, - "min private count", amsys->min_private_users); - sprintf(text, "%d day%s", amsys->mesg_life, PLTEXT_S(amsys->mesg_life)); - vwrite_user(user, - "| %-16.16s: %-15.15s %-20.20s: %.2d:%.2d |\n", - "message life", text, "message check time", - amsys->mesg_check_hour, amsys->mesg_check_min); - vwrite_user(user, - "| %-16.16s: %5d %-20.20s: %5d |\n", - "personal rooms", rmpcount, "total rooms", rmcount); - vwrite_user(user, "| %-16.16s: %7d bytes %-20.20s: %7d bytes |\n", - "room structure", (int) (sizeof *rm), "total memory", - rmcount * (int) (sizeof *rm)); - if (!strcasecmp("-r", word[1])) { - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - } - /* Memory Option */ - if (!strcasecmp("-m", word[1]) || !strcasecmp("-a", word[1])) { - ucount = 0; - for (u = user_first; u; u = u->next) { - ++ucount; - } - dcount = 0; - for (d = first_user_entry; d; d = d->next) { - ++dcount; - } - rmcount = 0; - for (rm = room_first; rm; rm = rm->next) { - ++rmcount; - } - cmdcount = 0; - for (cmd = first_command; cmd; cmd = cmd->next) { - ++cmdcount; - } - lcount = 0; - for (l = 0; l < LASTLOGON_NUM; ++l) { - ++lcount; - } - tsize = - ucount * (sizeof *u) + dcount * (sizeof *d) + rmcount * (sizeof *rm) + - cmdcount * (sizeof *cmd) + (sizeof *amsys) + - lcount * (sizeof *last_login_info); -#ifdef NETLINKS - nlcount = 0; - for (nl = nl_first; nl; nl = nl->next) { - ++nlcount; - } - tsize += nlcount * (sizeof *nl); -#endif - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCSystem Details - Memory Object Allocation~RS |\n"); - write_user(user, - "|----------------------------------------------------------------------------|\n"); - vwrite_user(user, - "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", - "users", ucount, (int) (sizeof *u), - ucount * (int) (sizeof *u)); - vwrite_user(user, - "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", - "all users", dcount, (int) (sizeof *d), - dcount * (int) (sizeof *d)); - vwrite_user(user, - "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", - "rooms", rmcount, (int) (sizeof *rm), - rmcount * (int) (sizeof *rm)); - vwrite_user(user, - "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", - "commands", cmdcount, (int) (sizeof *cmd), - cmdcount * (int) (sizeof *cmd)); - vwrite_user(user, - "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", - "system", 1, (int) (sizeof *amsys), - 1 * (int) (sizeof *amsys)); - vwrite_user(user, - "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", - "last logins", lcount, (int) (sizeof *last_login_info), - lcount * (int) (sizeof *last_login_info)); -#ifdef NETLINKS - vwrite_user(user, - "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", - "netlinks", nlcount, (int) (sizeof *nl), - nlcount * (int) (sizeof *nl)); -#endif - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, - "| %-16.16s: %12.3f Mb %8d total bytes |\n", - "total", tsize / 1048576.0, tsize); - if (!strcasecmp("-m", word[1])) { - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - } - if (!strcasecmp("-a", word[1])) { - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - } else { - write_user(user, "Usage: system [-m|-n|-r|-u|-a]\n"); - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show talker system parameters etc + */ +void +system_details(UR_OBJECT user) +{ + static const char *const ca[] ={"NONE", "SHUTDOWN", "REBOOT", "SEAMLESS"}; + static const char *const rip[] = {"OFF", "AUTO", "MANUAL", "IDENTD"}; + char bstr[32], foo[ARR_SIZE]; + UR_OBJECT u; + UD_OBJECT d; + RM_OBJECT rm; + CMD_OBJECT cmd; + size_t l; + int ucount, dcount, rmcount, cmdcount, lcount; + int tsize; + int uccount, rmpcount; +#ifdef NETLINKS + NL_OBJECT nl; + int nlcount, nlupcount, nlicount, nlocount, rmnlicount; +#endif + enum lvl_value lvl; + int days, hours, mins, secs; + + if (word_count < 2 || !strcasecmp("-a", word[1])) { + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + sprintf(text, "System Details for %s (Amnuts version %s)", TALKER_NAME, + AMNUTSVER); + vwrite_user(user, "| ~OL~FC%-74.74s~RS |\n", text); + write_user(user, + "|----------------------------------------------------------------------------|\n"); + /* Get some values */ + strftime(bstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&amsys->boot_time)); + secs = (int) (time(0) - amsys->boot_time); + days = secs / 86400; + hours = (secs % 86400) / 3600; + mins = (secs % 3600) / 60; + secs = secs % 60; + /* Show header parameters */ +#ifdef NETLINKS +#ifdef IDENTD + if (amsys->ident_state) { +#ifdef WIZPORT + write_user(user, + "| talker pid identd pid main port wiz port netlinks port |\n"); + vwrite_user(user, + "| %-5u %-5u %-5.5s %-5.5s %-5.5s |\n", + getpid(), amsys->ident_pid, amsys->mport_port, + amsys->wport_port, amsys->nlink_port); +#else + write_user(user, + "| talker pid identd pid main port netlinks port |\n"); + vwrite_user(user, + "| %-5u %-5u %-5.5s %-5.5s |\n", + getpid(), amsys->ident_pid, amsys->mport_port, + amsys->nlink_port); +#endif + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } else +#endif + { +#ifdef WIZPORT + write_user(user, + "| talker pid main port wiz port netlinks port |\n"); + vwrite_user(user, + "| %-5u %-5.5s %-5.5s %-5.5s |\n", + getpid(), amsys->mport_port, amsys->wport_port, + amsys->nlink_port); +#else + write_user(user, + "| talker pid main port netlinks port |\n"); + vwrite_user(user, + "| %-5u %-5.5s %-5.5s |\n", + getpid(), amsys->mport_port, amsys->nlink_port); +#endif + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } +#else +#ifdef IDENTD + if (amsys->ident_state) { +#ifdef WIZPORT + write_user(user, + "| talker pid identd pid main port wiz port |\n"); + vwrite_user(user, + "| %-5u %-5u %-5.5s %-5.5s |\n", + getpid(), amsys->ident_pid, amsys->mport_port, + amsys->wport_port); +#else + write_user(user, + "| talker pid identd pid main port |\n"); + vwrite_user(user, + "| %-5u %-5u %-5.5s |\n", + getpid(), amsys->ident_pid, amsys->mport_port); +#endif + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } else +#endif + { +#ifdef WIZPORT + write_user(user, + "| talker pid main port wiz port |\n"); + vwrite_user(user, + "| %-5u %-5.5s %-5.5s |\n", + getpid(), amsys->mport_port, amsys->wport_port); +#else + write_user(user, + "| talker pid main port |\n"); + vwrite_user(user, + "| %-5u %-5.5s |\n", + getpid(), amsys->mport_port); +#endif + write_user(user, + "+----------------------------------------------------------------------------+\n"); + } +#endif + vwrite_user(user, "| %-17.17s : %-54.54s |\n", "talker booted", bstr); + sprintf(text, "%d day%s, %d hour%s, %d minute%s, %d second%s", days, + PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins), + secs, PLTEXT_S(secs)); + vwrite_user(user, "| %-17.17s : %-54.54s |\n", "uptime", text); + vwrite_user(user, + "| %-17.17s : %-6.6s %-17.17s : %-10.10s |\n", + "system logging", offon[(amsys->logging) ? 1 : 0], + "flood protection", offon[amsys->flood_protect]); + vwrite_user(user, + "| %-17.17s : %-6.6s %-17.17s : %-10.10s |\n", + "ignoring sigterms", noyes[amsys->ignore_sigterm], + "crash action", ca[amsys->crash_action]); + sprintf(text, "every %d sec%s", amsys->heartbeat, + PLTEXT_S(amsys->heartbeat)); + vwrite_user(user, + "| %-17.17s : %-20.20s %-17.17s : %-10.10s |\n", + "heartbeat", text, "resolving IP", rip[amsys->resolve_ip]); + vwrite_user(user, "| %-17.17s : %-54.54s |\n", + "swear ban", minmax[amsys->ban_swearing]); + if (word_count < 2) { + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| For other options, see: system -m, -n, -r, -u, -a |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + } + /* user option */ + if (!strcasecmp("-u", word[1]) || !strcasecmp("-a", word[1])) { + uccount = 0; + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE) { + ++uccount; + } + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCSystem Details - Users~RS |\n"); + write_user(user, + "|----------------------------------------------------------------------------|\n"); + for (lvl = JAILED; lvl < NUM_LEVELS; lvl = (enum lvl_value) (lvl + 1)) { + vwrite_user(user, + "| users at level %-8.8s : %-5d |\n", + user_level[lvl].name, amsys->level_count[lvl]); + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, + "| %-24.24s: %-5d %-24.24s: %-5d |\n", + "online now", amsys->num_of_users, "max allowed online", + amsys->max_users); + vwrite_user(user, "| %-24.24s: %-5d %-24.24s: %-5d |\n", + "new this boot", amsys->logons_new, "returning this boot", + amsys->logons_old); + vwrite_user(user, "| %-24.24s: %-5d %-24.24s: %-5d |\n", + "clones now on", uccount, "max allowed clones", + amsys->max_clones); + sprintf(text, "%d sec%s", amsys->login_idle_time, + PLTEXT_S(amsys->login_idle_time)); + sprintf(foo, "%d sec%s", amsys->user_idle_time, + PLTEXT_S(amsys->user_idle_time)); + vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", + "login idle time out", text, "user idle time out", foo); + vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", + "time out maxlevel", + user_level[amsys->time_out_maxlevel].name, "time out afks", + noyes[amsys->time_out_afks]); + vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", + "current minlogin level", + amsys->minlogin_level == + NUM_LEVELS ? "NONE" : user_level[amsys->minlogin_level].name, + "min login disconnect", noyes[amsys->boot_off_min]); + vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", + "newbie prompt default", offon[amsys->prompt_def], + "newbie colour default", offon[amsys->colour_def]); + vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", + "newbie charecho default", offon[amsys->charecho_def], + "echoing password default", offon[amsys->passwordecho_def]); + vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", + "name recaps allowed", noyes[amsys->allow_recaps], + "smail auto-forwarding", offon[amsys->forwarding]); + strftime(text, ARR_SIZE * 2, "%a %Y-%m-%d %H:%M:%S", + localtime(&amsys->auto_purge_date)); + vwrite_user(user, "| %-24.24s: %-4s %-15.15s: %-25s |\n", "autopurge on", + noyes[amsys->auto_purge_date != -1], "next autopurge", text); + sprintf(text, "%d day%s", USER_EXPIRES, PLTEXT_S(USER_EXPIRES)); + sprintf(foo, "%d day%s", NEWBIE_EXPIRES, PLTEXT_S(NEWBIE_EXPIRES)); + vwrite_user(user, "| %-24.24s: %-10.10s %-24.24s: %-10.10s |\n", + "purge length (newbies)", foo, "purge length (users)", text); +#ifdef WIZPORT + vwrite_user(user, + "| %-24.24s: %-10.10s |\n", + "wizport min login level", + user_level[amsys->wizport_level].name); +#endif + if (!strcasecmp("-u", word[1])) { + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + } + /* Netlinks Option */ + if (!strcasecmp("-n", word[1]) || !strcasecmp("-a", word[1])) { + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCSystem Details - Netlinks~RS |\n"); + write_user(user, + "|----------------------------------------------------------------------------|\n"); +#ifdef NETLINKS + rmnlicount = 0; + for (rm = room_first; rm; rm = rm->next) { + if (rm->inlink) { + ++rmnlicount; + } + } + nlcount = nlupcount = nlicount = nlocount = 0; + for (nl = nl_first; nl; nl = nl->next) { + ++nlcount; + if (nl->type != UNCONNECTED && nl->stage == UP) { + ++nlupcount; + } + if (nl->type == INCOMING) { + ++nlicount; + } + if (nl->type == OUTGOING) { + ++nlocount; + } + } + vwrite_user(user, "| %-21.21s: %5d %45s |\n", + "total netlinks", nlcount, " "); + vwrite_user(user, "| %-21.21s: %5d secs %-21.21s: %5d secs |\n", + "idle time out", amsys->net_idle_time, + "keepalive interval", amsys->keepalive_interval); + vwrite_user(user, "| %-21.21s: %5d %-21.21s: %5d |\n", + "accepting connects", rmnlicount, + "live connects", nlupcount); + vwrite_user(user, "| %-21.21s: %5d %-21.21s: %5d |\n", + "incoming connections", nlicount, + "outgoing connections", nlocount); + vwrite_user(user, "| %-21.21s: %-13.13s %-21.21s: %-13.13s |\n", + "remote user maxlevel", user_level[amsys->rem_user_maxlevel].name, + "remote user deflevel", user_level[amsys->rem_user_deflevel].name); + vwrite_user(user, "| %-21.21s: %5d bytes %-21.21s: %5d bytes |\n", + "netlink structure", (int) (sizeof *nl), + "total memory", nlcount * (int) (sizeof *nl)); +#else + write_user(user, + "| Netlinks are not currently compiled into the talker. |\n"); +#endif + if (!strcasecmp("-n", word[1])) { + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + } + /* Room Option */ + if (!strcasecmp("-r", word[1]) || !strcasecmp("-a", word[1])) { + rmcount = rmpcount = 0; + for (rm = room_first; rm; rm = rm->next) { + ++rmcount; + if (is_personal_room(rm)) { + ++rmpcount; + } + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCSystem Details - Rooms~RS |\n"); + write_user(user, + "|----------------------------------------------------------------------------|\n"); + vwrite_user(user, + "| %-16.16s: %-15.15s %-20.20s: %5d |\n", + "gatecrash level", user_level[amsys->gatecrash_level].name, + "min private count", amsys->min_private_users); + sprintf(text, "%d day%s", amsys->mesg_life, PLTEXT_S(amsys->mesg_life)); + vwrite_user(user, + "| %-16.16s: %-15.15s %-20.20s: %.2d:%.2d |\n", + "message life", text, "message check time", + amsys->mesg_check_hour, amsys->mesg_check_min); + vwrite_user(user, + "| %-16.16s: %5d %-20.20s: %5d |\n", + "personal rooms", rmpcount, "total rooms", rmcount); + vwrite_user(user, "| %-16.16s: %7d bytes %-20.20s: %7d bytes |\n", + "room structure", (int) (sizeof *rm), "total memory", + rmcount * (int) (sizeof *rm)); + if (!strcasecmp("-r", word[1])) { + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + } + /* Memory Option */ + if (!strcasecmp("-m", word[1]) || !strcasecmp("-a", word[1])) { + ucount = 0; + for (u = user_first; u; u = u->next) { + ++ucount; + } + dcount = 0; + for (d = first_user_entry; d; d = d->next) { + ++dcount; + } + rmcount = 0; + for (rm = room_first; rm; rm = rm->next) { + ++rmcount; + } + cmdcount = 0; + for (cmd = first_command; cmd; cmd = cmd->next) { + ++cmdcount; + } + lcount = 0; + for (l = 0; l < LASTLOGON_NUM; ++l) { + ++lcount; + } + tsize = + ucount * (sizeof *u) + dcount * (sizeof *d) + rmcount * (sizeof *rm) + + cmdcount * (sizeof *cmd) + (sizeof *amsys) + + lcount * (sizeof *last_login_info); +#ifdef NETLINKS + nlcount = 0; + for (nl = nl_first; nl; nl = nl->next) { + ++nlcount; + } + tsize += nlcount * (sizeof *nl); +#endif + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCSystem Details - Memory Object Allocation~RS |\n"); + write_user(user, + "|----------------------------------------------------------------------------|\n"); + vwrite_user(user, + "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", + "users", ucount, (int) (sizeof *u), + ucount * (int) (sizeof *u)); + vwrite_user(user, + "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", + "all users", dcount, (int) (sizeof *d), + dcount * (int) (sizeof *d)); + vwrite_user(user, + "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", + "rooms", rmcount, (int) (sizeof *rm), + rmcount * (int) (sizeof *rm)); + vwrite_user(user, + "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", + "commands", cmdcount, (int) (sizeof *cmd), + cmdcount * (int) (sizeof *cmd)); + vwrite_user(user, + "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", + "system", 1, (int) (sizeof *amsys), + 1 * (int) (sizeof *amsys)); + vwrite_user(user, + "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", + "last logins", lcount, (int) (sizeof *last_login_info), + lcount * (int) (sizeof *last_login_info)); +#ifdef NETLINKS + vwrite_user(user, + "| %-16.16s: %8d * %8d bytes = %8d total bytes |\n", + "netlinks", nlcount, (int) (sizeof *nl), + nlcount * (int) (sizeof *nl)); +#endif + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, + "| %-16.16s: %12.3f Mb %8d total bytes |\n", + "total", tsize / 1048576.0, tsize); + if (!strcasecmp("-m", word[1])) { + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + } + if (!strcasecmp("-a", word[1])) { + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + } else { + write_user(user, "Usage: system [-m|-n|-r|-u|-a]\n"); + } +} diff --git a/src/commands/tell_user.c b/src/commands/tell_user.c index e5eef24..c50586e 100644 --- a/src/commands/tell_user.c +++ b/src/commands/tell_user.c @@ -1,125 +1,125 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Tell another user something - */ -void -tell_user(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: tell \n"; - static const char qcusage[] = "Usage: ,\n"; - const char *type; - const char *name; - UR_OBJECT u; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot speak.\n"); - return; - } - /* determine whether this is a quick call */ - if (*inpstr == ',') { - if (!*user->call) { - write_user(user, "Quick call not set.\n"); - return; - } - u = get_user_name(user, user->call); - /* if quick call with no message */ - if (word_count < 2) { - write_user(user, qcusage); - return; - } - inpstr = remove_first(inpstr); - } else { - /* if tell by itself, review tells */ - if (word_count < 2) { - revtell(user); - return; - } - u = get_user_name(user, word[1]); - /* if tell with no message */ - if (word_count < 3) { - write_user(user, usage); - return; - } - inpstr = remove_first(inpstr); - } - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "Talking to yourself is the first sign of madness.\n"); - return; - } - if (check_igusers(u, user) && user->level < GOD) { - vwrite_user(user, "%s~RS is ignoring tells from you.\n", u->recap); - return; - } - if (u->igntells && (user->level < WIZ || u->level > user->level)) { - vwrite_user(user, "%s~RS is ignoring tells at the moment.\n", u->recap); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - type = smiley_type(inpstr); - if (!type) { - type = "say"; - } - name = user->vis || u->level >= user->level ? user->recap : invisname; - sprintf(text, "~OL~FG>~RS %s~RS ~FC%ss~RS: %s\n", name, type, inpstr); - if (u->afk) { - record_afk(user, u, text); - if (*u->afk_mesg) { - vwrite_user(user, "%s~RS is ~FRAFK~RS, message is: %s\n", u->recap, - u->afk_mesg); - } else { - vwrite_user(user, "%s~RS is ~FRAFK~RS at the moment.\n", u->recap); - } - write_user(user, "Sending message to their afk review buffer.\n"); - return; - } - if (u->malloc_start) { - record_edit(user, u, text); - vwrite_user(user, - "%s~RS is in ~FCEDIT~RS mode at the moment (using the line editor).\n", - u->recap); - write_user(user, "Sending message to their edit review buffer.\n"); - return; - } - if (u->ignall && (user->level < WIZ || u->level > user->level)) { - vwrite_user(user, "%s~RS is ignoring everyone at the moment.\n", - u->recap); - return; - } -#ifdef NETLINKS - if (!u->room) { - vwrite_user(user, - "%s~RS is offsite and would not be able to reply to you.\n", - u->recap); - return; - } -#endif - record_tell(user, u, text); - write_user(u, text); - sprintf(text, "~OL~FG>~RS (%s~RS) You ~FC%s~RS: %s\n", u->recap, type, - inpstr); - record_tell(user, user, text); - write_user(user, text); -} +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Tell another user something + */ +void +tell_user(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: tell \n"; + static const char qcusage[] = "Usage: ,\n"; + const char *type; + const char *name; + UR_OBJECT u; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot speak.\n"); + return; + } + /* determine whether this is a quick call */ + if (*inpstr == ',') { + if (!*user->call) { + write_user(user, "Quick call not set.\n"); + return; + } + u = get_user_name(user, user->call); + /* if quick call with no message */ + if (word_count < 2) { + write_user(user, qcusage); + return; + } + inpstr = remove_first(inpstr); + } else { + /* if tell by itself, review tells */ + if (word_count < 2) { + revtell(user); + return; + } + u = get_user_name(user, word[1]); + /* if tell with no message */ + if (word_count < 3) { + write_user(user, usage); + return; + } + inpstr = remove_first(inpstr); + } + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "Talking to yourself is the first sign of madness.\n"); + return; + } + if (check_igusers(u, user) && user->level < GOD) { + vwrite_user(user, "%s~RS is ignoring tells from you.\n", u->recap); + return; + } + if (u->igntells && (user->level < WIZ || u->level > user->level)) { + vwrite_user(user, "%s~RS is ignoring tells at the moment.\n", u->recap); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + type = smiley_type(inpstr); + if (!type) { + type = "say"; + } + name = user->vis || u->level >= user->level ? user->recap : invisname; + sprintf(text, "~OL~FG>~RS %s~RS ~FC%ss~RS: %s\n", name, type, inpstr); + if (u->afk) { + record_afk(user, u, text); + if (*u->afk_mesg) { + vwrite_user(user, "%s~RS is ~FRAFK~RS, message is: %s\n", u->recap, + u->afk_mesg); + } else { + vwrite_user(user, "%s~RS is ~FRAFK~RS at the moment.\n", u->recap); + } + write_user(user, "Sending message to their afk review buffer.\n"); + return; + } + if (u->malloc_start) { + record_edit(user, u, text); + vwrite_user(user, + "%s~RS is in ~FCEDIT~RS mode at the moment (using the line editor).\n", + u->recap); + write_user(user, "Sending message to their edit review buffer.\n"); + return; + } + if (u->ignall && (user->level < WIZ || u->level > user->level)) { + vwrite_user(user, "%s~RS is ignoring everyone at the moment.\n", + u->recap); + return; + } +#ifdef NETLINKS + if (!u->room) { + vwrite_user(user, + "%s~RS is offsite and would not be able to reply to you.\n", + u->recap); + return; + } +#endif + record_tell(user, u, text); + write_user(u, text); + sprintf(text, "~OL~FG>~RS (%s~RS) You ~FC%s~RS: %s\n", u->recap, type, + inpstr); + record_tell(user, user, text); + write_user(user, text); +} diff --git a/src/commands/think_it.c b/src/commands/think_it.c index d510f29..36a365d 100644 --- a/src/commands/think_it.c +++ b/src/commands/think_it.c @@ -1,51 +1,51 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * put speech in a think bubbles - */ -void -think_it(UR_OBJECT user, char *inpstr) -{ -#if !!0 - static const char usage[] = "Usage: think []\n"; -#endif - const char *name; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot think out loud.\n"); - return; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_private_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - if (!user->vis) { - write_monitor(user, user->room, 0); - } - name = user->vis ? user->recap : invisname; - if (word_count < 2) { - sprintf(text, "%s~RS thinks nothing--now that is just typical!\n", name); - } else { - sprintf(text, "%s~RS thinks . o O ( %s~RS )\n", name, inpstr); - } - record(user->room, text); - write_room(user->room, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * put speech in a think bubbles + */ +void +think_it(UR_OBJECT user, char *inpstr) +{ +#if !!0 + static const char usage[] = "Usage: think []\n"; +#endif + const char *name; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot think out loud.\n"); + return; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_private_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + if (!user->vis) { + write_monitor(user, user->room, 0); + } + name = user->vis ? user->recap : invisname; + if (word_count < 2) { + sprintf(text, "%s~RS thinks nothing--now that is just typical!\n", name); + } else { + sprintf(text, "%s~RS thinks . o O ( %s~RS )\n", name, inpstr); + } + record(user->room, text); + write_room(user->room, text); +} diff --git a/src/commands/time.c b/src/commands/time.c index e10bdef..f5c8e00 100644 --- a/src/commands/time.c +++ b/src/commands/time.c @@ -1,40 +1,40 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Get current system time - */ -void -get_time(UR_OBJECT user) -{ - char dstr[32], temp[80]; - time_t now; - int secs, mins, hours, days; - - /* Get some values */ - time(&now); - secs = (int) (now - amsys->boot_time); - days = secs / 86400; - hours = (secs % 86400) / 3600; - mins = (secs % 3600) / 60; - secs = secs % 60; - write_user(user, - "+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCTalker times~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - strftime(dstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&now)); - vwrite_user(user, "| The current system time is : ~OL%-45s~RS |\n", dstr); - strftime(dstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&amsys->boot_time)); - vwrite_user(user, "| System booted : ~OL%-45s~RS |\n", dstr); - sprintf(temp, "%d day%s, %d hour%s, %d minute%s, %d second%s", days, - PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins), secs, - PLTEXT_S(secs)); - vwrite_user(user, "| Uptime : ~OL%-45s~RS |\n", temp); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Get current system time + */ +void +get_time(UR_OBJECT user) +{ + char dstr[32], temp[80]; + time_t now; + int secs, mins, hours, days; + + /* Get some values */ + time(&now); + secs = (int) (now - amsys->boot_time); + days = secs / 86400; + hours = (secs % 86400) / 3600; + mins = (secs % 3600) / 60; + secs = secs % 60; + write_user(user, + "+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCTalker times~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + strftime(dstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&now)); + vwrite_user(user, "| The current system time is : ~OL%-45s~RS |\n", dstr); + strftime(dstr, 32, "%a %Y-%m-%d %H:%M:%S", localtime(&amsys->boot_time)); + vwrite_user(user, "| System booted : ~OL%-45s~RS |\n", dstr); + sprintf(temp, "%d day%s, %d hour%s, %d minute%s, %d second%s", days, + PLTEXT_S(days), hours, PLTEXT_S(hours), mins, PLTEXT_S(mins), secs, + PLTEXT_S(secs)); + vwrite_user(user, "| Uptime : ~OL%-45s~RS |\n", temp); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); +} diff --git a/src/commands/toggle_ignall.c b/src/commands/toggle_ignall.c index 8853115..45f6961 100644 --- a/src/commands/toggle_ignall.c +++ b/src/commands/toggle_ignall.c @@ -1,34 +1,34 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Switch ignoring all on and off - */ -void -toggle_ignall(UR_OBJECT user) -{ - if (!user->ignall) { - write_user(user, "You are now ignoring everyone.\n"); - if (user->vis) { - vwrite_room_except(user->room, user, - "%s~RS is now ignoring everyone.\n", user->recap); - } else { - vwrite_room_except(user->room, user, - "%s~RS is now ignoring everyone.\n", invisname); - } - user->ignall = 1; - return; - } - write_user(user, "You will now hear everyone again.\n"); - if (user->vis) { - vwrite_room_except(user->room, user, "%s~RS is listening again.\n", - user->recap); - } else { - vwrite_room_except(user->room, user, "%s~RS is listening again.\n", - invisname); - } - user->ignall = 0; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Switch ignoring all on and off + */ +void +toggle_ignall(UR_OBJECT user) +{ + if (!user->ignall) { + write_user(user, "You are now ignoring everyone.\n"); + if (user->vis) { + vwrite_room_except(user->room, user, + "%s~RS is now ignoring everyone.\n", user->recap); + } else { + vwrite_room_except(user->room, user, + "%s~RS is now ignoring everyone.\n", invisname); + } + user->ignall = 1; + return; + } + write_user(user, "You will now hear everyone again.\n"); + if (user->vis) { + vwrite_room_except(user->room, user, "%s~RS is listening again.\n", + user->recap); + } else { + vwrite_room_except(user->room, user, "%s~RS is listening again.\n", + invisname); + } + user->ignall = 0; +} diff --git a/src/commands/toggle_mode.c b/src/commands/toggle_mode.c index f183fdd..eb5cd6c 100644 --- a/src/commands/toggle_mode.c +++ b/src/commands/toggle_mode.c @@ -1,20 +1,20 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Switch between command and speech mode - */ -void -toggle_mode(UR_OBJECT user) -{ - if (user->command_mode) { - write_user(user, "Now in ~FGSPEECH~RS mode.\n"); - user->command_mode = 0; - return; - } - write_user(user, "Now in ~FCCOMMAND~RS mode.\n"); - user->command_mode = 1; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Switch between command and speech mode + */ +void +toggle_mode(UR_OBJECT user) +{ + if (user->command_mode) { + write_user(user, "Now in ~FGSPEECH~RS mode.\n"); + user->command_mode = 0; + return; + } + write_user(user, "Now in ~FCCOMMAND~RS mode.\n"); + user->command_mode = 1; +} diff --git a/src/commands/toggle_prompt.c b/src/commands/toggle_prompt.c index 7a0ee40..f415ea0 100644 --- a/src/commands/toggle_prompt.c +++ b/src/commands/toggle_prompt.c @@ -1,20 +1,20 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Switch prompt on and off - */ -void -toggle_prompt(UR_OBJECT user) -{ - if (user->prompt) { - write_user(user, "Prompt ~FROFF.\n"); - user->prompt = 0; - return; - } - write_user(user, "Prompt ~FGON.\n"); - user->prompt = 1; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Switch prompt on and off + */ +void +toggle_prompt(UR_OBJECT user) +{ + if (user->prompt) { + write_user(user, "Prompt ~FROFF.\n"); + user->prompt = 0; + return; + } + write_user(user, "Prompt ~FGON.\n"); + user->prompt = 1; +} diff --git a/src/commands/toggle_swearban.c b/src/commands/toggle_swearban.c index 4c2f40b..d1e4cd3 100644 --- a/src/commands/toggle_swearban.c +++ b/src/commands/toggle_swearban.c @@ -1,30 +1,30 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Switch swearing ban on and off - */ -void -toggle_swearban(UR_OBJECT user) -{ - switch (amsys->ban_swearing) { - case SBOFF: - write_user(user, "Swearing ban now set to ~FGminimum ban~RS.\n"); - amsys->ban_swearing = SBMIN; - write_syslog(SYSLOG, 1, "%s set swearing ban to MIN.\n", user->name); - break; - case SBMIN: - write_user(user, "Swearing ban now set to ~FRmaximum ban~RS.\n"); - amsys->ban_swearing = SBMAX; - write_syslog(SYSLOG, 1, "%s set swearing ban to MAX.\n", user->name); - break; - case SBMAX: - write_user(user, "Swearing ban now set to ~FYoff~RS.\n"); - amsys->ban_swearing = SBOFF; - write_syslog(SYSLOG, 1, "%s set swearing ban to OFF.\n", user->name); - break; - } + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Switch swearing ban on and off + */ +void +toggle_swearban(UR_OBJECT user) +{ + switch (amsys->ban_swearing) { + case SBOFF: + write_user(user, "Swearing ban now set to ~FGminimum ban~RS.\n"); + amsys->ban_swearing = SBMIN; + write_syslog(SYSLOG, 1, "%s set swearing ban to MIN.\n", user->name); + break; + case SBMIN: + write_user(user, "Swearing ban now set to ~FRmaximum ban~RS.\n"); + amsys->ban_swearing = SBMAX; + write_syslog(SYSLOG, 1, "%s set swearing ban to MAX.\n", user->name); + break; + case SBMAX: + write_user(user, "Swearing ban now set to ~FYoff~RS.\n"); + amsys->ban_swearing = SBOFF; + write_syslog(SYSLOG, 1, "%s set swearing ban to OFF.\n", user->name); + break; + } } \ No newline at end of file diff --git a/src/commands/unarrest.c b/src/commands/unarrest.c index e2be195..199b08a 100644 --- a/src/commands/unarrest.c +++ b/src/commands/unarrest.c @@ -1,73 +1,73 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Unarrest a user who is currently under arrest and in jail - */ -void -unarrest(UR_OBJECT user) -{ - UR_OBJECT u; - RM_OBJECT rm; - int on; - - if (word_count < 2) { - write_user(user, "Usage: unarrest \n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - /* error checks */ - if (u == user) { - write_user(user, "You cannot unarrest yourself.\n"); - return; - } - if (u->level != JAILED) { - vwrite_user(user, "%s~RS is not under arrest!\n", u->recap); - done_retrieve(u); - return; - } - if (user->level < u->arrestby) { - vwrite_user(user, "%s~RS can only be unarrested by a %s or higher.\n", - u->recap, user_level[u->arrestby].name); - done_retrieve(u); - return; - } - /* do it */ - u->level = u->unarrest; - u->real_level = u->level; - u->arrestby = JAILED; /* FIXME: Use sentinel other JAILED */ - user_list_level(u->name, u->level); - strcpy(u->date, (long_date(1))); - sprintf(text, "~FG~OLYou have been unarrested... Now try to behave!\n"); - if (!on) { - send_mail(user, u->name, text, 0); - vwrite_user(user, "%s has been unarrested.\n", u->name); - } else { - write_user(u, text); - vwrite_user(user, "%s has been unarrested.\n", u->name); - write_room(NULL, "The Hand of Justice reaches through the air...\n"); - rm = get_room_full(amsys->default_warp); - if (!rm) { - vwrite_user(user, - "Cannot find a room for ex-cons, so %s~RS is still in the %s!\n", - u->recap, u->room->name); - } else { - move_user(u, rm, 2); - } - } - write_syslog(SYSLOG, 1, "%s UNARRESTED %s\n", user->name, u->name); - add_history(u->name, 1, "Was ~FGunarrested~RS by %s.\n", user->name); - if (!on) { - u->socket = -2; - strcpy(u->site, u->last_site); - } - save_user_details(u, on); - done_retrieve(u); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Unarrest a user who is currently under arrest and in jail + */ +void +unarrest(UR_OBJECT user) +{ + UR_OBJECT u; + RM_OBJECT rm; + int on; + + if (word_count < 2) { + write_user(user, "Usage: unarrest \n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + /* error checks */ + if (u == user) { + write_user(user, "You cannot unarrest yourself.\n"); + return; + } + if (u->level != JAILED) { + vwrite_user(user, "%s~RS is not under arrest!\n", u->recap); + done_retrieve(u); + return; + } + if (user->level < u->arrestby) { + vwrite_user(user, "%s~RS can only be unarrested by a %s or higher.\n", + u->recap, user_level[u->arrestby].name); + done_retrieve(u); + return; + } + /* do it */ + u->level = u->unarrest; + u->real_level = u->level; + u->arrestby = JAILED; /* FIXME: Use sentinel other JAILED */ + user_list_level(u->name, u->level); + strcpy(u->date, (long_date(1))); + sprintf(text, "~FG~OLYou have been unarrested... Now try to behave!\n"); + if (!on) { + send_mail(user, u->name, text, 0); + vwrite_user(user, "%s has been unarrested.\n", u->name); + } else { + write_user(u, text); + vwrite_user(user, "%s has been unarrested.\n", u->name); + write_room(NULL, "The Hand of Justice reaches through the air...\n"); + rm = get_room_full(amsys->default_warp); + if (!rm) { + vwrite_user(user, + "Cannot find a room for ex-cons, so %s~RS is still in the %s!\n", + u->recap, u->room->name); + } else { + move_user(u, rm, 2); + } + } + write_syslog(SYSLOG, 1, "%s UNARRESTED %s\n", user->name, u->name); + add_history(u->name, 1, "Was ~FGunarrested~RS by %s.\n", user->name); + if (!on) { + u->socket = -2; + strcpy(u->site, u->last_site); + } + save_user_details(u, on); + done_retrieve(u); } \ No newline at end of file diff --git a/src/commands/unban.c b/src/commands/unban.c index 3474f68..6c2514e 100644 --- a/src/commands/unban.c +++ b/src/commands/unban.c @@ -1,34 +1,34 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * uban a site (or domain) or user - */ -void -unban(UR_OBJECT user) -{ - static const char usage[] = - "Usage: unban site|user|new ||\n"; - - if (word_count < 3) { - write_user(user, usage); - return; - } - strtolower(word[1]); - if (!strcmp(word[1], "site")) { - unban_site(user); - return; - } - if (!strcmp(word[1], "user")) { - unban_user(user); - return; - } - if (!strcmp(word[1], "new")) { - unban_new(user); - return; - } - write_user(user, usage); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * uban a site (or domain) or user + */ +void +unban(UR_OBJECT user) +{ + static const char usage[] = + "Usage: unban site|user|new ||\n"; + + if (word_count < 3) { + write_user(user, usage); + return; + } + strtolower(word[1]); + if (!strcmp(word[1], "site")) { + unban_site(user); + return; + } + if (!strcmp(word[1], "user")) { + unban_user(user); + return; + } + if (!strcmp(word[1], "new")) { + unban_new(user); + return; + } + write_user(user, usage); +} diff --git a/src/commands/uninvite.c b/src/commands/uninvite.c index 7e42c92..6f84405 100644 --- a/src/commands/uninvite.c +++ b/src/commands/uninvite.c @@ -1,43 +1,43 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * no longer invite a user to the room you are in if you invited them - */ -void -uninvite(UR_OBJECT user) -{ - UR_OBJECT u; - const char *name; - - if (word_count < 2) { - write_user(user, "Uninvite who?\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "You cannot uninvite yourself.\n"); - return; - } - if (!u->invite_room) { - vwrite_user(user, "%s~RS has not been invited anywhere.\n", u->recap); - return; - } - if (strcmp(u->invite_by, user->name)) { - vwrite_user(user, "%s~RS has not been invited anywhere by you!\n", - u->recap); - return; - } - vwrite_user(user, "You cancel your invitation to %s~RS.\n", u->recap); - name = user->vis || u->level >= user->level ? user->recap : invisname; - vwrite_user(u, "%s~RS cancels your invitation.\n", name); - u->invite_room = NULL; - *u->invite_by = '\0'; -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * no longer invite a user to the room you are in if you invited them + */ +void +uninvite(UR_OBJECT user) +{ + UR_OBJECT u; + const char *name; + + if (word_count < 2) { + write_user(user, "Uninvite who?\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "You cannot uninvite yourself.\n"); + return; + } + if (!u->invite_room) { + vwrite_user(user, "%s~RS has not been invited anywhere.\n", u->recap); + return; + } + if (strcmp(u->invite_by, user->name)) { + vwrite_user(user, "%s~RS has not been invited anywhere by you!\n", + u->recap); + return; + } + vwrite_user(user, "You cancel your invitation to %s~RS.\n", u->recap); + name = user->vis || u->level >= user->level ? user->recap : invisname; + vwrite_user(u, "%s~RS cancels your invitation.\n", name); + u->invite_room = NULL; + *u->invite_by = '\0'; +} diff --git a/src/commands/unmuzzle.c b/src/commands/unmuzzle.c index 670a4e1..a63364e 100644 --- a/src/commands/unmuzzle.c +++ b/src/commands/unmuzzle.c @@ -1,64 +1,64 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Unmuzzle the bastard now he has apologised and grovelled enough via email - */ -void -unmuzzle(UR_OBJECT user) -{ - UR_OBJECT u; - int on; - - if (word_count < 2) { - write_user(user, "Usage: unmuzzle \n"); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - /* error checks */ - if (u == user) { - write_user(user, - "Trying to unmuzzle yourself is the tenth sign of madness.\n"); - done_retrieve(u); - return; - } - /* FIXME: Use sentinel other JAILED */ - if (u->muzzled == JAILED) { - vwrite_user(user, "%s~RS is not muzzled.\n", u->recap); - done_retrieve(u); - return; - } - if (u->muzzled > user->level) { - vwrite_user(user, - "%s~RS's muzzle is set to level %s, you do not have the power to remove it.\n", - u->recap, user_level[u->muzzled].name); - done_retrieve(u); - return; - } - /* do the unmuzzle */ - u->muzzled = JAILED; /* FIXME: Use sentinel other JAILED */ - vwrite_user(user, "~FG~OLYou remove %s~RS's muzzle.\n", u->recap); - write_syslog(SYSLOG, 1, "%s unmuzzled %s.\n", user->name, u->name); - add_history(u->name, 0, "~FGUnmuzzled~RS by %s, level %d (%s).\n", - user->name, user->level, user_level[user->level].name); - sprintf(text, "~FG~OLYou have been unmuzzled!\n"); - if (!on) { - send_mail(user, u->name, text, 0); - } else { - write_user(u, text); - } - /* finish up */ - if (!on) { - strcpy(u->site, u->last_site); - u->socket = -2; - } - save_user_details(u, on); - done_retrieve(u); + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Unmuzzle the bastard now he has apologised and grovelled enough via email + */ +void +unmuzzle(UR_OBJECT user) +{ + UR_OBJECT u; + int on; + + if (word_count < 2) { + write_user(user, "Usage: unmuzzle \n"); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + /* error checks */ + if (u == user) { + write_user(user, + "Trying to unmuzzle yourself is the tenth sign of madness.\n"); + done_retrieve(u); + return; + } + /* FIXME: Use sentinel other JAILED */ + if (u->muzzled == JAILED) { + vwrite_user(user, "%s~RS is not muzzled.\n", u->recap); + done_retrieve(u); + return; + } + if (u->muzzled > user->level) { + vwrite_user(user, + "%s~RS's muzzle is set to level %s, you do not have the power to remove it.\n", + u->recap, user_level[u->muzzled].name); + done_retrieve(u); + return; + } + /* do the unmuzzle */ + u->muzzled = JAILED; /* FIXME: Use sentinel other JAILED */ + vwrite_user(user, "~FG~OLYou remove %s~RS's muzzle.\n", u->recap); + write_syslog(SYSLOG, 1, "%s unmuzzled %s.\n", user->name, u->name); + add_history(u->name, 0, "~FGUnmuzzled~RS by %s, level %d (%s).\n", + user->name, user->level, user_level[user->level].name); + sprintf(text, "~FG~OLYou have been unmuzzled!\n"); + if (!on) { + send_mail(user, u->name, text, 0); + } else { + write_user(u, text); + } + /* finish up */ + if (!on) { + strcpy(u->site, u->last_site); + u->socket = -2; + } + save_user_details(u, on); + done_retrieve(u); } \ No newline at end of file diff --git a/src/commands/unretire.c b/src/commands/unretire.c index ad6e748..c027caa 100644 --- a/src/commands/unretire.c +++ b/src/commands/unretire.c @@ -1,55 +1,55 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Unretire a user--i.e., put them back on show on the wizlist - */ -void -unretire_user(UR_OBJECT user) -{ - UR_OBJECT u; - int on; - - if (word_count < 2) { - write_user(user, "Usage: unretire \n"); - return; - } - if (!is_retired(word[1])) { - vwrite_user(user, "%s has not been retired from the wizlist.\n", word[1]); - return; - } - u = retrieve_user(user, word[1]); - if (!u) { - return; - } - on = retrieve_user_type == 1; - if (u == user) { - write_user(user, "You cannot unretire yourself.\n"); - return; - } - if (u->level < WIZ) { - write_user(user, "You cannot retire anyone under the level WIZ.\n"); - return; - } - u->retired = 0; - clean_retire_list(u->name); - vwrite_user(user, "You unretire %s and put them back on the wizlist.\n", - u->name); - write_syslog(SYSLOG, 1, "%s UNRETIRED %s\n", user->name, u->name); - sprintf(text, "Was ~FGunretired~RS by %s.\n", user->name); - add_history(u->name, 1, "%s", text); - sprintf(text, "You have been unretired and put back on the wizlist.\n"); - if (!on) { - send_mail(user, u->name, text, 0); - } else { - write_user(u, text); - } - if (!on) { - strcpy(u->site, u->last_site); - u->socket = -2; - } - save_user_details(u, on); - done_retrieve(u); +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Unretire a user--i.e., put them back on show on the wizlist + */ +void +unretire_user(UR_OBJECT user) +{ + UR_OBJECT u; + int on; + + if (word_count < 2) { + write_user(user, "Usage: unretire \n"); + return; + } + if (!is_retired(word[1])) { + vwrite_user(user, "%s has not been retired from the wizlist.\n", word[1]); + return; + } + u = retrieve_user(user, word[1]); + if (!u) { + return; + } + on = retrieve_user_type == 1; + if (u == user) { + write_user(user, "You cannot unretire yourself.\n"); + return; + } + if (u->level < WIZ) { + write_user(user, "You cannot retire anyone under the level WIZ.\n"); + return; + } + u->retired = 0; + clean_retire_list(u->name); + vwrite_user(user, "You unretire %s and put them back on the wizlist.\n", + u->name); + write_syslog(SYSLOG, 1, "%s UNRETIRED %s\n", user->name, u->name); + sprintf(text, "Was ~FGunretired~RS by %s.\n", user->name); + add_history(u->name, 1, "%s", text); + sprintf(text, "You have been unretired and put back on the wizlist.\n"); + if (!on) { + send_mail(user, u->name, text, 0); + } else { + write_user(u, text); + } + if (!on) { + strcpy(u->site, u->last_site); + u->socket = -2; + } + save_user_details(u, on); + done_retrieve(u); } \ No newline at end of file diff --git a/src/commands/unshackle.c b/src/commands/unshackle.c index d2bd52c..cbc1295 100644 --- a/src/commands/unshackle.c +++ b/src/commands/unshackle.c @@ -1,43 +1,43 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Allow a user to move between rooms again - */ -void -unshackle(UR_OBJECT user) -{ - UR_OBJECT u; - - if (word_count < 2) { - write_user(user, "Usage: unshackle \n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (user == u) { - write_user(user, "You cannot unshackle yourself!\n"); - return; - } - if (u->lroom != 2) { - vwrite_user(user, "%s~RS in not currently shackled.\n", u->recap); - return; - } - u->lroom = 0; - write_user(u, "\n~FG~OLYou have been unshackled.\n"); - write_user(u, - "You can now use the ~FCset~RS command to alter the ~FBroom~RS attribute.\n"); - vwrite_user(user, "~FG~OLYou unshackled~RS %s~RS ~FG~OLfrom the %s room.\n", - u->recap, u->room->name); - sprintf(text, "~FGUnshackled~RS from the ~FB%s~RS room by ~FB~OL%s~RS.\n", - u->room->name, user->name); - add_history(u->name, 1, "%s", text); - write_syslog(SYSLOG, 1, "%s UNSHACKLED %s from the room: %s\n", user->name, - u->name, u->room->name); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Allow a user to move between rooms again + */ +void +unshackle(UR_OBJECT user) +{ + UR_OBJECT u; + + if (word_count < 2) { + write_user(user, "Usage: unshackle \n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (user == u) { + write_user(user, "You cannot unshackle yourself!\n"); + return; + } + if (u->lroom != 2) { + vwrite_user(user, "%s~RS in not currently shackled.\n", u->recap); + return; + } + u->lroom = 0; + write_user(u, "\n~FG~OLYou have been unshackled.\n"); + write_user(u, + "You can now use the ~FCset~RS command to alter the ~FBroom~RS attribute.\n"); + vwrite_user(user, "~FG~OLYou unshackled~RS %s~RS ~FG~OLfrom the %s room.\n", + u->recap, u->room->name); + sprintf(text, "~FGUnshackled~RS from the ~FB%s~RS room by ~FB~OL%s~RS.\n", + u->room->name, user->name); + add_history(u->name, 1, "%s", text); + write_syslog(SYSLOG, 1, "%s UNSHACKLED %s from the room: %s\n", user->name, + u->name, u->room->name); +} diff --git a/src/commands/verify.c b/src/commands/verify.c index 9f44370..77a7cdf 100644 --- a/src/commands/verify.c +++ b/src/commands/verify.c @@ -1,36 +1,36 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * verify that mail has been sent to the address supplied - */ -void -verify_email(UR_OBJECT user) -{ - if (word_count < 2) { - write_user(user, "Usage: verify \n"); - return; - } - if (!*user->email) { - write_user(user, - "You have not yet set your email address. You must do this first.\n"); - return; - } - if (user->mail_verified) { - write_user(user, - "You have already verified your current email address.\n"); - return; - } - if (strcmp(user->verify_code, word[1]) || !*user->verify_code) { - write_user(user, - "That does not match your verification code. Check your code and try again.\n"); - return; - } - *user->verify_code = '\0'; - user->mail_verified = 1; - write_user(user, - "\nThe verification code you gave was correct.\nYou may now use the auto-forward functions.\n\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * verify that mail has been sent to the address supplied + */ +void +verify_email(UR_OBJECT user) +{ + if (word_count < 2) { + write_user(user, "Usage: verify \n"); + return; + } + if (!*user->email) { + write_user(user, + "You have not yet set your email address. You must do this first.\n"); + return; + } + if (user->mail_verified) { + write_user(user, + "You have already verified your current email address.\n"); + return; + } + if (strcmp(user->verify_code, word[1]) || !*user->verify_code) { + write_user(user, + "That does not match your verification code. Check your code and try again.\n"); + return; + } + *user->verify_code = '\0'; + user->mail_verified = 1; + write_user(user, + "\nThe verification code you gave was correct.\nYou may now use the auto-forward functions.\n\n"); +} diff --git a/src/commands/viewlog.c b/src/commands/viewlog.c index a845887..c59be3c 100644 --- a/src/commands/viewlog.c +++ b/src/commands/viewlog.c @@ -1,220 +1,220 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * View the system log - */ -void -viewlog(UR_OBJECT user) -{ - static const char emp[] = "This log file is empty.\n\n"; - char logfile[80]; - char dstr[32]; - FILE *fp; - int lines, cnt, cnt2, type; - enum lvl_value lvl; - int c; - - if (word_count < 2) { - write_user(user, - "Usage: viewlog sys|net|req|err| []\n"); - return; - } - *logfile = '\0'; - strtoupper(word[1]); - lvl = get_level(word[1]); - strftime(dstr, 32, "%Y%m%d", localtime(&amsys->boot_time)); - if (word_count == 2) { - if (!strcmp(word[1], "SYS")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, MAINSYSLOG, dstr); - write_user(user, "\n~BB~FG*** System log ***\n\n"); - } else if (!strcmp(word[1], "NET")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, NETSYSLOG, dstr); - write_user(user, "\n~BB~FG*** Netlink log ***\n\n"); - } else if (!strcmp(word[1], "REQ")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, REQSYSLOG, dstr); - write_user(user, "\n~BB~FG*** Account Request log ***\n\n"); - } else if (!strcmp(word[1], "ERR")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, ERRSYSLOG, dstr); - write_user(user, "\n~BB~FG*** Error log ***\n\n"); - } else if (lvl != NUM_LEVELS) { - vwrite_user(user, "\n~BB~FG*** User list for level \"%s\" ***\n\n", - user_level[lvl].name); - if (!amsys->level_count[lvl]) { - write_user(user, emp); - return; - } - user->user_page_lev = lvl; - switch (more_users(user)) { - case 0: - write_user(user, emp); - return; - case 1: - user->misc_op = 16; - break; - } - return; - } else { - write_user(user, - "Usage: viewlog sys|net|req|err| []\n"); - return; - } - switch (more(user, user->socket, logfile)) { - case 0: - write_user(user, emp); - return; - case 1: - user->misc_op = 2; - break; - } - return; - } - lines = atoi(word[2]); - if (lines < 1) { - write_user(user, - "Usage: viewlog sys|net|req|err| []\n"); - return; - } - type = 0; - /* find out which log */ - if (!strcmp(word[1], "SYS")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, MAINSYSLOG, dstr); - type = SYSLOG; - } - if (!strcmp(word[1], "NET")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, NETSYSLOG, dstr); - type = NETLOG; - } - if (!strcmp(word[1], "REQ")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, REQSYSLOG, dstr); - type = REQLOG; - } - if (!strcmp(word[1], "ERR")) { - sprintf(logfile, "%s/%s.%s", LOGFILES, ERRSYSLOG, dstr); - type = ERRLOG; - } - if (lvl != NUM_LEVELS) { - if (!amsys->level_count[lvl]) { - write_user(user, emp); - return; - } - if (lines > amsys->level_count[lvl]) { - vwrite_user(user, "There %s only %d line%s in the log.\n", - PLTEXT_IS(amsys->level_count[lvl]), amsys->level_count[lvl], - PLTEXT_S(amsys->level_count[lvl])); - return; - } - if (lines == amsys->level_count[lvl]) { - vwrite_user(user, "\n~BB~FG*** User list for level \"%s\" ***\n\n", - user_level[lvl].name); - } else { - user->user_page_pos = amsys->level_count[lvl] - lines; - vwrite_user(user, - "\n~BB~FG*** User list for level \"%s\" (last %d line%s) ***\n\n", - user_level[lvl].name, lines, PLTEXT_S(lines)); - } - user->user_page_lev = lvl; - switch (more_users(user)) { - case 0: - write_user(user, emp); - return; - case 1: - user->misc_op = 16; - break; - } - return; - } - /* count total lines */ - fp = fopen(logfile, "r"); - if (!fp) { - write_user(user, emp); - return; - } - cnt = 0; - for (c = getc(fp); c != EOF; c = getc(fp)) { - if (c == '\n') { - ++cnt; - } - } - if (cnt < lines) { - vwrite_user(user, "There %s only %d line%s in the log.\n", PLTEXT_IS(cnt), - cnt, PLTEXT_S(cnt)); - fclose(fp); - return; - } - if (cnt == lines) { - switch (type) { - case SYSLOG: - write_user(user, "\n~BB~FG*** System log ***\n\n"); - break; - case NETLOG: - write_user(user, "\n~BB~FG*** Netlink log ***\n\n"); - break; - case REQLOG: - write_user(user, "\n~BB~FG*** Account Request log ***\n\n"); - break; - case ERRLOG: - write_user(user, "\n~BB~FG*** Error log ***\n\n"); - break; - } - fclose(fp); - switch (more(user, user->socket, logfile)) { - case 0: - break; - case 1: - user->misc_op = 2; - break; - } -#if !!0 - more(user, user->socket, logfile); -#endif - return; - } - /* Find line to start on */ - fseek(fp, 0, 0); - cnt2 = 0; - for (c = getc(fp); c != EOF; c = getc(fp)) { - if (c != '\n') { - continue; - } - if (++cnt2 == cnt - lines) { - break; - } - } - if (c == EOF) { - fclose(fp); - vwrite_user(user, "%s: Line count error.\n", syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Line count error in viewlog().\n"); - return; - } - user->filepos = ftell(fp); - fclose(fp); - switch (type) { - case SYSLOG: - vwrite_user(user, "\n~BB~FG*** System log (last %d line%s) ***\n\n", - lines, PLTEXT_S(lines)); - break; - case NETLOG: - vwrite_user(user, "\n~BB~FG*** Netlink log (last %d line%s) ***\n\n", - lines, PLTEXT_S(lines)); - break; - case REQLOG: - vwrite_user(user, - "\n~BB~FG*** Account Request log (last %d line%s) ***\n\n", - lines, PLTEXT_S(lines)); - break; - case ERRLOG: - vwrite_user(user, "\n~BB~FG*** Error log (last %d line%s) ***\n\n", lines, - PLTEXT_S(lines)); - break; - } - if (more(user, user->socket, logfile) != 1) { - user->filepos = 0; - } else { - user->misc_op = 2; - } -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * View the system log + */ +void +viewlog(UR_OBJECT user) +{ + static const char emp[] = "This log file is empty.\n\n"; + char logfile[80]; + char dstr[32]; + FILE *fp; + int lines, cnt, cnt2, type; + enum lvl_value lvl; + int c; + + if (word_count < 2) { + write_user(user, + "Usage: viewlog sys|net|req|err| []\n"); + return; + } + *logfile = '\0'; + strtoupper(word[1]); + lvl = get_level(word[1]); + strftime(dstr, 32, "%Y%m%d", localtime(&amsys->boot_time)); + if (word_count == 2) { + if (!strcmp(word[1], "SYS")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, MAINSYSLOG, dstr); + write_user(user, "\n~BB~FG*** System log ***\n\n"); + } else if (!strcmp(word[1], "NET")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, NETSYSLOG, dstr); + write_user(user, "\n~BB~FG*** Netlink log ***\n\n"); + } else if (!strcmp(word[1], "REQ")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, REQSYSLOG, dstr); + write_user(user, "\n~BB~FG*** Account Request log ***\n\n"); + } else if (!strcmp(word[1], "ERR")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, ERRSYSLOG, dstr); + write_user(user, "\n~BB~FG*** Error log ***\n\n"); + } else if (lvl != NUM_LEVELS) { + vwrite_user(user, "\n~BB~FG*** User list for level \"%s\" ***\n\n", + user_level[lvl].name); + if (!amsys->level_count[lvl]) { + write_user(user, emp); + return; + } + user->user_page_lev = lvl; + switch (more_users(user)) { + case 0: + write_user(user, emp); + return; + case 1: + user->misc_op = 16; + break; + } + return; + } else { + write_user(user, + "Usage: viewlog sys|net|req|err| []\n"); + return; + } + switch (more(user, user->socket, logfile)) { + case 0: + write_user(user, emp); + return; + case 1: + user->misc_op = 2; + break; + } + return; + } + lines = atoi(word[2]); + if (lines < 1) { + write_user(user, + "Usage: viewlog sys|net|req|err| []\n"); + return; + } + type = 0; + /* find out which log */ + if (!strcmp(word[1], "SYS")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, MAINSYSLOG, dstr); + type = SYSLOG; + } + if (!strcmp(word[1], "NET")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, NETSYSLOG, dstr); + type = NETLOG; + } + if (!strcmp(word[1], "REQ")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, REQSYSLOG, dstr); + type = REQLOG; + } + if (!strcmp(word[1], "ERR")) { + sprintf(logfile, "%s/%s.%s", LOGFILES, ERRSYSLOG, dstr); + type = ERRLOG; + } + if (lvl != NUM_LEVELS) { + if (!amsys->level_count[lvl]) { + write_user(user, emp); + return; + } + if (lines > amsys->level_count[lvl]) { + vwrite_user(user, "There %s only %d line%s in the log.\n", + PLTEXT_IS(amsys->level_count[lvl]), amsys->level_count[lvl], + PLTEXT_S(amsys->level_count[lvl])); + return; + } + if (lines == amsys->level_count[lvl]) { + vwrite_user(user, "\n~BB~FG*** User list for level \"%s\" ***\n\n", + user_level[lvl].name); + } else { + user->user_page_pos = amsys->level_count[lvl] - lines; + vwrite_user(user, + "\n~BB~FG*** User list for level \"%s\" (last %d line%s) ***\n\n", + user_level[lvl].name, lines, PLTEXT_S(lines)); + } + user->user_page_lev = lvl; + switch (more_users(user)) { + case 0: + write_user(user, emp); + return; + case 1: + user->misc_op = 16; + break; + } + return; + } + /* count total lines */ + fp = fopen(logfile, "r"); + if (!fp) { + write_user(user, emp); + return; + } + cnt = 0; + for (c = getc(fp); c != EOF; c = getc(fp)) { + if (c == '\n') { + ++cnt; + } + } + if (cnt < lines) { + vwrite_user(user, "There %s only %d line%s in the log.\n", PLTEXT_IS(cnt), + cnt, PLTEXT_S(cnt)); + fclose(fp); + return; + } + if (cnt == lines) { + switch (type) { + case SYSLOG: + write_user(user, "\n~BB~FG*** System log ***\n\n"); + break; + case NETLOG: + write_user(user, "\n~BB~FG*** Netlink log ***\n\n"); + break; + case REQLOG: + write_user(user, "\n~BB~FG*** Account Request log ***\n\n"); + break; + case ERRLOG: + write_user(user, "\n~BB~FG*** Error log ***\n\n"); + break; + } + fclose(fp); + switch (more(user, user->socket, logfile)) { + case 0: + break; + case 1: + user->misc_op = 2; + break; + } +#if !!0 + more(user, user->socket, logfile); +#endif + return; + } + /* Find line to start on */ + fseek(fp, 0, 0); + cnt2 = 0; + for (c = getc(fp); c != EOF; c = getc(fp)) { + if (c != '\n') { + continue; + } + if (++cnt2 == cnt - lines) { + break; + } + } + if (c == EOF) { + fclose(fp); + vwrite_user(user, "%s: Line count error.\n", syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Line count error in viewlog().\n"); + return; + } + user->filepos = ftell(fp); + fclose(fp); + switch (type) { + case SYSLOG: + vwrite_user(user, "\n~BB~FG*** System log (last %d line%s) ***\n\n", + lines, PLTEXT_S(lines)); + break; + case NETLOG: + vwrite_user(user, "\n~BB~FG*** Netlink log (last %d line%s) ***\n\n", + lines, PLTEXT_S(lines)); + break; + case REQLOG: + vwrite_user(user, + "\n~BB~FG*** Account Request log (last %d line%s) ***\n\n", + lines, PLTEXT_S(lines)); + break; + case ERRLOG: + vwrite_user(user, "\n~BB~FG*** Error log (last %d line%s) ***\n\n", lines, + PLTEXT_S(lines)); + break; + } + if (more(user, user->socket, logfile) != 1) { + user->filepos = 0; + } else { + user->misc_op = 2; + } +} diff --git a/src/commands/visibility.c b/src/commands/visibility.c index 8f2c075..ea47b8d 100644 --- a/src/commands/visibility.c +++ b/src/commands/visibility.c @@ -1,35 +1,35 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Set user visible or invisible - */ -void -visibility(UR_OBJECT user, int vis) -{ - if (vis) { - if (user->vis) { - write_user(user, "You are already visible.\n"); - return; - } - write_user(user, - "~FB~OLYou recite a melodic incantation and reappear.\n"); - vwrite_room_except(user->room, user, - "~FB~OLYou hear a melodic incantation chanted and %s materialises!\n", - user->bw_recap); - user->vis = 1; - return; - } - if (!user->vis) { - write_user(user, "You are already invisible.\n"); - return; - } - write_user(user, "~FB~OLYou recite a melodic incantation and fade out.\n"); - vwrite_room_except(user->room, user, - "~FB~OL%s recites a melodic incantation and disappears!\n", - user->bw_recap); - user->vis = 0; + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Set user visible or invisible + */ +void +visibility(UR_OBJECT user, int vis) +{ + if (vis) { + if (user->vis) { + write_user(user, "You are already visible.\n"); + return; + } + write_user(user, + "~FB~OLYou recite a melodic incantation and reappear.\n"); + vwrite_room_except(user->room, user, + "~FB~OLYou hear a melodic incantation chanted and %s materialises!\n", + user->bw_recap); + user->vis = 1; + return; + } + if (!user->vis) { + write_user(user, "You are already invisible.\n"); + return; + } + write_user(user, "~FB~OLYou recite a melodic incantation and fade out.\n"); + vwrite_room_except(user->room, user, + "~FB~OL%s recites a melodic incantation and disappears!\n", + user->bw_recap); + user->vis = 0; } \ No newline at end of file diff --git a/src/commands/visit.c b/src/commands/visit.c index f0fc45d..196e1b3 100644 --- a/src/commands/visit.c +++ b/src/commands/visit.c @@ -2,6 +2,9 @@ #include "globals.h" #include "commands.h" #include "prototypes.h" +#ifndef __SDS_H +#include "../vendors/sds/sds.h" +#endif /* * let a user go into another user's personal room if it is unlocked diff --git a/src/commands/wake.c b/src/commands/wake.c index c594009..95993f9 100644 --- a/src/commands/wake.c +++ b/src/commands/wake.c @@ -1,69 +1,69 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Wake up some idle sod - */ -void -wake(UR_OBJECT user) -{ - static const char usage[] = "Usage: wake \n"; - UR_OBJECT u; - const char *name; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot wake anyone.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, - "Trying to wake yourself up is the eighth sign of madness.\n"); - return; - } - if (check_igusers(u, user) && user->level < GOD) { - vwrite_user(user, "%s~RS is ignoring wakes from you.\n", u->recap); - return; - } - if (u->ignbeeps && (user->level < WIZ || u->level > user->level)) { - vwrite_user(user, "%s~RS is ignoring wakes at the moment.\n", u->recap); - return; - } - if (u->afk) { - write_user(user, "You cannot wake someone who is AFK.\n"); - return; - } - if (u->malloc_start) { - write_user(user, "You cannot wake someone who is in the editor.\n"); - return; - } - if (u->ignall && (user->level < WIZ || u->level > user->level)) { - write_user(user, "You cannot wake someone who ignoring everything.\n"); - return; - } -#ifdef NETLINKS - if (!u->room) { - vwrite_user(user, - "%s~RS is offsite and would not be able to reply to you.\n", - u->recap); - return; - } -#endif - name = user->vis ? user->recap : invisname; - vwrite_user(u, - "\n%s~BR***~RS %s~RS ~BRsays~RS: ~OL~LI~BRHEY! WAKE UP!!!~RS ~BR***\n\n", - u->ignbeeps ? "" : "\007", name); - write_user(user, "Wake up call sent.\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Wake up some idle sod + */ +void +wake(UR_OBJECT user) +{ + static const char usage[] = "Usage: wake \n"; + UR_OBJECT u; + const char *name; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot wake anyone.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, + "Trying to wake yourself up is the eighth sign of madness.\n"); + return; + } + if (check_igusers(u, user) && user->level < GOD) { + vwrite_user(user, "%s~RS is ignoring wakes from you.\n", u->recap); + return; + } + if (u->ignbeeps && (user->level < WIZ || u->level > user->level)) { + vwrite_user(user, "%s~RS is ignoring wakes at the moment.\n", u->recap); + return; + } + if (u->afk) { + write_user(user, "You cannot wake someone who is AFK.\n"); + return; + } + if (u->malloc_start) { + write_user(user, "You cannot wake someone who is in the editor.\n"); + return; + } + if (u->ignall && (user->level < WIZ || u->level > user->level)) { + write_user(user, "You cannot wake someone who ignoring everything.\n"); + return; + } +#ifdef NETLINKS + if (!u->room) { + vwrite_user(user, + "%s~RS is offsite and would not be able to reply to you.\n", + u->recap); + return; + } +#endif + name = user->vis ? user->recap : invisname; + vwrite_user(u, + "\n%s~BR***~RS %s~RS ~BRsays~RS: ~OL~LI~BRHEY! WAKE UP!!!~RS ~BR***\n\n", + u->ignbeeps ? "" : "\007", name); + write_user(user, "Wake up call sent.\n"); +} diff --git a/src/commands/who.c b/src/commands/who.c index e0e1bda..3f1e10c 100644 --- a/src/commands/who.c +++ b/src/commands/who.c @@ -1,211 +1,211 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show who is on. type 0=who, 1=fwho, 2=people - */ -void -who(UR_OBJECT user, int type) -{ - char line[RECAP_NAME_LEN + USER_DESC_LEN * 3]; - char rname[ROOM_NAME_LEN + PERSONAL_ROOMNAME_LEN + 1]; - char idlestr[20]; - char sockstr[3]; - const char *portstr; - UR_OBJECT u; - int mins; - int idle; - int linecnt; - int rnamecnt; - int total; - int invis; - int logins; -#ifdef NETLINKS - int remote = 0; -#endif - - total = invis = logins = 0; - - if (type == 2 && !strcmp(word[1], "key")) { - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - "| ~OL~FCUser login stages are as follows~RS |\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, - "| ~FY~OLStage %d :~RS The user has logged onto the port and is entering their name |\n", - LOGIN_NAME); - vwrite_user(user, - "| ~FY~OLStage %d :~RS The user is entering their password for the first time |\n", - LOGIN_PASSWD); - vwrite_user(user, - "| ~FY~OLStage %d :~RS The user is new and has been asked to confirm their password |\n", - LOGIN_CONFIRM); - vwrite_user(user, - "| ~FY~OLStage %d :~RS The user has entered the pre-login information prompt |\n", - LOGIN_PROMPT); - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - write_user(user, - align_string(1, 78, 0, NULL, "%sCurrent users %s", - (user->login) ? "" : "~FG", long_date(1))); - switch (type) { - case 0: - vwrite_user(user, - "%s Name : Room : Tm/Id\n", - (user->login) ? "" : "~FC"); - break; - case 1: - write_user(user, - "~FCFriend : Room : Tm/Id\n"); - break; - case 2: - write_user(user, - "~FCName : Level Line Ignall Visi Idle Mins Port Site/Service\n"); - break; - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - for (u = user_first; u; u = u->next) { - if (u->type == CLONE_TYPE) { - continue; - } - mins = (int) (time(0) - u->last_login) / 60; - idle = (int) (time(0) - u->last_input) / 60; -#ifdef NETLINKS - if (u->type == REMOTE_TYPE) { - portstr = " @"; - } else -#endif - { -#ifdef WIZPORT - if (u->wizport) { - portstr = " WIZ"; - } else -#endif - { - portstr = "MAIN"; - } - } - if (u->login) { - if (type != 2) { - continue; - } - vwrite_user(user, - "~FY[Login stage %d]~RS : - %2d - - %4d - %s %s:%s\n", - u->login, u->socket, idle, portstr, u->site, u->site_port); - ++logins; - continue; - } - if (type == 1 && !user_is_friend(user, u)) { - continue; - } - ++total; -#ifdef NETLINKS - if (u->type == REMOTE_TYPE) { - ++remote; - } -#endif - if (!u->vis) { - ++invis; - if (u->level > user->level && !(user->level >= ARCH)) { - continue; - } - } - if (type == 2) { - if (u->afk) { - strcpy(idlestr, " ~FRAFK~RS"); - } else if (u->malloc_start) { - strcpy(idlestr, "~FCEDIT~RS"); - } else { - sprintf(idlestr, "%4d", idle); - } -#ifdef NETLINKS - if (u->type == REMOTE_TYPE) { - strcpy(sockstr, " @"); - } else -#endif - sprintf(sockstr, "%2d", u->socket); - linecnt = 15 + teslen(u->recap, 15); - vwrite_user(user, - "%-*.*s~RS : %-5.5s %s %-6s %-4s %s %4d %-4s %s\n", - linecnt, linecnt, u->recap, user_level[u->level].name, - sockstr, noyes[u->ignall], noyes[u->vis], idlestr, mins, - portstr, u->site); - continue; - } - sprintf(line, " %s~RS %s", u->recap, u->desc); - if (!u->vis) { - *line = '*'; - } -#ifdef NETLINKS - if (u->type == REMOTE_TYPE) { - line[1] = '@'; - } - if (!u->room) { - sprintf(rname, "@%s", u->netlink->service); - } else { -#endif - strcpy(rname, - is_personal_room(u->room) ? u->room->show_name : u->room->name); -#ifdef NETLINKS - } -#endif - - /* Count number of colour coms to be taken account of when formatting */ - if (u->afk) { - strcpy(idlestr, "~FRAFK~RS"); - } else if (u->malloc_start) { - strcpy(idlestr, "~FCEDIT~RS"); - } else if (idle >= 30) { - strcpy(idlestr, "~FYIDLE~RS"); - } else { - sprintf(idlestr, "%d/%d", mins, idle); - } - linecnt = 45 + teslen(line, 45); - rnamecnt = 15 + teslen(rname, 15); - vwrite_user(user, "%-*.*s~RS %1.1s : %-*.*s~RS : %s\n", linecnt, linecnt, - line, user_level[u->level].alias, rnamecnt, rnamecnt, rname, - idlestr); - } - write_user(user, - "\n+----------------------------------------------------------------------------+\n"); - switch (type) { - case 0: - case 2: - if (type == 2) { - sprintf(text, "and ~OL~FG%d~RS login%s ", logins, PLTEXT_S(logins)); - } -#ifdef NETLINKS - write_user(user, - align_string(1, 78, 0, NULL, - "Total of ~OL~FG%d~RS user%s %s: ~OL~FC%d~RS visible, ~OL~FC%d~RS invisible, ~OL~FC%d~RS remote", - total, PLTEXT_S(total), type == 2 ? text : "", - amsys->num_of_users - invis, invis, remote)); -#else - write_user(user, - align_string(1, 78, 0, NULL, - "Total of ~OL~FG%d~RS user%s %s: ~OL~FC%d~RS visible, ~OL~FC%d~RS invisible", - total, PLTEXT_S(total), type == 2 ? text : "", - amsys->num_of_users - invis, invis)); -#endif - break; - case 1: - write_user(user, - align_string(1, 78, 0, NULL, - "Total of ~OL~FG%d~RS friend%s : ~OL~FC%d~RS visible, ~OL~FC%d~RS invisible", - total, PLTEXT_S(total), total - invis, invis)); - break; - } - write_user(user, - "+----------------------------------------------------------------------------+\n"); -} - + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show who is on. type 0=who, 1=fwho, 2=people + */ +void +who(UR_OBJECT user, int type) +{ + char line[RECAP_NAME_LEN + USER_DESC_LEN * 3]; + char rname[ROOM_NAME_LEN + PERSONAL_ROOMNAME_LEN + 1]; + char idlestr[20]; + char sockstr[3]; + const char *portstr; + UR_OBJECT u; + int mins; + int idle; + int linecnt; + int rnamecnt; + int total; + int invis; + int logins; +#ifdef NETLINKS + int remote = 0; +#endif + + total = invis = logins = 0; + + if (type == 2 && !strcmp(word[1], "key")) { + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + "| ~OL~FCUser login stages are as follows~RS |\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, + "| ~FY~OLStage %d :~RS The user has logged onto the port and is entering their name |\n", + LOGIN_NAME); + vwrite_user(user, + "| ~FY~OLStage %d :~RS The user is entering their password for the first time |\n", + LOGIN_PASSWD); + vwrite_user(user, + "| ~FY~OLStage %d :~RS The user is new and has been asked to confirm their password |\n", + LOGIN_CONFIRM); + vwrite_user(user, + "| ~FY~OLStage %d :~RS The user has entered the pre-login information prompt |\n", + LOGIN_PROMPT); + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + write_user(user, + align_string(ALIGN_CENTRE, 78, 0, NULL, "%sCurrent users %s", + (user->login) ? "" : "~FG", long_date(1))); + switch (type) { + case 0: + vwrite_user(user, + "%s Name : Room : Tm/Id\n", + (user->login) ? "" : "~FC"); + break; + case 1: + write_user(user, + "~FCFriend : Room : Tm/Id\n"); + break; + case 2: + write_user(user, + "~FCName : Level Line Ignall Visi Idle Mins Port Site/Service\n"); + break; + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + for (u = user_first; u; u = u->next) { + if (u->type == CLONE_TYPE) { + continue; + } + mins = (int) (time(0) - u->last_login) / 60; + idle = (int) (time(0) - u->last_input) / 60; +#ifdef NETLINKS + if (u->type == REMOTE_TYPE) { + portstr = " @"; + } else +#endif + { +#ifdef WIZPORT + if (u->wizport) { + portstr = " WIZ"; + } else +#endif + { + portstr = "MAIN"; + } + } + if (u->login) { + if (type != 2) { + continue; + } + vwrite_user(user, + "~FY[Login stage %d]~RS : - %2d - - %4d - %s %s:%s\n", + u->login, u->socket, idle, portstr, u->site, u->site_port); + ++logins; + continue; + } + if (type == 1 && !user_is_friend(user, u)) { + continue; + } + ++total; +#ifdef NETLINKS + if (u->type == REMOTE_TYPE) { + ++remote; + } +#endif + if (!u->vis) { + ++invis; + if (u->level > user->level && !(user->level >= ARCH)) { + continue; + } + } + if (type == 2) { + if (u->afk) { + strcpy(idlestr, " ~FRAFK~RS"); + } else if (u->malloc_start) { + strcpy(idlestr, "~FCEDIT~RS"); + } else { + sprintf(idlestr, "%4d", idle); + } +#ifdef NETLINKS + if (u->type == REMOTE_TYPE) { + strcpy(sockstr, " @"); + } else +#endif + sprintf(sockstr, "%2d", u->socket); + linecnt = 15 + teslen(u->recap, 15); + vwrite_user(user, + "%-*.*s~RS : %-5.5s %s %-6s %-4s %s %4d %-4s %s\n", + linecnt, linecnt, u->recap, user_level[u->level].name, + sockstr, noyes[u->ignall], noyes[u->vis], idlestr, mins, + portstr, u->site); + continue; + } + sprintf(line, " %s~RS %s", u->recap, u->desc); + if (!u->vis) { + *line = '*'; + } +#ifdef NETLINKS + if (u->type == REMOTE_TYPE) { + line[1] = '@'; + } + if (!u->room) { + sprintf(rname, "@%s", u->netlink->service); + } else { +#endif + strcpy(rname, + is_personal_room(u->room) ? u->room->show_name : u->room->name); +#ifdef NETLINKS + } +#endif + + /* Count number of colour coms to be taken account of when formatting */ + if (u->afk) { + strcpy(idlestr, "~FRAFK~RS"); + } else if (u->malloc_start) { + strcpy(idlestr, "~FCEDIT~RS"); + } else if (idle >= 30) { + strcpy(idlestr, "~FYIDLE~RS"); + } else { + sprintf(idlestr, "%d/%d", mins, idle); + } + linecnt = 45 + teslen(line, 45); + rnamecnt = 15 + teslen(rname, 15); + vwrite_user(user, "%-*.*s~RS %1.1s : %-*.*s~RS : %s\n", linecnt, linecnt, + line, user_level[u->level].alias, rnamecnt, rnamecnt, rname, + idlestr); + } + write_user(user, + "\n+----------------------------------------------------------------------------+\n"); + switch (type) { + case 0: + case 2: + if (type == 2) { + sprintf(text, "and ~OL~FG%d~RS login%s ", logins, PLTEXT_S(logins)); + } +#ifdef NETLINKS + write_user(user, + align_string(ALIGN_CENTRE, 78, 0, NULL, + "Total of ~OL~FG%d~RS user%s %s: ~OL~FC%d~RS visible, ~OL~FC%d~RS invisible, ~OL~FC%d~RS remote", + total, PLTEXT_S(total), type == 2 ? text : "", + amsys->num_of_users - invis, invis, remote)); +#else + write_user(user, + align_string(ALIGN_CENTRE, 78, 0, NULL, + "Total of ~OL~FG%d~RS user%s %s: ~OL~FC%d~RS visible, ~OL~FC%d~RS invisible", + total, PLTEXT_S(total), type == 2 ? text : "", + amsys->num_of_users - invis, invis)); +#endif + break; + case 1: + write_user(user, + align_string(ALIGN_CENTRE, 78, 0, NULL, + "Total of ~OL~FG%d~RS friend%s : ~OL~FC%d~RS visible, ~OL~FC%d~RS invisible", + total, PLTEXT_S(total), total - invis, invis)); + break; + } + write_user(user, + "+----------------------------------------------------------------------------+\n"); +} + diff --git a/src/commands/wipe_board.c b/src/commands/wipe_board.c index 5a17837..a0bc097 100644 --- a/src/commands/wipe_board.c +++ b/src/commands/wipe_board.c @@ -1,101 +1,101 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Wipe some messages off the board - */ -void -wipe_board(UR_OBJECT user) -{ - char filename[80]; - const char *name; - RM_OBJECT rm; - int cnt; - - rm = user->room; - if (word_count < 2 && ((user->level >= WIZ && !is_personal_room(rm)) - || (is_personal_room(rm) - && (is_my_room(user, rm) - || user->level >= GOD)))) { - write_user(user, "Usage: wipe all\n"); - write_user(user, " wipe <#>\n"); - write_user(user, " wipe to <#>\n"); - write_user(user, " wipe from <#> to <#>\n"); - return; - } else if (word_count < 2 && ((user->level < WIZ && !is_personal_room(rm)) - || (is_personal_room(rm) - && !is_my_room(user, rm) - && user->level < GOD))) { - write_user(user, "Usage: wipe <#>\n"); - return; - } - if (is_personal_room(rm)) { - if (!is_my_room(user, rm) && user->level < GOD && !check_board_wipe(user)) { - return; - } else if (get_wipe_parameters(user) == -1) { - return; - } - } else { - if (user->level < WIZ && !(check_board_wipe(user))) { - return; - } else if (get_wipe_parameters(user) == -1) { - return; - } - } - name = user->vis ? user->recap : invisname; - if (is_personal_room(rm)) { - sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); - } else { - sprintf(filename, "%s/%s.B", DATAFILES, rm->name); - } - if (!rm->mesg_cnt) { - write_user(user, "There are no messages on the room board.\n"); - return; - } - if (user->wipe_from == -1) { - remove(filename); - write_user(user, "All messages deleted.\n"); - if (user->level < GOD || user->vis) { - vwrite_room_except(rm, user, "%s~RS wipes the message board.\n", name); - } - write_syslog(SYSLOG, 1, - "%s wiped all messages from the board in the %s.\n", - user->name, rm->name); - rm->mesg_cnt = 0; - return; - } - if (user->wipe_from > rm->mesg_cnt) { - vwrite_user(user, "There %s only %d message%s on the board.\n", - PLTEXT_IS(rm->mesg_cnt), rm->mesg_cnt, - PLTEXT_S(rm->mesg_cnt)); - return; - } - cnt = wipe_messages(filename, user->wipe_from, user->wipe_to, 0); - if (cnt == rm->mesg_cnt) { - remove(filename); - vwrite_user(user, - "There %s only %d message%s on the board, all now deleted.\n", - PLTEXT_WAS(rm->mesg_cnt), rm->mesg_cnt, - PLTEXT_S(rm->mesg_cnt)); - if (user->level < GOD || user->vis) { - vwrite_room_except(rm, user, "%s wipes the message board.\n", name); - } - write_syslog(SYSLOG, 1, - "%s wiped all messages from the board in the %s.\n", - user->name, rm->name); - rm->mesg_cnt = 0; - return; - } - rm->mesg_cnt -= cnt; - vwrite_user(user, "%d board message%s deleted.\n", cnt, PLTEXT_S(cnt)); - if (user->level < GOD || user->vis) { - vwrite_room_except(rm, user, "%s wipes some messages from the board.\n", - name); - } - write_syslog(SYSLOG, 1, "%s wiped %d message%s from the board in the %s.\n", - user->name, cnt, PLTEXT_S(cnt), rm->name); -} - + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Wipe some messages off the board + */ +void +wipe_board(UR_OBJECT user) +{ + char filename[80]; + const char *name; + RM_OBJECT rm; + int cnt; + + rm = user->room; + if (word_count < 2 && ((user->level >= WIZ && !is_personal_room(rm)) + || (is_personal_room(rm) + && (is_my_room(user, rm) + || user->level >= GOD)))) { + write_user(user, "Usage: wipe all\n"); + write_user(user, " wipe <#>\n"); + write_user(user, " wipe to <#>\n"); + write_user(user, " wipe from <#> to <#>\n"); + return; + } else if (word_count < 2 && ((user->level < WIZ && !is_personal_room(rm)) + || (is_personal_room(rm) + && !is_my_room(user, rm) + && user->level < GOD))) { + write_user(user, "Usage: wipe <#>\n"); + return; + } + if (is_personal_room(rm)) { + if (!is_my_room(user, rm) && user->level < GOD && !check_board_wipe(user)) { + return; + } else if (get_wipe_parameters(user) == -1) { + return; + } + } else { + if (user->level < WIZ && !(check_board_wipe(user))) { + return; + } else if (get_wipe_parameters(user) == -1) { + return; + } + } + name = user->vis ? user->recap : invisname; + if (is_personal_room(rm)) { + sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, rm->owner); + } else { + sprintf(filename, "%s/%s.B", DATAFILES, rm->name); + } + if (!rm->mesg_cnt) { + write_user(user, "There are no messages on the room board.\n"); + return; + } + if (user->wipe_from == -1) { + remove(filename); + write_user(user, "All messages deleted.\n"); + if (user->level < GOD || user->vis) { + vwrite_room_except(rm, user, "%s~RS wipes the message board.\n", name); + } + write_syslog(SYSLOG, 1, + "%s wiped all messages from the board in the %s.\n", + user->name, rm->name); + rm->mesg_cnt = 0; + return; + } + if (user->wipe_from > rm->mesg_cnt) { + vwrite_user(user, "There %s only %d message%s on the board.\n", + PLTEXT_IS(rm->mesg_cnt), rm->mesg_cnt, + PLTEXT_S(rm->mesg_cnt)); + return; + } + cnt = wipe_messages(filename, user->wipe_from, user->wipe_to, 0); + if (cnt == rm->mesg_cnt) { + remove(filename); + vwrite_user(user, + "There %s only %d message%s on the board, all now deleted.\n", + PLTEXT_WAS(rm->mesg_cnt), rm->mesg_cnt, + PLTEXT_S(rm->mesg_cnt)); + if (user->level < GOD || user->vis) { + vwrite_room_except(rm, user, "%s wipes the message board.\n", name); + } + write_syslog(SYSLOG, 1, + "%s wiped all messages from the board in the %s.\n", + user->name, rm->name); + rm->mesg_cnt = 0; + return; + } + rm->mesg_cnt -= cnt; + vwrite_user(user, "%d board message%s deleted.\n", cnt, PLTEXT_S(cnt)); + if (user->level < GOD || user->vis) { + vwrite_room_except(rm, user, "%s wipes some messages from the board.\n", + name); + } + write_syslog(SYSLOG, 1, "%s wiped %d message%s from the board in the %s.\n", + user->name, cnt, PLTEXT_S(cnt), rm->name); +} + diff --git a/src/commands/wizemote.c b/src/commands/wizemote.c index a39fbaa..2f45aa4 100644 --- a/src/commands/wizemote.c +++ b/src/commands/wizemote.c @@ -1,60 +1,60 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Emote something to other wizes and gods. If the level isnt given it - * defaults to WIZ level. - */ -void -wizemote(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: ewiz [] \n"; - enum lvl_value lev; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot emote.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - strtoupper(word[1]); - lev = get_level(word[1]); - if (lev == NUM_LEVELS) { - lev = WIZ; - } else { - if (lev < WIZ || word_count < 3) { - write_user(user, usage); - return; - } - if (lev > user->level) { - write_user(user, - "You cannot specifically emote to users of a higher level than yourself.\n"); - return; - } - inpstr = remove_first(inpstr); - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - vwrite_level(lev, 1, RECORD, NULL, "~OL~FG>~RS [~FY%s~RS] %s~RS%s%s\n", - user_level[lev].name, user->recap, *inpstr != '\'' ? " " : "", - inpstr); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Emote something to other wizes and gods. If the level isn't given it + * defaults to WIZ level. + */ +void +wizemote(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: ewiz [] \n"; + enum lvl_value lev; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot emote.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + strtoupper(word[1]); + lev = get_level(word[1]); + if (lev == NUM_LEVELS) { + lev = WIZ; + } else { + if (lev < WIZ || word_count < 3) { + write_user(user, usage); + return; + } + if (lev > user->level) { + write_user(user, + "You cannot specifically emote to users of a higher level than yourself.\n"); + return; + } + inpstr = remove_first(inpstr); + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + vwrite_level(lev, 1, RECORD, NULL, "~OL~FG>~RS [~FY%s~RS] %s~RS%s%s\n", + user_level[lev].name, user->recap, *inpstr != '\'' ? " " : "", + inpstr); +} diff --git a/src/commands/wizlist.c b/src/commands/wizlist.c index 0f7f1f6..380cf28 100644 --- a/src/commands/wizlist.c +++ b/src/commands/wizlist.c @@ -1,132 +1,132 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Show the wizzes that are currently logged on, and get a list of names from the lists saved - */ -void -wiz_list(UR_OBJECT user) -{ - static const char *const clrs[] ={"~FC", "~FM", "~FG", "~FB", "~OL", "~FR", "~FY"}; - char text2[ARR_SIZE]; - char temp[ARR_SIZE]; - UR_OBJECT u; - UD_OBJECT entry; - int invis, count, inlist; - int linecnt, rnamecnt; - enum lvl_value lvl; - - /* show this for everyone */ - write_user(user, - "+----- ~FGWiz List~RS -------------------------------------------------------------+\n\n"); - for (lvl = GOD; lvl >= WIZ; lvl = (enum lvl_value) (lvl - 1)) { - *text2 = '\0'; - count = 0; - inlist = 0; - sprintf(text, "~OL%s%-10s~RS : ", clrs[lvl % 4], user_level[lvl].name); - for (entry = first_user_entry; entry; entry = entry->next) { - if (entry->level < WIZ) { - continue; - } - if (is_retired(entry->name)) { - continue; - } - if (entry->level == lvl) { - if (count > 3) { - strcat(text2, "\n "); - count = 0; - } - sprintf(temp, "~OL%s%-*s~RS ", clrs[rand() % 7], USER_NAME_LEN, - entry->name); - strcat(text2, temp); - ++count; - inlist = 1; - } - } - if (!count && !inlist) { - sprintf(text2, "~FR[none listed]\n~RS"); - } - strcat(text, text2); - write_user(user, text); - if (count) { - write_user(user, "\n"); - } - } - - /* show this to just the wizzes */ - if (user->level >= WIZ) { - write_user(user, - "\n+----- ~FGRetired Wiz List~RS -----------------------------------------------------+\n\n"); - for (lvl = GOD; lvl >= WIZ; lvl = (enum lvl_value) (lvl - 1)) { - *text2 = '\0'; - count = 0; - inlist = 0; - sprintf(text, "~OL%s%-10s~RS : ", clrs[lvl % 4], user_level[lvl].name); - for (entry = first_user_entry; entry; entry = entry->next) { - if (entry->level < WIZ) { - continue; - } - if (!is_retired(entry->name)) { - continue; - } - if (entry->level == lvl) { - if (count > 3) { - strcat(text2, "\n "); - count = 0; - } - sprintf(temp, "~OL%s%-*s~RS ", clrs[rand() % 7], USER_NAME_LEN, - entry->name); - strcat(text2, temp); - ++count; - inlist = 1; - } - } - if (!count && !inlist) { - sprintf(text2, "~FR[none listed]\n~RS"); - } - strcat(text, text2); - write_user(user, text); - if (count) { - write_user(user, "\n"); - } - } - } - /* show this to everyone */ - write_user(user, - "\n+----- ~FGThose currently on~RS ---------------------------------------------------+\n\n"); - invis = 0; - count = 0; - for (u = user_first; u; u = u->next) - if (u->room) { - if (u->level >= WIZ) { - if (!u->vis && (user->level < u->level && !(user->level >= ARCH))) { - ++invis; - continue; - } else { - if (u->vis) { - sprintf(text2, " %s~RS %s~RS", u->recap, u->desc); - } else { - sprintf(text2, "* %s~RS %s~RS", u->recap, u->desc); - } - linecnt = 43 + teslen(text2, 43); - rnamecnt = 15 + teslen(u->room->show_name, 15); - vwrite_user(user, "%-*.*s~RS : %-*.*s~RS : (%1.1s) %s\n", linecnt, - linecnt, text2, rnamecnt, rnamecnt, u->room->show_name, - user_level[u->level].alias, user_level[u->level].name); - } - } - ++count; - } - if (invis) { - vwrite_user(user, "Number of the wiz invisible to you : %d\n", invis); - } - if (!count) { - write_user(user, "Sorry, no wizzes are on at the moment...\n"); - } - write_user(user, "\n"); - write_user(user, - "+----------------------------------------------------------------------------+\n"); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Show the wizzes that are currently logged on, and get a list of names from the lists saved + */ +void +wiz_list(UR_OBJECT user) +{ + static const char *const clrs[] ={"~FC", "~FM", "~FG", "~FB", "~OL", "~FR", "~FY"}; + char text2[ARR_SIZE]; + char temp[ARR_SIZE]; + UR_OBJECT u; + UD_OBJECT entry; + int invis, count, inlist; + int linecnt, rnamecnt; + enum lvl_value lvl; + + /* show this for everyone */ + write_user(user, + "+----- ~FGWiz List~RS -------------------------------------------------------------+\n\n"); + for (lvl = GOD; lvl >= WIZ; lvl = (enum lvl_value) (lvl - 1)) { + *text2 = '\0'; + count = 0; + inlist = 0; + sprintf(text, "~OL%s%-10s~RS : ", clrs[lvl % 4], user_level[lvl].name); + for (entry = first_user_entry; entry; entry = entry->next) { + if (entry->level < WIZ) { + continue; + } + if (is_retired(entry->name)) { + continue; + } + if (entry->level == lvl) { + if (count > 3) { + strcat(text2, "\n "); + count = 0; + } + sprintf(temp, "~OL%s%-*s~RS ", clrs[rand() % 7], USER_NAME_LEN, + entry->name); + strcat(text2, temp); + ++count; + inlist = 1; + } + } + if (!count && !inlist) { + sprintf(text2, "~FR[none listed]\n~RS"); + } + strcat(text, text2); + write_user(user, text); + if (count) { + write_user(user, "\n"); + } + } + + /* show this to just the wizzes */ + if (user->level >= WIZ) { + write_user(user, + "\n+----- ~FGRetired Wiz List~RS -----------------------------------------------------+\n\n"); + for (lvl = GOD; lvl >= WIZ; lvl = (enum lvl_value) (lvl - 1)) { + *text2 = '\0'; + count = 0; + inlist = 0; + sprintf(text, "~OL%s%-10s~RS : ", clrs[lvl % 4], user_level[lvl].name); + for (entry = first_user_entry; entry; entry = entry->next) { + if (entry->level < WIZ) { + continue; + } + if (!is_retired(entry->name)) { + continue; + } + if (entry->level == lvl) { + if (count > 3) { + strcat(text2, "\n "); + count = 0; + } + sprintf(temp, "~OL%s%-*s~RS ", clrs[rand() % 7], USER_NAME_LEN, + entry->name); + strcat(text2, temp); + ++count; + inlist = 1; + } + } + if (!count && !inlist) { + sprintf(text2, "~FR[none listed]\n~RS"); + } + strcat(text, text2); + write_user(user, text); + if (count) { + write_user(user, "\n"); + } + } + } + /* show this to everyone */ + write_user(user, + "\n+----- ~FGThose currently on~RS ---------------------------------------------------+\n\n"); + invis = 0; + count = 0; + for (u = user_first; u; u = u->next) + if (u->room) { + if (u->level >= WIZ) { + if (!u->vis && (user->level < u->level && !(user->level >= ARCH))) { + ++invis; + continue; + } else { + if (u->vis) { + sprintf(text2, " %s~RS %s~RS", u->recap, u->desc); + } else { + sprintf(text2, "* %s~RS %s~RS", u->recap, u->desc); + } + linecnt = 43 + teslen(text2, 43); + rnamecnt = 15 + teslen(u->room->show_name, 15); + vwrite_user(user, "%-*.*s~RS : %-*.*s~RS : (%1.1s) %s\n", linecnt, + linecnt, text2, rnamecnt, rnamecnt, u->room->show_name, + user_level[u->level].alias, user_level[u->level].name); + } + } + ++count; + } + if (invis) { + vwrite_user(user, "Number of the wiz invisible to you : %d\n", invis); + } + if (!count) { + write_user(user, "Sorry, no wizzes are on at the moment...\n"); + } + write_user(user, "\n"); + write_user(user, + "+----------------------------------------------------------------------------+\n"); +} diff --git a/src/commands/wizshout.c b/src/commands/wizshout.c index 552e52a..fba6046 100644 --- a/src/commands/wizshout.c +++ b/src/commands/wizshout.c @@ -1,70 +1,70 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Shout something to other wizes and gods. If the level isnt given it - * defaults to WIZ level. - */ -void -wizshout(UR_OBJECT user, char *inpstr) -{ - static const char usage[] = "Usage: twiz [] \n"; - const char *type; - enum lvl_value lev; - - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot speak.\n"); - return; - } - if (word_count < 2) { - write_user(user, usage); - return; - } - strtoupper(word[1]); - lev = get_level(word[1]); - if (lev == NUM_LEVELS) { - lev = WIZ; - } else { - if (lev < WIZ || word_count < 3) { - write_user(user, usage); - return; - } - if (lev > user->level) { - write_user(user, - "You cannot specifically shout to users of a higher level than yourself.\n"); - return; - } - inpstr = remove_first(inpstr); - } - /* Even wizzes cannot escapde the swear ban! MWHAHahaha.... ahem. */ - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - inpstr = censor_swear_words(inpstr); - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - type = smiley_type(inpstr); - if (!type) { - type = "say"; - } - vwrite_level(lev, 1, RECORD, user, - "~OL~FG>~RS [~FY%s~RS] %s~RS ~FY%ss~RS: %s\n", - user_level[lev].name, user->recap, type, inpstr); - sprintf(text, "~OL~FG>~RS [~FY%s~RS] You ~FY%s~RS: %s\n", - user_level[lev].name, type, inpstr); - record_tell(user, user, text); - write_user(user, text); -} + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Shout something to other wizes and gods. If the level isn't given it + * defaults to WIZ level. + */ +void +wizshout(UR_OBJECT user, char *inpstr) +{ + static const char usage[] = "Usage: twiz [] \n"; + const char *type; + enum lvl_value lev; + + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot speak.\n"); + return; + } + if (word_count < 2) { + write_user(user, usage); + return; + } + strtoupper(word[1]); + lev = get_level(word[1]); + if (lev == NUM_LEVELS) { + lev = WIZ; + } else { + if (lev < WIZ || word_count < 3) { + write_user(user, usage); + return; + } + if (lev > user->level) { + write_user(user, + "You cannot specifically shout to users of a higher level than yourself.\n"); + return; + } + inpstr = remove_first(inpstr); + } + /* Even wizzes cannot escape the swear ban! MWHAHahaha.... ahem. */ + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + inpstr = censor_swear_words(inpstr); + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + type = smiley_type(inpstr); + if (!type) { + type = "say"; + } + vwrite_level(lev, 1, RECORD, user, + "~OL~FG>~RS [~FY%s~RS] %s~RS ~FY%ss~RS: %s\n", + user_level[lev].name, user->recap, type, inpstr); + sprintf(text, "~OL~FG>~RS [~FY%s~RS] You ~FY%s~RS: %s\n", + user_level[lev].name, type, inpstr); + record_tell(user, user, text); + write_user(user, text); +} diff --git a/src/commands/write_board.c b/src/commands/write_board.c index 89bddd8..0e0fdd3 100644 --- a/src/commands/write_board.c +++ b/src/commands/write_board.c @@ -1,109 +1,109 @@ - -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * Write on the message board - */ -void -write_board(UR_OBJECT user, char *inpstr) -{ - char filename[80]; /* TODO: the max filename size should be calculated */ - const char *name; - char *c; - FILE *fp; - int cnt; - - if (inpstr) { - /* FIXME: Use sentinel other JAILED */ - if (user->muzzled != JAILED) { - write_user(user, "You are muzzled, you cannot write on the board.\n"); - return; - } - if (word_count < 2) { -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - /* Editor will not work over netlink because all the prompts will go wrong */ - write_user(user, - "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".write \" method instead.\n"); - return; - } -#endif - write_user(user, "\n~BB*** Writing board message ***\n\n"); - user->misc_op = 3; - editor(user, NULL); - return; - } - strcat(inpstr, "\n"); /* XXX: risky but hopefully it will be ok */ - } else { - inpstr = user->malloc_start; - } - switch (amsys->ban_swearing) { - case SBMAX: - if (contains_swearing(inpstr)) { - write_user(user, noswearing); - return; - } - break; - case SBMIN: - if (!is_personal_room(user->room)) { - inpstr = censor_swear_words(inpstr); - } - break; - case SBOFF: - default: - /* do nothing as ban_swearing is off */ - break; - } - if (is_personal_room(user->room)) { - sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, user->room->owner); - } else { - sprintf(filename, "%s/%s.B", DATAFILES, user->room->name); - } - fp = fopen(filename, "a"); - if (!fp) { - vwrite_user(user, "%s: cannot write to file.\n", syserror); - write_syslog(SYSLOG | ERRLOG, 0, - "ERROR: Cannot open file %s to append in write_board().\n", - filename); - return; - } - name = user->vis ? user->recap : invisname; - /* - The posting time (PT) is the time its written in machine readable form, this - makes it easy for this program to check the age of each message and delete - as appropriate in check_messages() - */ -#ifdef NETLINKS - if (user->type == REMOTE_TYPE) { - sprintf(text, "PT: %d\r~OLFrom: %s@%s %s\n", (int) (time(0)), name, - user->netlink->service, long_date(0)); - } else -#endif - { - sprintf(text, "PT: %d\r~OLFrom: %s %s\n", (int) (time(0)), name, - long_date(0)); - } - fputs(text, fp); - cnt = 0; - for (c = inpstr; *c; ++c) { - putc(*c, fp); - if (*c == '\n') { - cnt = 0; - } else { - ++cnt; - } - if (cnt == 80) { - putc('\n', fp); - cnt = 0; - } - } - putc('\n', fp); - fclose(fp); - write_user(user, "You write the message on the board.\n"); - vwrite_room_except(user->room, user, "%s writes a message on the board.\n", - name); - ++user->room->mesg_cnt; + +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * Write on the message board + */ +void +write_board(UR_OBJECT user, char *inpstr) +{ + char filename[80]; /* TODO: the max filename size should be calculated */ + const char *name; + char *c; + FILE *fp; + int cnt; + + if (inpstr) { + /* FIXME: Use sentinel other JAILED */ + if (user->muzzled != JAILED) { + write_user(user, "You are muzzled, you cannot write on the board.\n"); + return; + } + if (word_count < 2) { +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + /* Editor will not work over netlink because all the prompts will go wrong */ + write_user(user, + "Sorry, due to software limitations remote users cannot use the line editor.\nUse the \".write \" method instead.\n"); + return; + } +#endif + write_user(user, "\n~BB*** Writing board message ***\n\n"); + user->misc_op = 3; + editor(user, NULL); + return; + } + strcat(inpstr, "\n"); /* XXX: risky but hopefully it will be ok */ + } else { + inpstr = user->malloc_start; + } + switch (amsys->ban_swearing) { + case SBMAX: + if (contains_swearing(inpstr)) { + write_user(user, noswearing); + return; + } + break; + case SBMIN: + if (!is_personal_room(user->room)) { + inpstr = censor_swear_words(inpstr); + } + break; + case SBOFF: + default: + /* do nothing as ban_swearing is off */ + break; + } + if (is_personal_room(user->room)) { + sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, user->room->owner); + } else { + sprintf(filename, "%s/%s.B", DATAFILES, user->room->name); + } + fp = fopen(filename, "a"); + if (!fp) { + vwrite_user(user, "%s: cannot write to file.\n", syserror); + write_syslog(SYSLOG | ERRLOG, 0, + "ERROR: Cannot open file %s to append in write_board().\n", + filename); + return; + } + name = user->vis ? user->recap : invisname; + /* + The posting time (PT) is the time its written in machine readable form, this + makes it easy for this program to check the age of each message and delete + as appropriate in check_messages() + */ +#ifdef NETLINKS + if (user->type == REMOTE_TYPE) { + sprintf(text, "PT: %d\r~OLFrom: %s@%s %s\n", (int) (time(0)), name, + user->netlink->service, long_date(0)); + } else +#endif + { + sprintf(text, "PT: %d\r~OLFrom: %s %s\n", (int) (time(0)), name, + long_date(0)); + } + fputs(text, fp); + cnt = 0; + for (c = inpstr; *c; ++c) { + putc(*c, fp); + if (*c == '\n') { + cnt = 0; + } else { + ++cnt; + } + if (cnt == 80) { + putc('\n', fp); + cnt = 0; + } + } + putc('\n', fp); + fclose(fp); + write_user(user, "You write the message on the board.\n"); + vwrite_room_except(user->room, user, "%s writes a message on the board.\n", + name); + ++user->room->mesg_cnt; } \ No newline at end of file diff --git a/src/commands/xcom.c b/src/commands/xcom.c index 947c3cb..56551f2 100644 --- a/src/commands/xcom.c +++ b/src/commands/xcom.c @@ -1,121 +1,121 @@ -#include "defines.h" -#include "globals.h" -#include "commands.h" -#include "prototypes.h" - -/* - * stop a user from using a certain command - */ -void -user_xcom(UR_OBJECT user) -{ - CMD_OBJECT cmd; - UR_OBJECT u; - size_t i, x; - - if (word_count < 2) { - write_user(user, "Usage: xcom []\n"); - return; - } - u = get_user_name(user, word[1]); - if (!u) { - write_user(user, notloggedon); - return; - } - if (u == user) { - write_user(user, "You cannot ban any commands of your own.\n"); - return; - } - /* if no command is given, then just view banned commands */ - if (word_count < 3) { - write_user(user, - "+----------------------------------------------------------------------------+\n"); - vwrite_user(user, "~OL~FCBanned commands for user \"%s~RS\"\n", u->recap); - write_user(user, - "+----------------------------------------------------------------------------+\n"); - x = 0; - for (i = 0; i < MAX_XCOMS; ++i) { - if (u->xcoms[i] == -1) { - continue; - } - for (cmd = first_command; cmd; cmd = cmd->next) { - if (cmd->id == u->xcoms[i]) { - break; - } - } - if (!cmd) { - /* XXX: Maybe emit some sort of error? */ - continue; - } - vwrite_user(user, "~OL%s~RS (level %d)\n", cmd->name, cmd->level); - ++x; - } - if (!x) { - write_user(user, "User has no banned commands.\n"); - } - write_user(user, - "+----------------------------------------------------------------------------+\n\n"); - return; - } - if (u->level >= user->level) { - write_user(user, - "You cannot ban the commands of a user with the same or higher level as yourself.\n"); - return; - } - /* FIXME: command search order is different than command_table/exec_com() - * because it uses the alpha sorted command list instead! */ - i = strlen(word[2]); - for (cmd = first_command; cmd; cmd = cmd->next) { - if (!strncmp(word[2], cmd->name, i)) { - break; - } - } - if (!cmd) { - write_user(user, "That command does not exist.\n"); - return; - } - if (u->level < cmd->level) { - vwrite_user(user, - "%s is not of a high enough level to use that command anyway.\n", - u->name); - return; - } - /* check to see is the user has previously been given the command */ - if (has_gcom(u, cmd->id)) { - write_user(user, - "You cannot ban a command that a user has been specifically given.\n"); - return; - } - if (has_xcom(u, cmd->id)) { - /* user already has the command banned, so unban it */ - if (!set_xgcom(user, u, cmd->id, 1, 0)) { - /* XXX: Maybe emit some sort of error? */ - return; - } - vwrite_user(user, "You have unbanned the \"%s\" command for %s\n", - word[2], u->name); - vwrite_user(u, - "The command \"%s\" has been unbanned and you can use it again.\n", - word[2]); - sprintf(text, "%s ~FGUNXCOM~RS'd the command \"%s\"\n", user->name, - word[2]); - add_history(u->name, 1, "%s", text); - write_syslog(SYSLOG, 1, "%s UNXCOM'd the command \"%s\" for %s\n", - user->name, word[2], u->name); - } else { - /* user does not have the command banned, so ban it */ - if (!set_xgcom(user, u, cmd->id, 1, 1)) { - /* XXX: Maybe emit some sort of error? */ - return; - } - vwrite_user(user, "You have banned the \"%s\" command for %s\n", word[2], - u->name); - vwrite_user(u, "You have been banned from using the command \"%s\".\n", - word[2]); - sprintf(text, "%s ~FRXCOM~RS'd the command \"%s\"\n", user->name, - word[2]); - add_history(u->name, 1, "%s", text); - write_syslog(SYSLOG, 1, "%s XCOM'd the command \"%s\" for %s\n", - user->name, word[2], u->name); - } +#include "defines.h" +#include "globals.h" +#include "commands.h" +#include "prototypes.h" + +/* + * stop a user from using a certain command + */ +void +user_xcom(UR_OBJECT user) +{ + CMD_OBJECT cmd; + UR_OBJECT u; + size_t i, x; + + if (word_count < 2) { + write_user(user, "Usage: xcom []\n"); + return; + } + u = get_user_name(user, word[1]); + if (!u) { + write_user(user, notloggedon); + return; + } + if (u == user) { + write_user(user, "You cannot ban any commands of your own.\n"); + return; + } + /* if no command is given, then just view banned commands */ + if (word_count < 3) { + write_user(user, + "+----------------------------------------------------------------------------+\n"); + vwrite_user(user, "~OL~FCBanned commands for user \"%s~RS\"\n", u->recap); + write_user(user, + "+----------------------------------------------------------------------------+\n"); + x = 0; + for (i = 0; i < MAX_XCOMS; ++i) { + if (u->xcoms[i] == -1) { + continue; + } + for (cmd = first_command; cmd; cmd = cmd->next) { + if (cmd->id == u->xcoms[i]) { + break; + } + } + if (!cmd) { + /* XXX: Maybe emit some sort of error? */ + continue; + } + vwrite_user(user, "~OL%s~RS (level %d)\n", cmd->name, cmd->level); + ++x; + } + if (!x) { + write_user(user, "User has no banned commands.\n"); + } + write_user(user, + "+----------------------------------------------------------------------------+\n\n"); + return; + } + if (u->level >= user->level) { + write_user(user, + "You cannot ban the commands of a user with the same or higher level as yourself.\n"); + return; + } + /* FIXME: command search order is different than command_table/exec_com() + * because it uses the alpha sorted command list instead! */ + i = strlen(word[2]); + for (cmd = first_command; cmd; cmd = cmd->next) { + if (!strncmp(word[2], cmd->name, i)) { + break; + } + } + if (!cmd) { + write_user(user, "That command does not exist.\n"); + return; + } + if (u->level < cmd->level) { + vwrite_user(user, + "%s is not of a high enough level to use that command anyway.\n", + u->name); + return; + } + /* check to see is the user has previously been given the command */ + if (has_gcom(u, cmd->id)) { + write_user(user, + "You cannot ban a command that a user has been specifically given.\n"); + return; + } + if (has_xcom(u, cmd->id)) { + /* user already has the command banned, so unban it */ + if (!set_xgcom(user, u, cmd->id, 1, 0)) { + /* XXX: Maybe emit some sort of error? */ + return; + } + vwrite_user(user, "You have unbanned the \"%s\" command for %s\n", + word[2], u->name); + vwrite_user(u, + "The command \"%s\" has been unbanned and you can use it again.\n", + word[2]); + sprintf(text, "%s ~FGUNXCOM~RS'd the command \"%s\"\n", user->name, + word[2]); + add_history(u->name, 1, "%s", text); + write_syslog(SYSLOG, 1, "%s UNXCOM'd the command \"%s\" for %s\n", + user->name, word[2], u->name); + } else { + /* user does not have the command banned, so ban it */ + if (!set_xgcom(user, u, cmd->id, 1, 1)) { + /* XXX: Maybe emit some sort of error? */ + return; + } + vwrite_user(user, "You have banned the \"%s\" command for %s\n", word[2], + u->name); + vwrite_user(u, "You have been banned from using the command \"%s\".\n", + word[2]); + sprintf(text, "%s ~FRXCOM~RS'd the command \"%s\"\n", user->name, + word[2]); + add_history(u->name, 1, "%s", text); + write_syslog(SYSLOG, 1, "%s XCOM'd the command \"%s\" for %s\n", + user->name, word[2], u->name); + } } \ No newline at end of file diff --git a/src/games.c b/src/games.c index d446b87..c4315c1 100644 --- a/src/games.c +++ b/src/games.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ diff --git a/src/includes/commands.h b/src/includes/commands.h index ab57899..29eed0c 100644 --- a/src/includes/commands.h +++ b/src/includes/commands.h @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ diff --git a/src/includes/defines.h b/src/includes/defines.h index 3f3fa25..6421a55 100644 --- a/src/includes/defines.h +++ b/src/includes/defines.h @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -49,19 +48,20 @@ #define TALKER_NAME "Your Talker's Name Here" /* general directories */ -#define DATAFILES "datafiles" -#define HELPFILES "helpfiles" -#define MAILSPOOL "mailspool" -#define MISCFILES "miscfiles" -#define PICTFILES "pictfiles" -#define MOTDFILES "motds" -#define DUMPFILES "dumpfiles" -#define TEXTFILES "textfiles" -#define ADMINFILES "adminfiles" -#define LOGFILES "logfiles" +#define BASE_STORAGE_DIR "files" +#define ADMINFILES BASE_STORAGE_DIR "/adminfiles" +#define DATAFILES BASE_STORAGE_DIR "/datafiles" +#define DUMPFILES BASE_STORAGE_DIR "/dumpfiles" +#define HELPFILES BASE_STORAGE_DIR "/helpfiles" +#define LOGFILES BASE_STORAGE_DIR "/logfiles" +#define MAILSPOOL BASE_STORAGE_DIR "/mailspool" +#define MISCFILES BASE_STORAGE_DIR "/miscfiles" +#define MOTDFILES BASE_STORAGE_DIR "/motds" +#define PICTFILES BASE_STORAGE_DIR "/pictfiles" +#define TEXTFILES BASE_STORAGE_DIR "/textfiles" /* user directories */ -#define USERFILES "userfiles" +#define USERFILES BASE_STORAGE_DIR "/userfiles" #define USERMAILS "mail" #define USERPROFILES "profiles" #define USERHISTORYS "historys" @@ -71,13 +71,13 @@ #define USERREMINDERS "reminders" #define USERFLAGGED "flagged" -/* seemless reboot */ -#define REBOOTING_DIR "reboot" -#define USER_LIST_FILE "reboot/_ulist" -#define TALKER_SYSINFO_FILE "reboot/_sysinfo" -#define CHILDS_PID_FILE "reboot/_child_pid" -#define ROOM_LIST_FILE "reboot/_rlist" -#define LAST_USERS_FILE "reboot/_last" +/* seamless reboot */ +#define REBOOTING_DIR BASE_STORAGE_DIR "/reboot" +#define USER_LIST_FILE REBOOTING_DIR "/_ulist" +#define TALKER_SYSINFO_FILE REBOOTING_DIR "/_sysinfo" +#define CHILDS_PID_FILE REBOOTING_DIR "/_child_pid" +#define ROOM_LIST_FILE REBOOTING_DIR "/_rlist" +#define LAST_USERS_FILE REBOOTING_DIR "/_last" /* files */ #define CONFIGFILE "config" @@ -123,6 +123,9 @@ #define UFILE_WORD_LEN 255 #define RECORD 1 #define NORECORD 0 +#define ALIGN_LEFT 0 +#define ALIGN_CENTRE 1 +#define ALIGN_RIGHT 2 /* netlink defines */ @@ -174,7 +177,7 @@ /* * some macros that are used in the code - * these are for grammer + * these are for grammar */ #define PLTEXT_S(n) ((1==(n))?"":"s") #define PLTEXT_ES(n) ((1==(n))?"":"es") @@ -183,6 +186,8 @@ #define SIZEOF(table) ((sizeof (table))/(sizeof *(table))) /* these are for bit manipulation */ #define BIT(pos) (1L<<(pos)) +/* utils */ +#define STRLEN(s) (sizeof(s) / sizeof(s[0]) - 1) /* money code */ #define DEFAULT_MONEY 1000 diff --git a/src/includes/globals.h b/src/includes/globals.h index 2a83252..316986f 100644 --- a/src/includes/globals.h +++ b/src/includes/globals.h @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -241,7 +240,7 @@ struct last_login_struct { }; /* - * room informaytion structure + * room information structure */ struct room_struct { char name[ROOM_NAME_LEN + 1]; diff --git a/src/includes/netlinks.h b/src/includes/netlinks.h index 01c39a4..6d9a552 100644 --- a/src/includes/netlinks.h +++ b/src/includes/netlinks.h @@ -1,3 +1,15 @@ +/**************************************************************************** + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 + + talker@amnuts.net - https://amnuts.net/ + + based on + + NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 + + *************************************************************************** + #ifndef AMNUTS_NETLINKS_H #define AMNUTS_NETLINKS_H diff --git a/src/includes/prototypes.h b/src/includes/prototypes.h index cd20d4c..59c4005 100644 --- a/src/includes/prototypes.h +++ b/src/includes/prototypes.h @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ diff --git a/src/includes/rooms.h b/src/includes/rooms.h index cacf676..09ea1ac 100644 --- a/src/includes/rooms.h +++ b/src/includes/rooms.h @@ -1,3 +1,15 @@ +/**************************************************************************** + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 + + talker@amnuts.net - https://amnuts.net/ + + based on + + NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 + + *************************************************************************** + #ifndef AMNUTS_ROOMS_H #define AMNUTS_ROOMS_H diff --git a/src/includes/spodlist.h b/src/includes/spodlist.h index e990405..95ebec2 100644 --- a/src/includes/spodlist.h +++ b/src/includes/spodlist.h @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 diff --git a/src/messages.c b/src/messages.c index 288d3e0..9156981 100644 --- a/src/messages.c +++ b/src/messages.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -48,7 +47,7 @@ count_suggestions(void) } /* - * work out how many motds are stored - if an motd file is deleted after + * work out how many motds are stored - if a motd file is deleted after * this count has been made then you need to recount them with the recount * command. If you fail to do this and something buggers up because the count * is wrong then it is your own fault. @@ -91,7 +90,7 @@ count_motds(int forcecnt) } /* - * return a random number for an motd file - if 0 then return 1 + * return a random number for a motd file - if 0 then return 1 */ int get_motd_num(int motd) @@ -671,7 +670,7 @@ send_forward_email(char *send_to, char *mail_file, char *subject) #else // We must not run this on background, otherwise we never know if the mailer // will actually have time to read the mail_file before we remove it! - // Also: the subject must come before the recepient (otherwise recent mail + // Also: the subject must come before the recipient (otherwise recent mail // versions will refuse to send the mail). sprintf(text, "mail -s '%s' '%s' < %s", subject, send_to, mail_file); system(text); @@ -864,7 +863,7 @@ check_board_wipe(UR_OBJECT user) } fclose(fp); s2 = colour_com_strip(w2); - /* lower case the name incase of recapping */ + /* lower case the name i case of recapping */ strtolower(s2); *s2 = toupper(*s2); if (strcmp(s2, user->name)) { @@ -940,7 +939,7 @@ board_from(UR_OBJECT user) int get_wipe_parameters(UR_OBJECT user) { - /* get delete paramters */ + /* get delete parameters */ strtolower(word[1]); if (!strcmp(word[1], "all")) { user->wipe_from = -1; @@ -976,7 +975,7 @@ get_wipe_parameters(UR_OBJECT user) * suggestions, etc. It works on the premise that every message is * seperated by a newline on a line by itself. And as all messages have * this form--no probs :) Just do not go screwing with how the messages - * are stored and you will be ok :P + * are stored, and you will be ok :P * * from = message to start deleting at * to = message to stop deleting at (both inclusive) diff --git a/src/netlinks.c b/src/netlinks.c index 849d35a..4fd3bd9 100644 --- a/src/netlinks.c +++ b/src/netlinks.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -15,6 +14,9 @@ #include "globals.h" #include "commands.h" #include "prototypes.h" +#ifndef __SDS_H +#include "./vendors/sds/sds.h" +#endif #ifdef NETLINKS /**************************************************************************/ @@ -1469,6 +1471,11 @@ release_nl(UR_OBJECT user) int action_nl(UR_OBJECT user, const char *command, const char *inpstr) { + sds text; + + if (!user || user->type != REMOTE_TYPE) { + return 0; + } if (user->room) { return 0; } @@ -1476,12 +1483,12 @@ action_nl(UR_OBJECT user, const char *command, const char *inpstr) command = "NL"; } if (!inpstr || !*inpstr) { - sprintf(text, "%s %s %s\n", netcom[NLC_ACTION], user->name, command); + text = sdscatfmt(sdsempty(), "%s %s %s\n", netcom[NLC_ACTION], user->name, command); } else { - sprintf(text, "%s %s %s %s\n", netcom[NLC_ACTION], user->name, command, - inpstr); + text = sdscatfmt(sdsempty(), "%s %s %s %s\n", netcom[NLC_ACTION], user->name, command, inpstr); } write_sock(user->netlink->socket, text); + sdsfree(text); return 1; } diff --git a/src/objects.c b/src/objects.c index 18abf49..0093549 100644 --- a/src/objects.c +++ b/src/objects.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -829,7 +828,7 @@ destruct_flagged_user_entry(UR_OBJECT user, FU_OBJECT fu) } /* - * desctruct all nodes in flagged user linked list + * destruct all nodes in flagged user linked list */ void destruct_all_flagged_users(UR_OBJECT user) @@ -919,7 +918,7 @@ get_user(const char *name) } /* - * Get user from abreviated name + * Get user from abbreviated name */ UR_OBJECT get_user_name(UR_OBJECT user, const char *name) @@ -1199,7 +1198,7 @@ destruct_review_buffer_entry(UR_OBJECT user, RB_OBJECT rb) } /* - * desctruct all nodes in review buffer linked list + * destruct all nodes in review buffer linked list */ void destruct_all_review_buffer(UR_OBJECT user) @@ -1211,7 +1210,7 @@ destruct_all_review_buffer(UR_OBJECT user) } /* - * desctruct all nodes of a certain type in review buffer linked list + * destruct all nodes of a certain type in review buffer linked list */ void destruct_review_buffer_type(UR_OBJECT user, unsigned flags, int first) diff --git a/src/pager.c b/src/pager.c index f803cb4..70f9a30 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ diff --git a/src/reboot.c b/src/reboot.c index 8cc7d01..b73fa15 100644 --- a/src/reboot.c +++ b/src/reboot.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -453,7 +452,7 @@ do_sreboot(UR_OBJECT user) /* * here is where to add for any other syncing that needs to be done - * when your talker shutsdown... notes, etc + * when your talker shuts down... notes, etc */ close_fds(); @@ -469,11 +468,11 @@ do_sreboot(UR_OBJECT user) break; case 0: /* - * XXX: ISO C and historical compatibility introduce anomolies for + * XXX: ISO C and historical compatibility introduce anomalies for * all exec functions. * * execv style will strip const from char specifiers because - * historically there was no const and const cannot be tranparently + * historically there was no const and const cannot be transparently * added to indirect types. * * execl style need a char null pointer because they are variadic @@ -484,7 +483,7 @@ do_sreboot(UR_OBJECT user) /*** run the background process..and die! ***/ write_syslog(SYSLOG, 0, "BOOT: Exiting child process.\n"); break; - default: /* parents thread ... put the childs pid to file, for reboot matching */ + default: /* parents thread ... put the child's pid to file, for reboot matching */ f = fopen(CHILDS_PID_FILE, "w"); if (!f) { write_syslog(SYSLOG | ERRLOG, 0, @@ -639,7 +638,7 @@ void retrieve_users(void) { char name[USER_NAME_LEN], rmname[ROOM_NAME_LEN], - filename[USER_NAME_LEN + 15], line[ARR_SIZE * 3 + 1], *s; + filename[USER_NAME_LEN + STRLEN(REBOOTING_DIR) + 15], line[ARR_SIZE * 3 + 1], *s; struct user_struct spanky; FILE *f, *pf; UR_OBJECT u; diff --git a/src/rooms.c b/src/rooms.c index 2f45488..b910e4e 100644 --- a/src/rooms.c +++ b/src/rooms.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ diff --git a/src/speech.c b/src/speech.c index 774ebf9..aa7a9ca 100644 --- a/src/speech.c +++ b/src/speech.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ diff --git a/src/spodlist.c b/src/spodlist.c index 79ff0be..b72ae68 100644 --- a/src/spodlist.c +++ b/src/spodlist.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -224,7 +223,7 @@ show_spodlist(UR_OBJECT user) write_user(user, "+----------------------------------------------------------------------------+\n"); write_user(user, - align_string(0, 78, 1, "|", + align_string(ALIGN_LEFT, 78, 1, "|", " Positions %d to %d (out of %d users) ", start_pos, end_pos, listed)); write_user(user, diff --git a/src/strings.c b/src/strings.c index 14b32b2..b55bfd3 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1,11 +1,10 @@ /**************************************************************************** - Amnuts version 2.3.0 - Copyright (C) Andrew Collington, 2003 - Last update: 2003-08-04 + Amnuts - Copyright (C) Andrew Collington, 1996-2023 + Last update: Sometime in 2023 - amnuts@talker.com - http://amnuts.talker.com/ + talker@amnuts.net - https://amnuts.net/ - based on + based on NUTS version 3.3.3 (Triple Three :) - Copyright (C) Neil Robertson 1996 ***************************************************************************/ @@ -388,8 +387,8 @@ is_number(const char *str) /* * Performs the same as strstr, in that it returns a pointer to the - * first occurence of pat in str--except that this is performed case - * insensitive + * first occurrence of pat in str--except that this is performed + * case-insensitive */ char * istrstr(char *str, const char *pat) @@ -425,7 +424,7 @@ istrstr(char *str, const char *pat) } /* - * Take the string "inpstr" and replace any occurence of "old_str" with + * Take the string "inpstr" and replace any occurrence of "old_str" with * the string "new_str" */ char * @@ -531,7 +530,7 @@ long_date(int which) /* * takes string str and determines what smiley type it should have. The type is then - * stored in "type". The smiley type is determind by the last 2 characters in str. + * stored in "type". The smiley type is determined by the last 2 characters in str. */ const char * smiley_type(const char *str) @@ -582,17 +581,17 @@ smiley_type(const char *str) * mark=0, no markers on the left and right sides. mark=1, markers in place */ char * -align_string(int pos, int cstrlen, int mark, const char *marker, - const char *str, ...) +align_string(int pos, int cstrlen, int mark, const char *marker, const char *str, ...) { va_list args; char text2[ARR_SIZE * 2]; + char vtext[ARR_SIZE]; int len = 0, spc = 0, odd = 0; /* first build up the string */ *vtext = '\0'; va_start(args, str); - vsprintf(vtext, str, args); + vsnprintf(vtext, sizeof(vtext), str, args); va_end(args); /* get size */ len = strlen(vtext) - teslen(vtext, 0); @@ -600,29 +599,25 @@ align_string(int pos, int cstrlen, int mark, const char *marker, odd = ((spc + spc + len) - (cstrlen)); /* if greater than size given then do not do anything except return */ if (len > cstrlen) { - return vtext; + return strdup(vtext); } switch (pos) { - case 0: - /* left align */ - sprintf(text2, "%s%*.*s", vtext, (spc * 2) - odd, (spc * 2) - odd, ""); - break; - case 1: - /* centre align */ - sprintf(text2, "%*.*s%s%*.*s", spc, spc, "", vtext, spc - odd, spc - odd, - ""); - break; - case 2: - /* right align */ - sprintf(text2, "%*.*s%s", (spc * 2) - odd, (spc * 2) - odd, "", vtext); - break; + case ALIGN_LEFT: + snprintf(text2, sizeof(text2), "%s%*.*s", vtext, (spc * 2) - odd, (spc * 2) - odd, ""); + break; + case ALIGN_CENTRE: + snprintf(text2, sizeof(text2), "%*.*s%s%*.*s", spc, spc, "", vtext, spc - odd, spc - odd, ""); + break; + case ALIGN_RIGHT: + snprintf(text2, sizeof(text2), "%*.*s%s", (spc * 2) - odd, (spc * 2) - odd, "", vtext); + break; } strcpy(vtext, text2); /* if marked, then add spaces on the other side too */ if (mark) { /* if markers cannot be placed without over-writing text then return */ - if (len > (cstrlen - 1)) { - return vtext; + if (len > (cstrlen - 2)) { + return strdup(vtext); } /* if they forgot to pass a marker, use a default one */ if (!marker) { @@ -630,16 +625,18 @@ align_string(int pos, int cstrlen, int mark, const char *marker, } *vtext = *marker; int index = 0; - if (strlen(vtext) > 0) index = strlen(vtext) - 1; + if (strlen(vtext) > 0) { + index = strlen(vtext) - 1; + } vtext[index] = *marker; } strcat(vtext, "\n"); - return vtext; + return strdup(vtext); } /* * Check to see if the pattern "pat" appears in the string "str". - * Uses recursion to acheive this + * Uses recursion to achieve this */ int pattern_match(char *str, char *pat) diff --git a/src/vendors/sds/sds.c b/src/vendors/sds/sds.c index 39ad595..3943189 100644 --- a/src/vendors/sds/sds.c +++ b/src/vendors/sds/sds.c @@ -78,7 +78,7 @@ static inline char sdsReqType(size_t string_size) { * If NULL is used for 'init' the string is initialized with zero bytes. * If SDS_NOINIT is used, the buffer is left uninitialized; * - * The string is always null-termined (all the sds strings are, always) so + * The string is always null-terminated (all the sds strings are, always) so * even if you create an sds string with: * * mystring = sdsnewlen("abc",3); @@ -97,11 +97,11 @@ sds sdsnewlen(const void *init, size_t initlen) { unsigned char *fp; /* flags pointer. */ sh = s_malloc(hdrlen+initlen+1); + if (sh == NULL) return NULL; if (init==SDS_NOINIT) init = NULL; else if (!init) memset(sh, 0, hdrlen+initlen+1); - if (sh == NULL) return NULL; s = (char*)sh+hdrlen; fp = ((unsigned char*)s)-1; switch(type) { @@ -204,7 +204,7 @@ void sdsclear(sds s) { sds sdsMakeRoomFor(sds s, size_t addlen) { void *sh, *newsh; size_t avail = sdsavail(s); - size_t len, newlen; + size_t len, newlen, reqlen; char type, oldtype = s[-1] & SDS_TYPE_MASK; int hdrlen; @@ -213,7 +213,7 @@ sds sdsMakeRoomFor(sds s, size_t addlen) { len = sdslen(s); sh = (char*)s-sdsHdrSize(oldtype); - newlen = (len+addlen); + reqlen = newlen = (len+addlen); if (newlen < SDS_MAX_PREALLOC) newlen *= 2; else @@ -227,6 +227,7 @@ sds sdsMakeRoomFor(sds s, size_t addlen) { if (type == SDS_TYPE_5) type = SDS_TYPE_8; hdrlen = sdsHdrSize(type); + assert(hdrlen + newlen + 1 > reqlen); /* Catch size_t overflow */ if (oldtype==type) { newsh = s_realloc(sh, hdrlen+newlen+1); if (newsh == NULL) return NULL; @@ -257,8 +258,12 @@ sds sdsRemoveFreeSpace(sds s) { char type, oldtype = s[-1] & SDS_TYPE_MASK; int hdrlen, oldhdrlen = sdsHdrSize(oldtype); size_t len = sdslen(s); + size_t avail = sdsavail(s); sh = (char*)s-oldhdrlen; + /* Return ASAP if there is no space left. */ + if (avail == 0) return s; + /* Check what would be the minimum SDS header that is just good enough to * fit this string. */ type = sdsReqType(len); @@ -430,7 +435,7 @@ sds sdscpylen(sds s, const char *t, size_t len) { return s; } -/* Like sdscpylen() but 't' must be a null-termined string so that the length +/* Like sdscpylen() but 't' must be a null-terminated string so that the length * of the string is obtained with strlen(). */ sds sdscpy(sds s, const char *t) { return sdscpylen(s, t, strlen(t)); @@ -450,7 +455,18 @@ int sdsll2str(char *s, long long value) { /* Generate the string representation, this method produces * an reversed string. */ - v = (value < 0) ? -value : value; + if (value < 0) { + /* Since v is unsigned, if value==LLONG_MIN then + * -LLONG_MIN will overflow. */ + if (value != LLONG_MIN) { + v = -value; + } else { + v = ((unsigned long long)LLONG_MAX) + 1; + } + } else { + v = value; + } + p = s; do { *p++ = '0'+(v%10); @@ -519,6 +535,7 @@ sds sdscatvprintf(sds s, const char *fmt, va_list ap) { va_list cpy; char staticbuf[1024], *buf = staticbuf, *t; size_t buflen = strlen(fmt)*2; + int bufstrlen; /* We try to start using a static buffer for speed. * If not possible we revert to heap allocation. */ @@ -529,16 +546,19 @@ sds sdscatvprintf(sds s, const char *fmt, va_list ap) { buflen = sizeof(staticbuf); } - /* Try with buffers two times bigger every time we fail to + /* Alloc enough space for buffer and \0 after failing to * fit the string in the current buffer size. */ while(1) { - buf[buflen-2] = '\0'; va_copy(cpy,ap); - vsnprintf(buf, buflen, fmt, cpy); + bufstrlen = vsnprintf(buf, buflen, fmt, cpy); va_end(cpy); - if (buf[buflen-2] != '\0') { + if (bufstrlen < 0) { + if (buf != staticbuf) s_free(buf); + return NULL; + } + if (((size_t)bufstrlen) >= buflen) { if (buf != staticbuf) s_free(buf); - buflen *= 2; + buflen = ((size_t)bufstrlen) + 1; buf = s_malloc(buflen); if (buf == NULL) return NULL; continue; @@ -547,7 +567,7 @@ sds sdscatvprintf(sds s, const char *fmt, va_list ap) { } /* Finally concat the obtained string to the SDS string and return it. */ - t = sdscat(s, buf); + t = sdscatlen(s, buf, bufstrlen); if (buf != staticbuf) s_free(buf); return t; } @@ -599,6 +619,10 @@ sds sdscatfmt(sds s, char const *fmt, ...) { long i; va_list ap; + /* To avoid continuous reallocations, let's start with a buffer that + * can hold at least two times the format string itself. It's not the + * best heuristic but seems to work in practice. */ + s = sdsMakeRoomFor(s, initlen + strlen(fmt)*2); va_start(ap,fmt); f = fmt; /* Next format specifier byte to process. */ i = initlen; /* Position of the next byte to write to dest str. */ @@ -614,65 +638,66 @@ sds sdscatfmt(sds s, char const *fmt, ...) { } switch(*f) { - case '%': - next = *(f+1); - f++; - switch(next) { - case 's': - case 'S': - str = va_arg(ap,char*); - l = (next == 's') ? strlen(str) : sdslen(str); - if (sdsavail(s) < l) { - s = sdsMakeRoomFor(s,l); - } - memcpy(s+i,str,l); - sdsinclen(s,l); - i += l; - break; - case 'i': - case 'I': - if (next == 'i') - num = va_arg(ap,int); - else - num = va_arg(ap,long long); - { - char buf[SDS_LLSTR_SIZE]; - l = sdsll2str(buf,num); - if (sdsavail(s) < l) { - s = sdsMakeRoomFor(s,l); - } - memcpy(s+i,buf,l); - sdsinclen(s,l); - i += l; - } - break; - case 'u': - case 'U': - if (next == 'u') - unum = va_arg(ap,unsigned int); - else - unum = va_arg(ap,unsigned long long); - { - char buf[SDS_LLSTR_SIZE]; - l = sdsull2str(buf,unum); - if (sdsavail(s) < l) { - s = sdsMakeRoomFor(s,l); - } - memcpy(s+i,buf,l); - sdsinclen(s,l); - i += l; + case '%': + next = *(f+1); + if (next == '\0') break; + f++; + switch(next) { + case 's': + case 'S': + str = va_arg(ap,char*); + l = (next == 's') ? strlen(str) : sdslen(str); + if (sdsavail(s) < l) { + s = sdsMakeRoomFor(s,l); + } + memcpy(s+i,str,l); + sdsinclen(s,l); + i += l; + break; + case 'i': + case 'I': + if (next == 'i') + num = va_arg(ap,int); + else + num = va_arg(ap,long long); + { + char buf[SDS_LLSTR_SIZE]; + l = sdsll2str(buf,num); + if (sdsavail(s) < l) { + s = sdsMakeRoomFor(s,l); + } + memcpy(s+i,buf,l); + sdsinclen(s,l); + i += l; + } + break; + case 'u': + case 'U': + if (next == 'u') + unum = va_arg(ap,unsigned int); + else + unum = va_arg(ap,unsigned long long); + { + char buf[SDS_LLSTR_SIZE]; + l = sdsull2str(buf,unum); + if (sdsavail(s) < l) { + s = sdsMakeRoomFor(s,l); + } + memcpy(s+i,buf,l); + sdsinclen(s,l); + i += l; + } + break; + default: /* Handle %% and generally %. */ + s[i++] = next; + sdsinclen(s,1); + break; } break; - default: /* Handle %% and generally %. */ - s[i++] = next; + default: + s[i++] = *f; sdsinclen(s,1); break; - } - break; - default: - s[i++] = *f; - sdsinclen(s,1); - break; } f++; } @@ -684,7 +709,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) { } /* Remove the part of the string from left and from right composed just of - * contiguous characters found in 'cset', that is a null terminted C string. + * contiguous characters found in 'cset', that is a null terminated C string. * * After the call, the modified sds string is no longer valid and all the * references must be substituted with the new pointer returned by the call. @@ -695,17 +720,17 @@ sds sdscatfmt(sds s, char const *fmt, ...) { * s = sdstrim(s,"Aa. :"); * printf("%s\n", s); * - * Output will be just "Hello World". + * Output will be just "HelloWorld". */ sds sdstrim(sds s, const char *cset) { - char *start, *end, *sp, *ep; + char *end, *sp, *ep; size_t len; - sp = start = s; + sp = s; ep = end = s+sdslen(s)-1; while(sp <= end && strchr(cset, *sp)) sp++; while(ep > sp && strchr(cset, *ep)) ep--; - len = (sp > ep) ? 0 : ((ep-sp)+1); + len = (ep-sp)+1; if (s != sp) memmove(s, sp, len); s[len] = '\0'; sdssetlen(s,len); @@ -746,10 +771,8 @@ void sdsrange(sds s, ssize_t start, ssize_t end) { newlen = 0; } else if (end >= (ssize_t)len) { end = len-1; - newlen = (start > end) ? 0 : (end-start)+1; + newlen = (end-start)+1; } - } else { - start = 0; } if (start && newlen) memmove(s, s+start, newlen); s[newlen] = 0; @@ -814,15 +837,14 @@ sds *sdssplitlen(const char *s, ssize_t len, const char *sep, int seplen, int *c long start = 0, j; sds *tokens; - if (seplen < 1 || len < 0) return NULL; + if (seplen < 1 || len <= 0) { + *count = 0; + return NULL; + } tokens = s_malloc(sizeof(sds)*slots); if (tokens == NULL) return NULL; - if (len == 0) { - *count = 0; - return tokens; - } for (j = 0; j < (len-(seplen-1)); j++) { /* make sure there is room for the next element and the final one */ if (slots < elements+2) { @@ -849,7 +871,7 @@ sds *sdssplitlen(const char *s, ssize_t len, const char *sep, int seplen, int *c *count = elements; return tokens; -cleanup: + cleanup: { int i; for (i = 0; i < elements; i++) sdsfree(tokens[i]); @@ -877,21 +899,21 @@ sds sdscatrepr(sds s, const char *p, size_t len) { s = sdscatlen(s,"\"",1); while(len--) { switch(*p) { - case '\\': - case '"': - s = sdscatprintf(s,"\\%c",*p); - break; - case '\n': s = sdscatlen(s,"\\n",2); break; - case '\r': s = sdscatlen(s,"\\r",2); break; - case '\t': s = sdscatlen(s,"\\t",2); break; - case '\a': s = sdscatlen(s,"\\a",2); break; - case '\b': s = sdscatlen(s,"\\b",2); break; - default: - if (isprint(*p)) - s = sdscatprintf(s,"%c",*p); - else - s = sdscatprintf(s,"\\x%02x",(unsigned char)*p); - break; + case '\\': + case '"': + s = sdscatprintf(s,"\\%c",*p); + break; + case '\n': s = sdscatlen(s,"\\n",2); break; + case '\r': s = sdscatlen(s,"\\r",2); break; + case '\t': s = sdscatlen(s,"\\t",2); break; + case '\a': s = sdscatlen(s,"\\a",2); break; + case '\b': s = sdscatlen(s,"\\b",2); break; + default: + if (isprint(*p)) + s = sdscatprintf(s,"%c",*p); + else + s = sdscatprintf(s,"\\x%02x",(unsigned char)*p); + break; } p++; } @@ -909,23 +931,23 @@ int is_hex_digit(char c) { * integer from 0 to 15 */ int hex_digit_to_int(char c) { switch(c) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - case 'a': case 'A': return 10; - case 'b': case 'B': return 11; - case 'c': case 'C': return 12; - case 'd': case 'D': return 13; - case 'e': case 'E': return 14; - case 'f': case 'F': return 15; - default: return 0; + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + case 'a': case 'A': return 10; + case 'b': case 'B': return 11; + case 'c': case 'C': return 12; + case 'd': case 'D': return 13; + case 'e': case 'E': return 14; + case 'f': case 'F': return 15; + default: return 0; } } @@ -967,13 +989,13 @@ sds *sdssplitargs(const char *line, int *argc) { while(!done) { if (inq) { if (*p == '\\' && *(p+1) == 'x' && - is_hex_digit(*(p+2)) && - is_hex_digit(*(p+3))) + is_hex_digit(*(p+2)) && + is_hex_digit(*(p+3))) { unsigned char byte; byte = (hex_digit_to_int(*(p+2))*16)+ - hex_digit_to_int(*(p+3)); + hex_digit_to_int(*(p+3)); current = sdscatlen(current,(char*)&byte,1); p += 3; } else if (*p == '\\' && *(p+1)) { @@ -981,12 +1003,12 @@ sds *sdssplitargs(const char *line, int *argc) { p++; switch(*p) { - case 'n': c = '\n'; break; - case 'r': c = '\r'; break; - case 't': c = '\t'; break; - case 'b': c = '\b'; break; - case 'a': c = '\a'; break; - default: c = *p; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'b': c = '\b'; break; + case 'a': c = '\a'; break; + default: c = *p; break; } current = sdscatlen(current,&c,1); } else if (*p == '"') { @@ -1017,22 +1039,22 @@ sds *sdssplitargs(const char *line, int *argc) { } } else { switch(*p) { - case ' ': - case '\n': - case '\r': - case '\t': - case '\0': - done=1; - break; - case '"': - inq=1; - break; - case '\'': - insq=1; - break; - default: - current = sdscatlen(current,p,1); - break; + case ' ': + case '\n': + case '\r': + case '\t': + case '\0': + done=1; + break; + case '"': + inq=1; + break; + case '\'': + insq=1; + break; + default: + current = sdscatlen(current,p,1); + break; } } if (*p) p++; @@ -1049,7 +1071,7 @@ sds *sdssplitargs(const char *line, int *argc) { } } -err: + err: while((*argc)--) sdsfree(vector[*argc]); s_free(vector); @@ -1151,6 +1173,22 @@ int sdsTest(void) { test_cond("sdscatprintf() seems working in the base case", sdslen(x) == 3 && memcmp(x,"123\0",4) == 0) + sdsfree(x); + x = sdscatprintf(sdsempty(),"a%cb",0); + test_cond("sdscatprintf() seems working with \\0 inside of result", + sdslen(x) == 3 && memcmp(x,"a\0""b\0",4) == 0) + + { + sdsfree(x); + char etalon[1024*1024]; + for (size_t i = 0; i < sizeof(etalon); i++) { + etalon[i] = '0'; + } + x = sdscatprintf(sdsempty(),"%0*d",(int)sizeof(etalon),0); + test_cond("sdscatprintf() can print 1MB", + sdslen(x) == sizeof(etalon) && memcmp(x,etalon,sizeof(etalon)) == 0) + } + sdsfree(x); x = sdsnew("--"); x = sdscatfmt(x, "Hello %s World %I,%I--", "Hi!", LLONG_MIN,LLONG_MAX); @@ -1246,7 +1284,6 @@ int sdsTest(void) { memcmp(y,"\"\\a\\n\\x00foo\\r\"",15) == 0) { - unsigned int oldfree; char *p; int step = 10, j, i; @@ -1265,7 +1302,6 @@ int sdsTest(void) { test_cond("sdsMakeRoomFor() len", sdslen(x) == oldlen); if (type != SDS_TYPE_5) { test_cond("sdsMakeRoomFor() free", sdsavail(x) >= step); - oldfree = sdsavail(x); } p = x+oldlen; for (j = 0; j < step; j++) { diff --git a/src/vendors/sds/sds.h b/src/vendors/sds/sds.h index 1bdb60d..87d76fc 100644 --- a/src/vendors/sds/sds.h +++ b/src/vendors/sds/sds.h @@ -34,7 +34,7 @@ #define __SDS_H #define SDS_MAX_PREALLOC (1024*1024) -const char *SDS_NOINIT; +extern const char *SDS_NOINIT; #include #include @@ -131,10 +131,10 @@ static inline void sdssetlen(sds s, size_t newlen) { unsigned char flags = s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: - { - unsigned char *fp = ((unsigned char*)s)-1; - *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); - } + { + unsigned char *fp = ((unsigned char*)s)-1; + *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); + } break; case SDS_TYPE_8: SDS_HDR(8,s)->len = newlen; @@ -155,11 +155,11 @@ static inline void sdsinclen(sds s, size_t inc) { unsigned char flags = s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: - { - unsigned char *fp = ((unsigned char*)s)-1; - unsigned char newlen = SDS_TYPE_5_LEN(flags)+inc; - *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); - } + { + unsigned char *fp = ((unsigned char*)s)-1; + unsigned char newlen = SDS_TYPE_5_LEN(flags)+inc; + *fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS); + } break; case SDS_TYPE_8: SDS_HDR(8,s)->len += inc; diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..b3e61ce --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,15 @@ +[supervisord] +nodaemon=true +user=root + +[program:amnutsTalker] +command=/amnuts/build/amnutsTalker +directory=/amnuts +autostart=true +autorestart=unexpected +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +environment=IN_FOREGROUND="1" +startsecs=0 diff --git a/userfiles/rooms/.gitignore b/userfiles/rooms/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/userfiles/xgcoms/.gitignore b/userfiles/xgcoms/.gitignore deleted file mode 100644 index e69de29..0000000