dpr/cnf/
dpr/lib/
dpr/lib/house/
dpr/lib/misc/
dpr/lib/text/clan/
dpr/lib/text/help/
dpr/lib/world/
dpr/lib/world/qst/
dpr/src-backup/src/util/
dpr/src/
dpr/src/src code added/
/* ************************************************************************
*   File: interpreter.c                                 Part of CircleMUD *
*  Usage: parse user commands, search for specials, call ACMD functions   *
*                                                                         *
*  All rights reserved.  See license.doc for complete information.        *
*                                                                         *
*  Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
*  CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.               *
************************************************************************ */

#define __INTERPRETER_C__

#include "conf.h"
#include "sysdep.h"

#include "structs.h"
#include "comm.h"
#include "interpreter.h"
#include "db.h"
#include "utils.h"
#include "spells.h"
#include "handler.h"
#include "mail.h"
#include "screen.h"
#include "olc.h"
#include "dg_scripts.h"


extern sh_int r_mortal_start_room ;
extern sh_int r_immort_start_room;
extern sh_int r_frozen_start_room;
extern sh_int r_death_start_room;
extern sh_int r_ctf_start_room;
extern const char *class_menu;
extern char *motd;
extern char *imotd;
extern char *background;
extern char *MENU;
extern char *WELC_MESSG;
extern char *START_MESSG;
extern struct char_data *character_list;
extern struct descriptor_data *descriptor_list;
extern struct player_index_element *player_table;
extern int top_of_p_table;
extern int circle_restrict;
extern int no_specials;
extern int max_bad_pws;
extern struct index_data *mob_index;
extern struct index_data *obj_index;
extern struct room_data *world;

/* external functions */
void do_newbie(struct char_data *vict);
void echo_on(struct descriptor_data *d);
void echo_off(struct descriptor_data *d);
void do_start(struct char_data *ch);
int parse_class(char arg);
int special(struct char_data *ch, int cmd, char *arg);
int isbanned(char *hostname);
int Valid_Name(char *newname);
void oedit_parse(struct descriptor_data *d, char *arg);
void redit_parse(struct descriptor_data *d, char *arg);
void hedit_parse(struct descriptor_data *d, char *arg);
void zedit_parse(struct descriptor_data *d, char *arg);
void medit_parse(struct descriptor_data *d, char *arg);
void sedit_parse(struct descriptor_data *d, char *arg);
void trigedit_parse(struct descriptor_data *d, char *arg);
void aedit_parse(struct descriptor_data *d, char *arg);

/* local functions */
int perform_dupe_check(struct descriptor_data *d);
struct alias *find_alias(struct alias *alias_list, char *str);
void free_alias(struct alias *a);
void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias *a);
int perform_alias(struct descriptor_data *d, char *orig);
int reserved_word(char *argument);
int find_name(char *name);
int _parse_name(char *arg, char *name);

/* prototypes for all do_x functions. */
ACMD(do_absorb);
ACMD(do_action);
ACMD(do_advance);
ACMD(do_afk);
ACMD(do_spar);
ACMD(do_sparkick);
ACMD(do_sparpunch);
ACMD(do_sparknee);
ACMD(do_sparelbow);
ACMD(do_sparkiblast);
ACMD(do_alias);
ACMD(do_assist);
ACMD(do_orevert);
ACMD(do_at);
ACMD(do_backstab);
ACMD(do_ban);
ACMD(do_bigbang);
ACMD(do_sweep);
ACMD(do_knee);
ACMD(do_kishot);
ACMD(do_kikoho);
ACMD(do_elbow);
ACMD(do_roundhouse);
ACMD(do_focus);
ACMD(do_choukame);
ACMD(do_color);
ACMD(do_commands);
ACMD(do_consider);
ACMD(do_copyover);
ACMD(do_stealth);
ACMD(do_copy);
ACMD(do_charge);
ACMD(do_credits);
ACMD(do_cypress);
ACMD(do_date);
ACMD(do_dc);
ACMD(do_diagnose);
ACMD(do_disk);
ACMD(do_pk);
ACMD(do_powerup);
ACMD(do_powerdown);
ACMD(do_display);
ACMD(do_scan);
ACMD(do_drink);
ACMD(do_drop);
ACMD(do_eat);
ACMD(do_echo);
ACMD(do_enter);
ACMD(do_equipment);
ACMD(do_examine);
ACMD(do_powersense);
ACMD(do_exit);
ACMD(do_exits);
ACMD(do_jog);
ACMD(do_finalflash);
ACMD(do_flee);
ACMD(do_fly);
ACMD(do_land);
ACMD(do_follow);
ACMD(do_selfdestruct);
ACMD(do_force);
ACMD(do_gecho);
ACMD(do_gen_comm);
ACMD(do_gen_door);
ACMD(do_gen_ps);
ACMD(do_gen_tog);
ACMD(do_gen_write);
ACMD(do_get);
ACMD(do_give);
ACMD(do_gold);
ACMD(do_goto);
ACMD(do_grab);
ACMD(do_group);
ACMD(do_gsay);
ACMD(do_osay);
ACMD(do_hcontrol);
ACMD(do_help);
ACMD(do_heal);
ACMD(do_hide);
ACMD(do_hit);
ACMD(do_house);
ACMD(do_info);
ACMD(do_insult);
ACMD(do_ingest);
ACMD(do_inventory);
ACMD(do_invis);
ACMD(do_kaioken);
ACMD(do_kamehame);
ACMD(do_kick);
ACMD(do_regenerate);
ACMD(do_kill);
ACMD(do_last);
ACMD(do_leave);
ACMD(do_learn);
ACMD(do_learned);
ACMD(do_mystic);
ACMD(do_makanko);
ACMD(do_masenko);
ACMD(do_load);
ACMD(do_look);
ACMD(do_halt);
ACMD(do_upgrade);
/* ACMD(do_move); -- interpreter.h */
ACMD(do_not_here);
ACMD(do_offer);
ACMD(do_olc);
ACMD(do_order);
ACMD(do_page);
ACMD(do_peace);
ACMD(do_perfection);
ACMD(do_poofset);
ACMD(do_pour);
ACMD(do_purge);
ACMD(do_pushup);
ACMD(do_put);
ACMD(do_qcomm);
ACMD(do_quit);
ACMD(do_reboot);
ACMD(do_remove);
ACMD(do_rent);
ACMD(do_repair);
ACMD(do_reply);
ACMD(do_report);
ACMD(do_rescue);
ACMD(do_rest);
ACMD(do_restore);
ACMD(do_restore);
ACMD(do_return);
ACMD(do_rlink);
ACMD(do_save);
ACMD(do_say);
ACMD(do_score);
ACMD(do_status);
ACMD(do_send);
ACMD(do_set);
ACMD(do_ftick);
ACMD(do_show);
ACMD(do_shutdown);
ACMD(do_sit);
ACMD(do_situp);
ACMD(do_skillset);
ACMD(do_sleep);
ACMD(do_SWIFTNESS);
ACMD(do_snoop);
ACMD(do_spec_comm);
ACMD(do_ssj);
ACMD(do_evil);
ACMD(do_transform);
/*ACMD(do_morph);*/
ACMD(do_renzo);
ACMD(do_split);
ACMD(do_stand);
ACMD(do_stat);
ACMD(do_steal);
ACMD(do_camp);
ACMD(do_switch);
ACMD(do_syslog);
ACMD(do_tailwhip);
ACMD(do_tedit);
ACMD(do_teleport);
ACMD(do_tell);
ACMD(do_time);
ACMD(do_title);
ACMD(do_toggle);
ACMD(do_sense);
ACMD(do_trans);
ACMD(do_unban);
ACMD(do_ungroup);
ACMD(do_use);
ACMD(do_users);
ACMD(do_visible);
ACMD(do_finger);
ACMD(do_vnum);
ACMD(do_vstat);
ACMD(do_wake);
ACMD(do_wear);
ACMD(do_weather);
ACMD(do_where);
ACMD(do_who);
ACMD(do_wield);
ACMD(do_wimpy);
ACMD(do_wizlock);
ACMD(do_wiznet);
ACMD(do_wizutil);
ACMD(do_write);
ACMD(do_zreset);

/* DG Script ACMD's */
ACMD(do_attach);
ACMD(do_detach);
ACMD(do_tlist);
ACMD(do_tstat);
ACMD(do_masound);
ACMD(do_mkill);
ACMD(do_mjunk);
ACMD(do_mechoaround);
ACMD(do_msend);
ACMD(do_mecho);
ACMD(do_mload);
ACMD(do_mpurge);
ACMD(do_mgoto);
ACMD(do_mat);
ACMD(do_mteleport);
ACMD(do_mforce);
ACMD(do_mexp);
ACMD(do_mgold);
ACMD(do_mhunt);
ACMD(do_mremember);
ACMD(do_mforget);
ACMD(do_mtransform);

cpp_extern struct command_info *complete_cmd_info;

/* This is the Master Command List(tm).

 * You can put new commands in, take commands out, change the order
 * they appear in, etc.  You can adjust the "priority" of commands
 * simply by changing the order they appear in the command list.
 * (For example, if you want "as" to mean "assist" instead of "ask",
 * just put "assist" above "ask" in the Master Command List(tm).
 *
 * In general, utility commands such as "at" should have high priority;
 * infrequently used and dangerously destructive commands should have low
 * priority.
 */

cpp_extern const struct command_info cmd_info[] = {
  { "RESERVED" , "RESERVED", 0, 0, 0, 0 },	/* this must be first -- for specprocs */

  /* directions must come before other commands but after RESERVED */
  { "north"    , "n"    , POS_STANDING, do_move     , 0, SCMD_NORTH },
  { "east"     , "e"	, POS_STANDING, do_move     , 0, SCMD_EAST },
  { "south"    , "s"	, POS_STANDING, do_move     , 0, SCMD_SOUTH },
  { "west"     , "w"	, POS_STANDING, do_move     , 0, SCMD_WEST },
  { "up"       , "u"	, POS_STANDING, do_move     , 0, SCMD_UP },
  { "down"     , "d"	, POS_STANDING, do_move     , 0, SCMD_DOWN },
  
  { "stat"     , "stat"	, POS_DEAD    , do_stat     , LVL_IMMORT, 0 },
  { "look"     , "l"	, POS_RESTING , do_look     , 0, SCMD_LOOK },
  { "score"    , "sco"	, POS_DEAD    , do_score    , 0, 0 },
  { "status"   , "stat"	, POS_DEAD    , do_status   , 0, 0 },
  { "kill"     , "k"	, POS_FIGHTING, do_kill     , 0, 0 },
  { "inventory", "i"	, POS_DEAD    , do_inventory, 0, 0 },
  { "halt"     , "hal"	, POS_DEAD    , do_halt     , 0, 0 },
  
  /* now, the main list */
  { "at"       , "at"	, POS_DEAD    , do_at       , LVL_IMMORT, 0 },
  { "advance"  , "adv"	, POS_DEAD    , do_advance  , LVL_GOD, 0 },
  { "afk"      , "afk"  , POS_DEAD    , do_gen_tog  , 0, SCMD_AFK },
  { "spar"     , "spa"  , POS_STANDING    , do_spar     , 0, 0 },
  { "sparkick"      , "sparkic"  , POS_STANDING    , do_sparkick      , 0, 0 },
  { "sparpunch"     , "sparp"    , POS_STANDING    , do_sparpunch     , 0, 0 },
  { "sparelbow"     , "spare"    , POS_STANDING    , do_sparelbow     , 0, 0 },
  { "sparknee"      , "sparkn"   , POS_STANDING    , do_sparknee      , 0, 0 },
  { "sparkiblast"   , "sparkib"  , POS_STANDING    , do_sparkiblast   , 0, 0 },



  { "aedit"    , "aed"	, POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_AEDIT },
  { "alias"    , "ali"	, POS_DEAD    , do_alias    , 0, 0 },
  { "powersense" , "ps"	, POS_DEAD    , do_powersense , 0, 0 },
  { "absorb"   , "abs"	, POS_DEAD    , do_absorb   , 0, 0 },
  { "assist"   , "ass"	, POS_FIGHTING, do_assist   , 1, 0 },
  { "ask"      , "ask"	, POS_RESTING , do_spec_comm, 0, SCMD_ASK },
  { "ooc"      , "oo"	, POS_SLEEPING, do_gen_comm , 0, SCMD_ooc },
  { "autoexit" , "autoe", POS_DEAD    , do_gen_tog  , 0, SCMD_AUTOEXIT },

  { "backstab" , "bac"	, POS_STANDING, do_backstab , 1, 0 },
  { "ban"      , "ban"	, POS_DEAD    , do_ban      , LVL_GRGOD, 0 },
  { "orevert"  , "orev"	, POS_DEAD    , do_orevert  , 1, 0 },
  { "balance"  , "bal"	, POS_STANDING, do_not_here , 1, 0 },
  { "sweep"     , "bas"	, POS_FIGHTING, do_sweep     , 1, 0 },
  { "brief"    , "br"   , POS_DEAD    , do_gen_tog  , 0, SCMD_BRIEF },
  { "buy"      , "b"    , POS_STANDING, do_not_here , 0, 0 },
  { "bug"      , "bug"  , POS_DEAD    , do_gen_write, 0, SCMD_BUG },

  /*{ "focus"    , "f"    , POS_SITTING , do_focus    , 1, 0 },*/
  { "check"    , "ch"   , POS_STANDING, do_not_here , 1, 0 },
  { "choukamehameha" , "chou" , POS_FIGHTING, do_choukame , 1, 0 },
  { "clear"    , "cle"	, POS_DEAD    , do_gen_ps   , 0, SCMD_CLEAR },
  { "close"    , "clo"	, POS_SITTING , do_gen_door , 0, SCMD_CLOSE },
  { "clone"    , "clon"  , POS_DEAD    , do_copy     , LVL_IMMORT, 0 },
  { "cls"      , "cls"	, POS_DEAD    , do_gen_ps   , 0, SCMD_CLEAR },
  { "consider" , "con"	, POS_RESTING , do_consider , 0, 0 },
  { "congrat"  , "cong" , POS_SLEEPING, do_gen_comm , 0, SCMD_GRATZ },
  { "color"    , "col"	, POS_DEAD    , do_color    , 0, 0 },
  { "commands" , "comm"	, POS_DEAD    , do_commands , 0, SCMD_COMMANDS },
  { "compact"  , "comp"	, POS_DEAD    , do_gen_tog  , 0, SCMD_COMPACT },
  { "copyover" , "copyover", POS_DEAD, do_copyover, LVL_GRGOD, 0 },
  { "charge"   , "ch"	, POS_STANDING , do_charge  , 1, 0 },
  { "credits"  , "cre"	, POS_DEAD    , do_gen_ps   , 0, SCMD_CREDITS },
  { "cypress"  , "cyp"  , POS_SITTING , do_cypress  , LVL_IMMORT, 0 },

  { "date"     , "date"	, POS_DEAD    , do_date     , LVL_IMMORT, SCMD_DATE },
  { "dc"       , "dc"	, POS_DEAD    , do_dc       , LVL_GOD, 0 },
  { "deposit"  , "dep"	, POS_STANDING, do_not_here , 1, 0 },
  { "destructo" , "des" , POS_FIGHTING, do_disk , 1, 0 },
  { "diagnose" , "dia"	, POS_RESTING , do_diagnose , 0, 0 },
  { "disk"     , "disk" , POS_FIGHTING, do_disk , 1, 0 },
  { "display"  , "dis"	, POS_DEAD    , do_display  , 0, 0 },
  { "donate"   , "don"	, POS_RESTING , do_drop     , 0, SCMD_DONATE },
  { "drink"    , "dr"	, POS_RESTING , do_drink    , 0, SCMD_DRINK },
  { "drop"     , "dro"	, POS_RESTING , do_drop     , 0, SCMD_DROP },

  { "eat"      , "ea"	, POS_RESTING , do_eat      , 0, SCMD_EAT },
  { "echo"     , "echo"	, POS_SLEEPING, do_echo     , LVL_IMMORT, SCMD_ECHO },
  { "elbow"    , "elb"	, POS_FIGHTING, do_elbow    , 1, 0 },
  { "emote"    , "em"	, POS_RESTING , do_echo     , 1, SCMD_EMOTE },
  { ":"        , ":"	, POS_RESTING, do_echo      , 1, SCMD_EMOTE },
  { "enter"    , "en"	, POS_STANDING, do_enter    , 0, 0 },
  { "equipment", "eq"	, POS_SLEEPING, do_equipment, 0, 0 },
  /*{ "evil"     , "evi"  , POS_STANDING, do_evil     , 1, 0 },*/
  { "exits"    , "exi"	, POS_RESTING , do_exits    , 0, 0 },
  { "examine"  , "exa"	, POS_SITTING , do_examine  , 0, 0 },

  { "force"    , "for"	, POS_SLEEPING, do_force    , LVL_GOD, 0 },
  { "fill"     , "fil"	, POS_STANDING, do_pour     , 0, SCMD_FILL },
  { "finalflash" , "final" , POS_FIGHTING, do_finalflash , 1, 0 },
  { "flee"     , "fl"	, POS_FIGHTING, do_flee     , 1, 0 },
  { "follow"   , "fol"	, POS_RESTING , do_follow   , 0, 0 },
  { "selfdestruct" , "selfdest"	, POS_RESTING , do_selfdestruct , 0, 0 },
  { "fly"      , "fl"	, POS_RESTING , do_fly      , 1, 0 },
  { "freeze"   , "free" , POS_DEAD    , do_wizutil  , LVL_FREEZE, SCMD_FREEZE },

  { "get"      , "g"	, POS_RESTING , do_get      , 0, 0 },
  { "gecho"    , "gech"	, POS_DEAD    , do_gecho    , LVL_GOD, 0 },
  { "give"     , "giv"	, POS_RESTING , do_give     , 0, 0 },
  { "goto"     , "got"	, POS_SLEEPING, do_goto     , LVL_IMMORT, 0 },
  { "gold"     , "gol"	, POS_RESTING , do_gold     , 0, 0 },
  { "group"    , "gro"  , POS_RESTING , do_group    , 1, 0 },
  { "grab"     , "gra"  , POS_RESTING , do_grab     , 0, 0 },
  { "grats"    , "grat" , POS_SLEEPING, do_gen_comm , 0, SCMD_GRATZ },
  { "gsay"     , "gs"   , POS_SLEEPING, do_gsay     , 0, 0 },
  { "gtell"    , "gt"   , POS_SLEEPING, do_gsay     , 0, 0 },

  { "help"     , "he"	, POS_DEAD    , do_help     , 0, 0 },
  { "heal"     , "hea"  , POS_RESTING , do_heal     , 0, 0 },
  { "hedit"    , "hedit", POS_DEAD    , do_olc	   , LVL_IMMORT, SCMD_OLC_HEDIT },
  { "handbook" , "hand"	, POS_DEAD    , do_gen_ps   , LVL_IMMORT, SCMD_HANDBOOK },
  { "hcontrol" , "hcon"	, POS_DEAD    , do_hcontrol , LVL_IMMORT, 0 },
  { "hide"     , "hid"  , POS_RESTING , do_hide     , 1, 0 },
  { "hit"      , "h"	, POS_FIGHTING, do_hit      , 0, SCMD_HIT },
  { "hold"     , "ho"	, POS_RESTING , do_grab     , 1, 0 },
  { "holler"   , "hol"	, POS_RESTING , do_gen_comm , 1, SCMD_HOLLER },
  { "holylight", "holy"	, POS_DEAD    , do_gen_tog  , LVL_IMMORT, SCMD_HOLYLIGHT },
  { "house"    , "hou"	, POS_RESTING , do_house    , 0, 0 },

  { "idea"     , "id"	, POS_DEAD    , do_gen_write, 0, SCMD_IDEA },
  { "imotd"    , "imo"	, POS_DEAD    , do_gen_ps   , LVL_IMMORT, SCMD_IMOTD },
  { "immlist"  , "imm"	, POS_DEAD    , do_gen_ps   , 0, SCMD_IMMLIST },
  { "info"     , "inf"	, POS_SLEEPING, do_gen_ps   , 0, SCMD_INFO },
  { "insult"   , "ins"	, POS_RESTING , do_insult   , 0, 0 },
  { "invis"    , "inv"	, POS_DEAD    , do_invis    , LVL_IMMORT, 0 },

  { "junk"     , "j"	, POS_RESTING , do_drop     , 0, SCMD_JUNK },

  { "kaioken"  , "kaio"	, POS_STANDING, do_kaioken  , 1, 0 },
  { "kamehameha" , "kame" , POS_FIGHTING, do_kamehame , 1, 0 },
  { "kick"     , "kic"	, POS_FIGHTING, do_kick     ,  LVL_IMMORT, 0 },
  { "kienzan"  , "kien" , POS_FIGHTING, do_disk , 1, 0 },
  { "kikoho"   , "kik"  , POS_FIGHTING, do_kikoho, 1, 0 },
  { "kishot"   , "kish" , POS_FIGHTING, do_kishot, 1, 0 },
  { "regenerate" , "regen" , POS_STANDING, do_regenerate  , 1, 0 },
  { "knee"     , "kn"	, POS_FIGHTING, do_knee     , 1, 0 },

  { "scan"     , "sc"	, POS_RESTING , do_scan     , 0, 0 },
  { "stealth"  , "stea" , POS_RESTING , do_stealth  , 0, 0 },
  { "upgrade"  , "upg"	, POS_RESTING , do_upgrade  , 0, 0 },
  { "last"     , "la"	, POS_DEAD    , do_last     , LVL_GOD, 0 },
  { "land"     , "lan"  , POS_FLYING  , do_land     , 0, 0 },
  { "learn"    , "lear" , POS_RESTING , do_learn    , 1, 0 },
  { "learned"  , "learne" , POS_RESTING, do_learned , 1, 0 },
  { "leave"    , "lea"	, POS_STANDING, do_leave    , 0, 0 },
  { "list"     , "li"	, POS_STANDING, do_not_here , 0, 0 },
  { "lock"     , "loc"	, POS_SITTING , do_gen_door , 0, SCMD_LOCK },
  { "load"     , "loa"	, POS_DEAD    , do_load     , LVL_IMMORT, 0 },

  { "medit"    , "med"	, POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_MEDIT },
  { "makankosappo"  , "maka" , POS_FIGHTING, do_makanko , 1, 0 },
  { "masenko"  , "mase" , POS_FIGHTING, do_masenko , 1, 0 },
  { "motd"     , "motd" , POS_DEAD    , do_gen_ps   , 0, SCMD_MOTD },
  { "mail"     , "mail"	, POS_STANDING, do_not_here , 1, 0 },
  { "mute"     , "mut"	, POS_DEAD    , do_wizutil  , LVL_IMMORT, SCMD_SQUELCH },
  { "murder"   , "mur"	, POS_FIGHTING, do_hit      , 0, SCMD_MURDER },
  { "mystic"   , "mys"  , POS_STANDING, do_mystic   , 1, 0 },

  { "news"     , "new"	, POS_SLEEPING, do_gen_ps   , 0, SCMD_NEWS },
  { "noooc", "noa"	, POS_DEAD    , do_gen_tog  , 0, SCMD_NOooc },
  { "norp" , "norp"	, POS_DEAD    , do_gen_tog  , 0, SCMD_NOGOSSIP },
  { "nograts"  , "nogr"	, POS_DEAD    , do_gen_tog  , 0, SCMD_NOGRATZ },
  { "nohassle" , "noh"	, POS_DEAD    , do_gen_tog  , LVL_IMMORT, SCMD_NOHASSLE },
  { "norepeat" , "nor"	, POS_DEAD    , do_gen_tog  , 0, SCMD_NOREPEAT },
  { "noshout"  , "nosh"	, POS_SLEEPING, do_gen_tog  , 1, SCMD_DEAF },
  { "notell"   , "note"	, POS_DEAD    , do_gen_tog  , 1, SCMD_NOTELL },
  { "notitle"  , "noti"	, POS_DEAD    , do_wizutil  , LVL_GOD, SCMD_NOTITLE },
  { "nowiz"    , "now"	, POS_DEAD    , do_gen_tog  , LVL_IMMORT, SCMD_NOWIZ },

  { "order"    , "ord"	, POS_RESTING , do_order    , 1, 0 },
  { "offer"    , "off"	, POS_STANDING, do_not_here , 1, 0 },
  { "open"     , "op"	, POS_SITTING , do_gen_door , 0, SCMD_OPEN },
  { "olc"      , "olc"	, POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_SAVEINFO },
  { "oedit"    , "oed"	, POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_OEDIT},

  { "put"      , "p"	, POS_RESTING , do_put      , 0, 0 },
  { "page"     , "pag"	, POS_DEAD    , do_page     , LVL_GOD, 0 },
  { "pardon"   , "par"	, POS_DEAD    , do_wizutil  , LVL_GOD, SCMD_PARDON },
  { "peace"    , "pea"	, POS_DEAD    , do_peace     , LVL_IMMORT, 0 },
  { "perfection"  , "per" , POS_STANDING, do_perfection , 1, 0 },
  { "pick"     , "pi"	, POS_STANDING, do_gen_door , 1, SCMD_PICK },
  { "pk"       , "pk"   , POS_SLEEPING, do_pk       , 50 , 0 },
  { "policy"   , "pol"	, POS_DEAD    , do_gen_ps   , 0, SCMD_POLICIES },
  { "poofin"   , "poofi", POS_DEAD    , do_poofset  , LVL_IMMORT, SCMD_POOFIN },
  { "poofout"  , "poofo", POS_DEAD    , do_poofset  , LVL_IMMORT, SCMD_POOFOUT },
  { "pour"     , "pour" , POS_STANDING, do_pour     , 0, SCMD_POUR },
  { "powerup"  , "pow"  , POS_STANDING, do_powerup  , 0, 0 },
  { "powerdown" , "powerd"  , POS_STANDING, do_powerdown  , 0, 0 },
  { "prompt"   , "promp", POS_DEAD    , do_display  , 0, 0 },
  { "pushup"   ,"pushu" , POS_STANDING, do_pushup , 1, 0 },
  { "jog"      ,"jo"    , POS_STANDING, do_jog    , 1, 0 },
  { "purge"    , "pur"	, POS_DEAD    , do_purge    , LVL_IMMORT, 0 },

  { "plant"    , "pl"	, POS_RESTING , do_use      , 0, SCMD_PLANT },
  { "qui"      , "qui"	, POS_DEAD    , do_quit     , 0, 0 },
  { "quit"     , "quit"	, POS_DEAD    , do_quit     , 0, SCMD_QUIT },
  { "qsay"     , "qsay"	, POS_RESTING , do_qcomm    , 0, SCMD_QSAY },

  { "renzokou" , "renzo" , POS_FIGHTING, do_renzo , 1, 0 },
  { "reply"    , "r"	, POS_SLEEPING, do_reply    , 0, 0 },
  { "rest"     , "res"	, POS_RESTING , do_rest     , 0, 0 },
  { "read"     , "rea"	, POS_RESTING , do_look     , 0, SCMD_READ },
  { "reload"   , "rel"	, POS_DEAD    , do_reboot   , LVL_IMPL, 0 },
  { "swallow"  , "swal"	, POS_RESTING , do_use      , 0, SCMD_SWALLOW },
  { "receive"  , "rece"	, POS_STANDING, do_not_here , 1, 0 },
  { "remove"   , "rem"	, POS_RESTING , do_remove   , 0, 0 },
  { "rent"     , "ren"	, POS_STANDING, do_not_here , 1, 0 },
  { "repair"   , "repa" , POS_SITTING , do_repair   , 1, 0 },
  { "ingest"   , "ing"  , POS_SITTING , do_ingest   , 1, 0 },
  { "report"   , "rep"	, POS_RESTING , do_report   , 0, 0 },
  { "reroll"   , "rer"	, POS_DEAD    , do_wizutil  , LVL_GRGOD, SCMD_REROLL },
  { "rescue"   , "resc"	, POS_FIGHTING, do_rescue   , 1, 0 },
  { "restore"  , "resto", POS_DEAD    , do_restore  , LVL_IMMORT, 0 },
  { "return"   , "ret"	, POS_DEAD    , do_return   , 0, 0 },
  { "redit"    , "redit", POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_REDIT},
  { "rlink"    , "rlink", POS_DEAD    , do_rlink    , LVL_IMMORT, 0 },
  { "roleplay" , "role"  , POS_SLEEPING, do_gen_comm , 0, SCMD_GOSSIP },
  { "roomflags", "roomf", POS_DEAD    , do_gen_tog  , LVL_IMMORT, SCMD_ROOMFLAGS },
  { "roundhouse", "rou"	, POS_FIGHTING, do_roundhouse , 1, 0 },
  { "rp"       , "rp"   , POS_DEAD    , do_gen_tog  , 0, SCMD_QUEST },
  { "rpecho"   , "rpec"	, POS_DEAD    , do_qcomm    , LVL_IMMORT, SCMD_QECHO },

  { "say"      , "say"	, POS_RESTING , do_say      , 0, 0 },
  { "osay"     , "osay"	, POS_RESTING , do_osay     , 0, 0 },
  { "'"        , "'"	, POS_RESTING , do_say      , 0, 0 },
  { "save"     , "save"	, POS_SLEEPING, do_save     , 0, 0 },
  { "sell"     , "sel"	, POS_STANDING, do_not_here , 0, 0 },
  { "send"     , "sen"	, POS_SLEEPING, do_send     , LVL_GOD, 0 },
  { "set"      , "set"	, POS_DEAD    , do_set      , LVL_GOD, 0 },
  { "ftick"    , "ftick", POS_DEAD    , do_ftick    , LVL_GOD, 0 },
  { "sedit"    , "sedi"	, POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_SEDIT},
  { "shout"    , "sho"	, POS_RESTING , do_gen_comm , 0, SCMD_SHOUT },
  { "shake"    , "sha"	, POS_RESTING , do_action   , 0, 0 },
  { "shiver"   , "shiv"	, POS_RESTING , do_action   , 0, 0 },
  { "show"     , "sho"	, POS_DEAD    , do_show     , LVL_IMMORT, 0 },
  { "shutdow"  , "shutdow", POS_DEAD    , do_shutdown , LVL_GRGOD, 0 },
  { "shutdown" , "shutdown", POS_DEAD    , do_shutdown , LVL_GRGOD, SCMD_SHUTDOWN },
  { "sip"      , "sip"	, POS_RESTING , do_drink    , 0, SCMD_SIP },
  { "sit"      , "sit"	, POS_RESTING , do_sit      , 0, 0 },
  { "situp"    ,"situ"  , POS_STANDING, do_situp , 1, 0 },
  { "skillset" , "skillse" , POS_SLEEPING, do_skillset , LVL_GRGOD, 0 },
  { "sleep"    , "sl"	, POS_SLEEPING, do_sleep    , 0, 0 },
  { "slowns"   , "slown", POS_DEAD    , do_gen_tog  , LVL_IMPL, SCMD_SLOWNS },
  { "swiftness", "swift", POS_STANDING, do_SWIFTNESS    , 1, 0 },
  { "snoop"    , "sno"	, POS_DEAD    , do_snoop    , LVL_GOD, 0 },
  { "socials"  , "soc"	, POS_DEAD    , do_commands , 0, SCMD_SOCIALS },
  { "split"    , "spl"	, POS_SITTING , do_split    , 1, 0 },
  { "stand"    , "st"	, POS_RESTING , do_stand    , 0, 0 },
  { "steal"    , "stea"	, POS_STANDING, do_steal    , 1, 0 },
  { "camp"     , "cam"  , POS_STANDING, do_gen_tog  , 1, SCMD_CAMP },
  { "switch"   , "sw"	, POS_DEAD    , do_switch   , LVL_GRGOD, 0 },
  { "ssj"      , "ssj"  , POS_STANDING, do_ssj      , 1, 0 },
  { "transform" , "transfo" , POS_STANDING, do_transform , 1, 0 },
/* { "morph"    , "mor"  , POS_STANDING, do_morph    , 1, 0 }, */
  { "syslog"   , "sys"	, POS_DEAD    , do_syslog   , LVL_IMMORT, 0 },

  { "tedit"    , "ted"	, POS_DEAD    , do_tedit    , LVL_IMPL, 0 },
  { "tell"     , "tel"	, POS_DEAD    , do_tell     , 0, 0 },
  { "take"     , "ta"	, POS_RESTING , do_get      , 0, 0 },
  { "tailwhip" , "tail"	, POS_FIGHTING, do_tailwhip , 1, 0 },  
  { "taste"    , "tas"	, POS_RESTING , do_eat      , 0, SCMD_TASTE },
  { "teleport" , "tel"	, POS_DEAD    , do_teleport , LVL_GOD, 0 },
  { "thaw"     , "thaw"	, POS_DEAD    , do_wizutil  , LVL_FREEZE, SCMD_THAW },
  { "title"    , "tit"	, POS_DEAD    , do_title    , 0, 0 },
  { "time"     , "tim"	, POS_DEAD    , do_time     , 0, 0 },
  { "toggle"   , "tog"	, POS_DEAD    , do_toggle   , 0, 0 },
  { "sense"    , "sen"	, POS_STANDING, do_sense    , 0, 0 },
  { "transfer" , "tran"	, POS_SLEEPING, do_trans    , LVL_IMMORT, 0 },
  { "trigedit" , "trig"	, POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_TRIGEDIT},
  { "typo"     , "typ"	, POS_DEAD    , do_gen_write, 0, SCMD_TYPO },

  { "unlock"   , "unl"	, POS_SITTING , do_gen_door , 0, SCMD_UNLOCK },
  { "ungroup"  , "ung"	, POS_DEAD    , do_ungroup  , 0, 0 },
  { "unban"    , "unb"	, POS_DEAD    , do_unban    , LVL_GRGOD, 0 },
  { "unaffect" , "una"	, POS_DEAD    , do_wizutil  , LVL_GOD, SCMD_UNAFFECT },
  { "uptime"   , "upt"	, POS_DEAD    , do_date     , LVL_IMMORT, SCMD_UPTIME },
  { "use"      , "us"	, POS_SITTING , do_use      , 1, SCMD_USE },
  { "users"    , "user"	, POS_DEAD    , do_users    , LVL_IMMORT, 0 },

  { "value"    , "val"	, POS_STANDING, do_not_here , 0, 0 },
  { "visible"  , "vis"	, POS_RESTING , do_visible  , 1, 0 },
  { "vnum"     , "vnum"	, POS_DEAD    , do_vnum     , LVL_IMMORT, 0 },
  { "vstat"    , "vsta"	, POS_DEAD    , do_vstat    , LVL_IMMORT, 0 },

  { "wake"     , "wak"	, POS_SLEEPING, do_wake     , 0, 0 },
  { "wave"     , "wav"	, POS_RESTING , do_action   , 0, 0 },
  { "wear"     , "wea"	, POS_RESTING , do_wear     , 0, 0 },
  { "weather"  , "weat" , POS_RESTING , do_weather  , 0, 0 },
  { "who"      , "who"	, POS_DEAD    , do_who      , 0, 0 },
  { "finger"   , "fin"	, POS_DEAD    , do_finger   , 0, 0 },
  { "whoami"   , "whoa"	, POS_DEAD    , do_gen_ps   , 0, SCMD_WHOAMI },
  { "where"    , "whe"	, POS_RESTING , do_where    , 1, 0 },
  { "whisper"  , "whis"	, POS_RESTING , do_spec_comm, 0, SCMD_WHISPER },
  { "wield"    , "wie"	, POS_RESTING , do_wield    , 0, 0 },
  { "wimpy"    , "wim"	, POS_DEAD    , do_wimpy    , 0, 0 },
  { "withdraw" , "with"	, POS_STANDING, do_not_here , 1, 0 },
  { "wiznet"   , "wiz"	, POS_DEAD    , do_wiznet   , LVL_IMMORT, 0 },
  { ";"        , ";"	, POS_DEAD    , do_wiznet   , LVL_IMMORT, 0 },
  { "wizhelp"  , "wizh"	, POS_SLEEPING, do_commands , LVL_IMMORT, SCMD_WIZHELP },
  { "wizlist"  , "wizl"	, POS_DEAD    , do_gen_ps   , 0, SCMD_WIZLIST },
  { "wizlock"  , "wizlo", POS_DEAD    , do_wizlock  , LVL_IMPL, 0 },
  { "write"    , "wr"	, POS_STANDING, do_write    , 1, 0 },

  { "zedit"    , "zed"	, POS_DEAD    , do_olc      , LVL_IMMORT, SCMD_OLC_ZEDIT},
  { "zreset"   , "zre"	, POS_DEAD    , do_zreset   , LVL_IMMORT, 0 },


  /* DG trigger commands */
  { "attach"   , "att"	, POS_DEAD    , do_attach   , LVL_IMPL, 0 },
  { "detach"   , "det"	, POS_DEAD    , do_detach   , LVL_IMPL, 0 },
  { "tlist"    , "tli"	, POS_DEAD    , do_tlist    , LVL_GOD, 0 },
  { "tstat"    , "tst"	, POS_DEAD    , do_tstat    , LVL_GOD, 0 },
  { "masound"  , "masound"	, POS_DEAD    , do_masound  , 0, 0 },
  { "mkill"    , "mkill"	, POS_STANDING, do_mkill    , 0, 0 },
  { "mjunk"    , "mjunk"	, POS_SITTING , do_mjunk    , 0, 0 },
  { "mecho"    , "mecho"	, POS_DEAD    , do_mecho    , 0, 0 },
  { "mechoaround", "mechoaround",POS_DEAD , do_mechoaround    , 0, 0 },
  { "msend"    , "msend"	, POS_DEAD    , do_msend    , 0, 0 },
  { "mload"    , "mload"	, POS_DEAD    , do_mload    , 0, 0 },
  { "mpurge"   , "mpurge"	, POS_DEAD    , do_mpurge    , 0, 0 },
  { "mgoto"    , "mgoto"	, POS_DEAD    , do_mgoto    , 0, 0 },
  { "mat"      , "mat"		, POS_DEAD    , do_mat      , 0, 0 },
  { "mteleport", "mteleport"	, POS_DEAD    , do_mteleport, 0, 0 },
  { "mforce"   , "mforce"	, POS_DEAD    , do_mforce   , 0, 0 },
  { "mexp"     , "mexp"		, POS_DEAD    , do_mexp     , 0, 0 },
  { "mgold"    , "mgold"	, POS_DEAD    , do_mgold    , 0, 0 },
  { "mhunt"    , "mhunt"	, POS_DEAD    , do_mhunt    , 0, 0 },
  { "mremember", "mremember"	, POS_DEAD    , do_mremember, 0, 0 },
  { "mforget"  , "mforget"	, POS_DEAD    , do_mforget  , 0, 0 },
  { "mtransform","mtransform"	, POS_DEAD    , do_mtransform, 0, 0 },


  { "\n", "zzzzzzz", 0, 0, 0, 0 } };	/* this must be last */


const char *fill[] =
{
  "in",
  "from",
  "with",
  "the",
  "on",
  "at",
  "to",
  "\n"
};

const char *reserved[] =
{
  "a",
  "an",
  "self",
  "me",
  "all",
  "room",
  "someone",
  "something",
  "\n"
};

/*
 * This is the actual command interpreter called from game_loop() in comm.c
 * It makes sure you are the proper level and position to execute the command,
 * then calls the appropriate function.
 */
void command_interpreter(struct char_data *ch, char *argument)
{
  int cmd, length;
  char *line;

  REMOVE_BIT(AFF_FLAGS(ch), AFF_HIDE);

  /* just drop to next line for hitting CR */
  skip_spaces(&argument);
  if (!*argument)
    return;

  if (!isalpha(*argument)) {
    arg[0] = argument[0];
    arg[1] = '\0';
    line = argument + 1;
  } else
    line = any_one_arg(argument, arg);

  /* otherwise, find the command */
  if ((GET_LEVEL(ch)<LVL_IMMORT) &&
      (command_wtrigger(ch, arg, line) ||
       command_mtrigger(ch, arg, line) ||
       command_otrigger(ch, arg, line)))
    return; /* command trigger took over */

  for (length = strlen(arg), cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++)
    if (!strncmp(complete_cmd_info[cmd].command, arg, length))
      if (GET_LEVEL(ch) >= complete_cmd_info[cmd].minimum_level)
	break;

  if (*complete_cmd_info[cmd].command == '\n')
    send_to_char("Huh?!?\r\n", ch);
  else if (PLR_FLAGGED(ch, PLR_FROZEN) && GET_LEVEL(ch) < LVL_IMPL)
    send_to_char("You try, but the mind-numbing cold prevents you...\r\n", ch);
/*  else if (complete_cmd_info[cmd].command_pointer == NULL)
send_to_char("Sorry, that command hasn't been implemented yet.\r\n", ch);*/
  else if (IS_NPC(ch) && complete_cmd_info[cmd].minimum_level >= LVL_IMMORT)
    send_to_char("You can't use immortal commands while switched.\r\n", ch);
  else if (GET_POS(ch) < complete_cmd_info[cmd].minimum_position)
    switch (GET_POS(ch)) {
    case POS_DEAD:
      send_to_char("Lie still; you are DEAD!!! :-(\r\n", ch);
      break;
    case POS_INCAP:
    case POS_MORTALLYW:
      send_to_char("You are in a pretty bad shape, unable to do anything!\r\n", ch);
      break;
    case POS_STUNNED:
      send_to_char("All you can do right now is think about the stars!\r\n", ch);
      break;
    case POS_SLEEPING:
      send_to_char("In your dreams, or what?\r\n", ch);
      break;
    case POS_RESTING:
      send_to_char("Nah... You feel too relaxed to do that..\r\n", ch);
      break;
    case POS_SITTING:
      send_to_char("Maybe you should get on your feet first?\r\n", ch);
      break;
    case POS_FIGHTING:
      send_to_char("No way!  You're fighting for your life!\r\n", ch);
      break;
  } else if (no_specials || !special(ch, cmd, line))
    ((*complete_cmd_info[cmd].command_pointer) (ch, line, cmd, complete_cmd_info[cmd].subcmd));
}

/**************************************************************************
 * Routines to handle aliasing                                             *
  **************************************************************************/


struct alias *find_alias(struct alias *alias_list, char *str)
{
  while (alias_list != NULL) {
    if (*str == *alias_list->alias)	/* hey, every little bit counts :-) */
      if (!strcmp(str, alias_list->alias))
	return alias_list;

    alias_list = alias_list->next;
  }

  return NULL;
}


void free_alias(struct alias *a)
{
  if (a->alias)
    free(a->alias);
  if (a->replacement)
    free(a->replacement);
  free(a);
}


/* The interface to the outside world: do_alias */
ACMD(do_alias)
{
  char *repl;
  struct alias *a, *temp;

  if (IS_NPC(ch))
    return;

  repl = any_one_arg(argument, arg);

  if (!*arg) {			/* no argument specified -- list currently defined aliases */
    send_to_char("Currently defined aliases:\r\n", ch);
    if ((a = GET_ALIASES(ch)) == NULL)
      send_to_char(" None.\r\n", ch);
    else {
      while (a != NULL) {
	sprintf(buf, "%-15s %s\r\n", a->alias, a->replacement);
	send_to_char(buf, ch);
	a = a->next;
      }
    }
  } else {			/* otherwise, add or remove aliases */
    /* is this an alias we've already defined? */
    if ((a = find_alias(GET_ALIASES(ch), arg)) != NULL) {
      REMOVE_FROM_LIST(a, GET_ALIASES(ch), next);
      free_alias(a);
    }
    /* if no replacement string is specified, assume we want to delete */
    if (!*repl) {
      if (a == NULL)
	send_to_char("No such alias.\r\n", ch);
      else
	send_to_char("Alias deleted.\r\n", ch);
    } else {			/* otherwise, either add or redefine an alias */
      if (!str_cmp(arg, "alias")) {
	send_to_char("You can't alias 'alias'.\r\n", ch);
	return;
      }
      CREATE(a, struct alias, 1);
      a->alias = str_dup(arg);
      delete_doubledollar(repl);
      a->replacement = str_dup(repl);
      if (strchr(repl, ALIAS_SEP_CHAR) || strchr(repl, ALIAS_VAR_CHAR))
	a->type = ALIAS_COMPLEX;
      else
	a->type = ALIAS_SIMPLE;
      a->next = GET_ALIASES(ch);
      GET_ALIASES(ch) = a;
      send_to_char("Alias added.\r\n", ch);
    }
  }
}

/*
 * Valid numeric replacements are only $1 .. $9 (makes parsing a little
 * easier, and it's not that much of a limitation anyway.)  Also valid
 * is "$*", which stands for the entire original line after the alias.
 * ";" is used to delimit commands.
 */
#define NUM_TOKENS       9

void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias *a)
{
  struct txt_q temp_queue;
  char *tokens[NUM_TOKENS], *temp, *write_point;
  int num_of_tokens = 0, num;

  /* First, parse the original string */
  temp = strtok(strcpy(buf2, orig), " ");
  while (temp != NULL && num_of_tokens < NUM_TOKENS) {
    tokens[num_of_tokens++] = temp;
    temp = strtok(NULL, " ");
  }

  /* initialize */
  write_point = buf;
  temp_queue.head = temp_queue.tail = NULL;

  /* now parse the alias */
  for (temp = a->replacement; *temp; temp++) {
    if (*temp == ALIAS_SEP_CHAR) {
      *write_point = '\0';
      buf[MAX_INPUT_LENGTH - 1] = '\0';
      write_to_q(buf, &temp_queue, 1);
      write_point = buf;
    } else if (*temp == ALIAS_VAR_CHAR) {
      temp++;
      if ((num = *temp - '1') < num_of_tokens && num >= 0) {
	strcpy(write_point, tokens[num]);
	write_point += strlen(tokens[num]);
      } else if (*temp == ALIAS_GLOB_CHAR) {
	strcpy(write_point, orig);
	write_point += strlen(orig);
      } else if ((*(write_point++) = *temp) == '$')	/* redouble $ for act safety */
	*(write_point++) = '$';
    } else
      *(write_point++) = *temp;
  }

  *write_point = '\0';
  buf[MAX_INPUT_LENGTH - 1] = '\0';
  write_to_q(buf, &temp_queue, 1);

  /* push our temp_queue on to the _front_ of the input queue */
  if (input_q->head == NULL)
    *input_q = temp_queue;
  else {
    temp_queue.tail->next = input_q->head;
    input_q->head = temp_queue.head;
  }
}


/*
 * Given a character and a string, perform alias replacement on it.
 *
 * Return values:
 *   0: String was modified in place; call command_interpreter immediately.
 *   1: String was _not_ modified in place; rather, the expanded aliases
 *      have been placed at the front of the character's input queue.
 */
int perform_alias(struct descriptor_data *d, char *orig)
{
  char first_arg[MAX_INPUT_LENGTH], *ptr;
  struct alias *a, *tmp;

  /* Mobs don't have alaises. */
  if (IS_NPC(d->character))
    return 0;

  /* bail out immediately if the guy doesn't have any aliases */
  if ((tmp = GET_ALIASES(d->character)) == NULL)
    return 0;

  /* find the alias we're supposed to match */
  ptr = any_one_arg(orig, first_arg);

  /* bail out if it's null */
  if (!*first_arg)
    return 0;

  /* if the first arg is not an alias, return without doing anything */
  if ((a = find_alias(tmp, first_arg)) == NULL)
    return 0;

  if (a->type == ALIAS_SIMPLE) {
    strcpy(orig, a->replacement);
    return 0;
  } else {
    perform_complex_alias(&d->input, ptr, a);
    return 1;
  }
}



/***************************************************************************
 * Various other parsing utilities                                         *
 **************************************************************************/

/*
 * searches an array of strings for a target string.  "exact" can be
 * 0 or non-0, depending on whether or not the match must be exact for
 * it to be returned.  Returns -1 if not found; 0..n otherwise.  Array
 * must be terminated with a '\n' so it knows to stop searching.
 */
int search_block(char *arg, const char **list, int exact)
{
  register int i, l;

  /* Make into lower case, and get length of string */
  for (l = 0; *(arg + l); l++)
    *(arg + l) = LOWER(*(arg + l));

  if (exact) {
    for (i = 0; **(list + i) != '\n'; i++)
      if (!strcmp(arg, *(list + i)))
	return (i);
  } else {
    if (!l)
      l = 1;			/* Avoid "" to match the first available
				 * string */
    for (i = 0; **(list + i) != '\n'; i++)
      if (!strncmp(arg, *(list + i), l))
	return (i);
  }

  return -1;
}


int is_number(const char *str)
{
  while (*str)
    if (!isdigit(*(str++)))
      return 0;

  return 1;
}

/*
 * Function to skip over the leading spaces of a string.
 */
void skip_spaces(char **string)
{
  for (; **string && isspace(**string); (*string)++);
}


/*
 * Given a string, change all instances of double dollar signs ($$) to
 * single dollar signs ($).  When strings come in, all $'s are changed
 * to $$'s to avoid having users be able to crash the system if the
 * inputted string is eventually sent to act().  If you are using user
 * input to produce screen output AND YOU ARE SURE IT WILL NOT BE SENT
 * THROUGH THE act() FUNCTION (i.e., do_gecho, do_title, but NOT do_say),
 * you can call delete_doubledollar() to make the output look correct.
 *
 * Modifies the string in-place.
 */
char *delete_doubledollar(char *string)
{
  char *read, *write;

  /* If the string has no dollar signs, return immediately */
  if ((write = strchr(string, '$')) == NULL)
    return string;

  /* Start from the location of the first dollar sign */
  read = write;


  while (*read)   /* Until we reach the end of the string... */
    if ((*(write++) = *(read++)) == '$') /* copy one char */
      if (*read == '$')
	read++; /* skip if we saw 2 $'s in a row */

  *write = '\0';

  return string;
}


int fill_word(char *argument)
{
  return (search_block(argument, fill, TRUE) >= 0);
}


int reserved_word(char *argument)
{
  return (search_block(argument, reserved, TRUE) >= 0);
}


/*
 * copy the first non-fill-word, space-delimited argument of 'argument'
 * to 'first_arg'; return a pointer to the remainder of the string.
 */
char *one_argument(char *argument, char *first_arg)
{
  char *begin = first_arg;

  if (!argument) {
    log("SYSERR: one_argument received a NULL pointer!");
    *first_arg = '\0';
    return NULL;
  }

  do {
    skip_spaces(&argument);

    first_arg = begin;
    while (*argument && !isspace(*argument)) {
      *(first_arg++) = LOWER(*argument);
      argument++;
    }

    *first_arg = '\0';
  } while (fill_word(begin));

  return argument;
}


/*
 * one_word is like one_argument, except that words in quotes ("") are
 * considered one word.
 */
char *one_word(char *argument, char *first_arg)
{
  char *begin = first_arg;

  do {
    skip_spaces(&argument);

    first_arg = begin;

    if (*argument == '\"') {
      argument++;
      while (*argument && *argument != '\"') {
        *(first_arg++) = LOWER(*argument);
        argument++;
      }
      argument++;
    } else {
      while (*argument && !isspace(*argument)) {
        *(first_arg++) = LOWER(*argument);
        argument++;
      }
    }

    *first_arg = '\0';
  } while (fill_word(begin));

  return argument;
}


/* same as one_argument except that it doesn't ignore fill words */
char *any_one_arg(char *argument, char *first_arg)
{
  skip_spaces(&argument);

  while (*argument && !isspace(*argument)) {
    *(first_arg++) = LOWER(*argument);
    argument++;
  }

  *first_arg = '\0';

  return argument;
}


/*
 * Same as one_argument except that it takes two args and returns the rest;
 * ignores fill words
 */
char *two_arguments(char *argument, char *first_arg, char *second_arg)
{
  return one_argument(one_argument(argument, first_arg), second_arg); /* :-) */
}



/*
 * determine if a given string is an abbreviation of another
 * (now works symmetrically -- JE 7/25/94)
 *
 * that was dumb.  it shouldn't be symmetrical.  JE 5/1/95
 * 
 * returnss 1 if arg1 is an abbreviation of arg2
 */
int is_abbrev(const char *arg1, const char *arg2)
{
  if (!*arg1)
    return 0;

  for (; *arg1 && *arg2; arg1++, arg2++)
    if (LOWER(*arg1) != LOWER(*arg2))