_if.c

untermud/CMD/_if.c · 908 B

From the archive untermud-2.4-r22.tar.gz

Download the archive   « Back to the archive contents

/*
    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);
}

Site Stats

Snippets: 1791
Codebases: 571