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    "sbuf.h"

/*
conditional
*/

/* ARGSUSED */
int cmd__if (int argc, char *argv[], char *who, char *aswho)
{
  Sbuf suf;

  sbuf_initstatic (&suf);

  if (bool_rewrite (who, argv[1], &suf)) {
    say (who, "Bad Boolean expression.\n", (char *) 0);
    sbuf_freestatic (&suf);
    return (UERR_SYNTAX);
  }

  if (bool_eval (who, ut_loc (run_actor ()), sbuf_buf (&suf), 0)) {
    sbuf_freestatic (&suf);
    return (run (who, aswho, argv[2], argc, argv, 0));
  }
  sbuf_freestatic (&suf);

  if (argc == 5 && !strcmp (argv[3], "else"))
    return (run (who, aswho, argv[4], argc, argv, 0));
  if (bool_eval (who, ut_loc (run_actor ()), argv[1], 0))
    return (run (who, aswho, argv[2], argc, argv, 0));
  return (UERR_NONE);
}