/* Copyright (C) 1991, Marcus J. Ranum. All rights reserved. */ /* configure all options BEFORE including system stuff. */ #include "config.h" #include "mud.h" #include "vars.h" static void act_subs (char *who, char *aswho, int ac, char *av[], char *in, char *out, size_t size) { char vbl[MAXVLEN]; int vl; while (*in && (size > 1)) { if (*in == '$') { /* A variable! */ if (*(++in) == '$') { /* $$ -> $ */ *out++ = *in++; size--; continue; } if (*in == '{') { /* ${var} */ in++; for (vl = 0; *in != '}' && *in && vl < (int) sizeof (vbl) - 2; vl++) vbl[vl] = *in++; vbl[vl] = '\0'; if (*in == '}') in++; (void) vresolve (vbl, who, aswho, ac, av, &out, &size); continue; } /* $var format */ for (vl = 0; *in != '\0' && vl < (int) sizeof (vbl) - 2 && (isalpha (*in) || isdigit (*in) || *in == '.' || *in == '_' || *in == '+' || *in == '*'); vl++) vbl[vl] = *in++; vbl[vl] = '\0'; (void) vresolve (vbl, who, aswho, ac, av, &out, &size); } else { *out++ = *in++; size--; } } *out++ = '\0'; } /* */ int activate (int flg, char *who, char *what, char *where, char *actvar, int argc, char *argv[]) { Obj *op; char *ap; if ((op = cache_get (what)) == (Obj *) 0) return (0); /* get named attribute */ if ((ap = objattr (op, actvar, (int *) 0)) == (char *) 0) return (0); /* if it is a string, just echo it normally */ if (attistype (ap, typ_str)) { char *excp = (char *) 0; char work[MUDBUF]; if ((ap = attdata (ap)) == (char *) 0) return (0); act_subs (what, what, argc, argv, ap, work, sizeof (work)); if (flg == ACTIV_PONLY) { say (who, work, "\n", (char *) 0); return (1); } /* if the player is to be excluded set flag for broadcast */ if (flg == ACTIV_ECAST) excp = who; ut_roombcast (where, excp, ut_name (who), " ", work, "\n", (char *) 0); return (1); } /* if it is a command, call it with faked-up values */ if (attistype (ap, typ_cmd)) { if ((ap = attdata (ap)) == (char *) 0) return (0); /* do IT! */ (void) run (who, what, ap, argc, argv, 0); return (1); } /* if it is U code .. */ if (attistype (ap, typ_u)) { if ((ap = attdata (ap)) == (char *) 0) return (0); parser_setinput (ap); if (parser_compile (who)) (void) parser_run (who, what, argc, argv); return (1); } /* huh? */ return (0); }