_if.c

umud/CMD/_if.c · 968 B

From the archive umud1.13.tar.gz

Download the archive   « Back to the archive contents

/*
	Copyright (C) 1991, Marcus J. Ranum. All rights reserved.
*/

#ifndef	lint
static	char	RCSid[] = "$Header: /usr/users/mjr/hacks/umud/CMD/RCS/_if.c,v 1.1 91/07/04 17:33:21 mjr Rel $";
#endif

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


#include	"mud.h"
#include	"sbuf.h"

/*
conditional
*/

/* ARGSUSED */
cmd__if(argc,argv,who,aswho)
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(1);
 	}
 
 	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(0);
}

Site Stats

Snippets: 1791
Codebases: 571