untermud/DOC/
untermud/DOC/U/
untermud/DOC/U/U-examples/
untermud/DOC/internals/
untermud/DOC/wizard/
untermud/MISC/
untermud/MISC/dbchk/
untermud/RWHO/
untermud/RWHO/rwhod/
/*
    Copyright (C) 1991, Marcus J. Ranum. All rights reserved.
*/

/* configure all options BEFORE including system stuff. */
#include    "config.h"
#include    "mud.h"
#include    "match.h"



/* ARGSUSED */
int cmd_which (int ac, char *av[], char *who, char *aswho)
{
  char ob[MAXOID];
  int flg;

  flg = MTCH_MEOK | MTCH_WHICH | MTCH_NONLOC | MTCH_QUIET;

  if (ac == 2) {
    flg = MTCH_MEOK | MTCH_WHICH | MTCH_NONLOC | MTCH_QUIET;
    if (matchlocal (who, av[1], ut_loc (who), flg, ob) == 0)
      say (who, "Matched: ", ob, " (", ut_name (ob), ")\n", (char *) 0);
    else
      say (who, "Nothing matches \"", av[1], "\"\n", (char *) 0);
    return (UERR_NOMATCH);
  }

  if (ac > 2 && !strncmp (av[1], "object", strlen (av[1]))) {
    if (matchobjects (who, av[2], ut_loc (who), flg, ob) == 0)
      say (who, "Matched: ", ob, " (", ut_name (ob), ")\n", (char *) 0);
    else
      say (who, "Nothing matches \"", av[1], "\"\n", (char *) 0);
    return (UERR_NOMATCH);
  }

  if (ac > 2 && !strncmp (av[1], "player", strlen (av[1]))) {
    if (matchplayers (who, av[2], ut_loc (who), flg, ob) == 0)
      say (who, "Matched: ", ob, " (", ut_name (ob), ")\n", (char *) 0);
    else
      say (who, "Nobody matches \"", av[1], "\"\n", (char *) 0);
    return (UERR_NOMATCH);
  }

  if (ac > 2 && !strncmp (av[1], "exit", strlen (av[1]))) {
    if (matchexit (who, av[2], ut_loc (who), flg, ob) == 0)
      say (who, "Matched: ", ob, " (", ut_name (ob), ")\n", (char *) 0);
    else
      say (who, "No exit matches \"", av[1], "\"\n", (char *) 0);
    return (UERR_NOMATCH);
  }
  say (who, "Match what?\n", (char *) 0);
  return (UERR_BADPARM);
}