int re_subpatterns; /**< The number of re subpatterns */
int *re_offsets; /**< The offsets for the subpatterns */
char *re_from; /**< The positions of the subpatterns */
+ HASHTAB namedregs;
+ HASHTAB namedregsnxt;
};
typedef struct eval_context EVAL_CONTEXT;
extern void shutdown_queues(void);
extern void do_hourly(void);
+extern void init_namedregs(HASHTAB *);
+extern void free_namedregs(HASHTAB *);
+extern void clear_namedregs(HASHTAB *);
+extern void copy_namedregs(HASHTAB *, HASHTAB *);
+extern void set_namedreg(HASHTAB *, const char *, const char *);
+extern const char *get_namedreg(HASHTAB *, const char *);
+
/* From create.c */
extern dbref do_dig(dbref player, const char *name, char **argv, int tport);
global_eval_context.wenv[j] = (char *) NULL;
for (j = 0; j < NUMQ; j++)
global_eval_context.renv[j][0] = '\0';
+ clear_namedregs(&global_eval_context.namedregs);
global_eval_context.process_command_port = d->descriptor;
process_command(d->player, command, d->player, d->player, 1);
global_eval_context.wnxt[j] = NULL;
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = NULL;
+ clear_namedregs(&global_eval_context.namedregsnxt);
strcpy(global_eval_context.ccom, "");
/* do the person's personal connect action */
global_eval_context.wnxt[j] = NULL;
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = NULL;
+ clear_namedregs(&global_eval_context.namedregsnxt);
/* Setup all connect information as info to pass */
(void) queue_attribute(player, "ADISCONNECT", player);
#endif
char fqueued; /**< function inserted into queue */
enum qid_flags qid; /**< queue identification # */
+ HASHTAB namedregs;
} BQUE;
static BQUE *qfirst = NULL, *qlast = NULL, *qwait = NULL;
if (point->rval[a]) {
mush_free((Malloc_t) point->rval[a], "bqueue_rval");
}
+ free_namedregs(&point->namedregs);
if (point->semattr)
mush_free((Malloc_t) point->semattr, "bqueue_semattr");
if (point->comm)
char *val_rnxt[NUMQ];
char *preserves[10];
char *preserveq[NUMQ];
+ HASHTAB preserve_namedregs;
save_global_nxt("pay_queue_save", preserve_wnxt, preserve_rnxt, val_wnxt,
val_rnxt);
save_global_regs("pay_queue_save", preserveq);
save_global_env("pay_queue_save", preserves);
+ init_namedregs(&preserve_namedregs);
+ copy_namedregs(&preserve_namedregs, &global_eval_context.namedregs);
+ clear_namedregs(&global_eval_context.namedregs);
notify_format(Owner(player),
T("GAME: Object %s(%s) lost a %s to queue loss."),
Name(player), unparse_dbref(player), MONEY);
+ copy_namedregs(&global_eval_context.namedregs, &preserve_namedregs);
+ free_namedregs(&preserve_namedregs);
restore_global_regs("pay_queue_save", preserveq);
restore_global_env("pay_queue_save", preserves);
restore_global_nxt("pay_queue_save", preserve_wnxt, preserve_rnxt, val_wnxt,
else {
tmp->rval[a] = mush_strdup(global_eval_context.rnxt[a], "bqueue_rval");
}
+ init_namedregs(&tmp->namedregs);
+ copy_namedregs(&tmp->namedregs, &global_eval_context.namedregs);
if (IsPlayer(cause)) {
if (qlast) {
else {
tmp->rval[a] = mush_strdup(global_eval_context.rnxt[a], "bqueue_rval");
}
+ init_namedregs(&tmp->namedregs);
+ copy_namedregs(&tmp->namedregs, &global_eval_context.namedregs);
if (IsPlayer(player)) {
if (qlast) {
qlast->next = tmp;
tmp->rval[a] = mush_strdup(global_eval_context.rnxt[a], "bqueue_rval");
}
}
+ init_namedregs(&tmp->namedregs);
+ copy_namedregs(&tmp->namedregs, &global_eval_context.namedregs);
if (until) {
tmp->left = wait;
else
global_eval_context.renv[a][0] = '\0';
}
+ copy_namedregs(&global_eval_context.namedregs, &entry->namedregs);
global_eval_context.process_command_port = 0;
s = entry->comm;
global_eval_context.break_called = 0;
global_eval_context.wnxt[j] = global_eval_context.wenv[j];
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = global_eval_context.renv[j];
+ copy_namedregs(&global_eval_context.namedregsnxt, &global_eval_context.namedregs);
arg2 = strip_braces(cmd);
if (is_strict_integer(arg1)) {
global_eval_context.wnxt[j] = global_eval_context.wenv[j];
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = global_eval_context.renv[j];
+ copy_namedregs(&global_eval_context.namedregsnxt, &global_eval_context.namedregs);
parse_que(player, ncom, player);
}
}
shutdown_a_queue(&qlfirst, &qllast);
shutdown_a_queue(&qsemfirst, &qsemlast);
shutdown_a_queue(&qwait, NULL);
+ free_namedregs(&global_eval_context.namedregs);
+ free_namedregs(&global_eval_context.namedregsnxt);
}
}
}
+void init_namedregs(HASHTAB *regs) {
+ hashinit(regs, 16, sizeof(char *));
+}
+
+void free_namedregs(HASHTAB *regs) {
+ clear_namedregs(regs);
+ hashfree(regs);
+}
+
+void clear_namedregs(HASHTAB *regs) {
+ char *value;
+
+ for(value = (char *) hash_firstentry(regs); value; value = (char *) hash_nextentry(regs))
+ mush_free(value, "namedreg");
+
+ hashflush(regs, 16);
+}
+
+void copy_namedregs(HASHTAB *dest, HASHTAB *src) {
+ char *key;
+
+ for(key = hash_firstentry(src); key; key = hash_nextentry_key(src))
+ set_namedreg(dest, key, get_namedreg(src, key));
+}
+
+void set_namedreg(HASHTAB *regs, const char *name, const char *value) {
+ char *key;
+ char *oldvalue;
+
+ key = strupper(name);
+
+ oldvalue = (char *) hashfind(key, regs);
+ if(oldvalue) {
+ mush_free(oldvalue, "namedreg");
+ hashdelete(key, regs);
+ }
+
+ hashadd(key, mush_strdup(value, "namedreg"), regs);
+}
+
+const char *get_namedreg(HASHTAB *regs, const char *name) {
+ char *key;
+ char *value;
+
+ key = strupper(name);
+
+ value = (char *) hashfind(key, regs);
+
+ if(value)
+ return value;
+
+ return "";
+}
+
FUNCTION(fun_wait) {
char tbuf[BUFFER_LEN], *tbp;
const char *p;
global_eval_context.wenv[j] = NULL;
for (j = 0; j < NUMQ; j++)
global_eval_context.renv[j][0] = '\0';
+ clear_namedregs(&global_eval_context.namedregs);
strcpy(arg, unparse_dbref(from));
global_eval_context.wenv[0] = arg;
strcpy(arg2, subject);
strcpy(global_eval_context.renv[qindex], args[n + 1]);
if (n == 0 && !strcmp(called_as, "SETR"))
safe_strl(args[n + 1], arglens[n + 1], buff, bp);
- } else
- safe_str(T("#-1 REGISTER OUT OF RANGE"), buff, bp);
+ } else {
+ if (*args[n] && !strpbrk(args[n], "|<>% \n\r\t")) {
+ set_namedreg(&global_eval_context.namedregs, args[n], args[n+1]);
+ if (n == 0 && !strcmp(called_as, "SETR"))
+ safe_strl(args[n + 1], arglens[n + 1], buff, bp);
+ } else {
+ safe_str(T("#-1 REGISTER OUT OF RANGE"), buff, bp);
+ }
+ }
}
}
((qindex = qreg_indexes[(unsigned char) args[0][0]]) != -1)
&& global_eval_context.renv[qindex])
safe_str(global_eval_context.renv[qindex], buff, bp);
+ else if (*args[0])
+ safe_str(get_namedreg(&global_eval_context.namedregs, args[0]), buff, bp);
else
safe_str(T("#-1 REGISTER OUT OF RANGE"), buff, bp);
}
global_eval_context.wnxt[j] = NULL;
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = NULL;
+ init_namedregs(&global_eval_context.namedregs);
+ init_namedregs(&global_eval_context.namedregsnxt);
/* Initialize the regexp patterns to nothing */
global_eval_context.re_code = NULL;
global_eval_context.renv[a][0] = '\0';
global_eval_context.rnxt[a] = NULL;
}
+ clear_namedregs(&global_eval_context.namedregs);
+ clear_namedregs(&global_eval_context.namedregsnxt);
/* set MUSH start time */
globals.start_time = time((time_t *) 0);
global_eval_context.wnxt[j] = global_eval_context.wenv[j];
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = global_eval_context.renv[j];
+ copy_namedregs(&global_eval_context.namedregsnxt, &global_eval_context.namedregs);
bp = outbuf;
if (flags & DOL_DELIM)
list += 2;
}
for (j = 0; j < NUMQ; j++)
global_eval_context.renv[j][0] = '\0';
+ clear_namedregs(&global_eval_context.namedregs);
bp = arg;
DOLIST(thing, Exits(loc)) {
if (((Light(loc) || Light(thing)) || !(Dark(loc) || Dark(thing)))
}
for (j = 0; j < NUMQ; j++)
global_eval_context.renv[j][0] = '\0';
+ clear_namedregs(&global_eval_context.namedregs);
bp = arg;
bp2 = arg2;
DOLIST(thing, Contents(loc)) {
for(j = 0; j < NUMQ ; j++)
global_eval_context.renv[j][0] = '\0';
+ clear_namedregs(&global_eval_context.namedregs);
bp = arg;
bp2 = arg2;
DOLIST(thing, Contents(player)) {
switch (savec) {
case 'Q':
case 'q':
+ savec = **str;
+ if (!savec)
+ goto exit_sequence;
+ safe_chr(savec, buff, bp);
+ (*str)++;
+ if (savec == '<') {
+ for (savec = **str; savec && savec != '>'; savec = **str) {
+ safe_chr(savec, buff, bp);
+ (*str)++;
+ }
+ if(!savec)
+ goto exit_sequence;
+ safe_chr(savec, buff, bp);
+ (*str)++;
+ }
+ break;
case 'V':
case 'v':
case 'W':
if (!nextc)
goto exit_sequence;
(*str)++;
- if ((qindex = qreg_indexes[(unsigned char) nextc]) == -1)
- break;
- if (global_eval_context.renv[qindex])
- safe_str(global_eval_context.renv[qindex], buff, bp);
+ if (nextc == '<') {
+ const char *tmp;
+ char regname[BUFFER_LEN];
+ for(tmp = *str; *tmp && *tmp != '>'; tmp++)
+ ;
+ if(!*tmp || tmp == *str) {
+ (*str)--;
+ goto exit_sequence;
+ }
+ strncpy(regname, *str, tmp - *str);
+ regname[tmp - *str] = '\0';
+ safe_str(get_namedreg(&global_eval_context.namedregs, regname), buff, bp);
+ *str = tmp + 1;
+ } else {
+ if ((qindex = qreg_indexes[(unsigned char) nextc]) == -1)
+ break;
+ if (global_eval_context.renv[qindex])
+ safe_str(global_eval_context.renv[qindex], buff, bp);
+ }
break;
case 'R':
case 'r': /* newline */
global_eval_context.wnxt[j] = myenv[j];
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = NULL;
+ clear_namedregs(&global_eval_context.namedregsnxt);
attribs_used = charge_action(player, thing, awhat) || attribs_used;
orator = preserve_orator;
return attribs_used;
global_eval_context.wnxt[a] = global_eval_context.wenv[a];
for (a = 0; a < NUMQ; a++)
global_eval_context.rnxt[a] = global_eval_context.renv[a];
+ copy_namedregs(&global_eval_context.namedregsnxt, &global_eval_context.namedregs);
/* now try a wild card match of buff with stuff in coms */
for (a = 1;
DESC *d;
int i, pflags = 0;
char buf[BUFFER_LEN], *bp;
+ char *key;
if (!arg_left) {
notify(player, "Invalid arguments.");
}
safe_chr('|', tbuf1, &tbp);
}
+ for(key = hash_firstentry_key(&global_eval_context.namedregs); key; key = hash_nextentry_key(&global_eval_context.namedregs)) {
+ safe_str(key, tbuf1, &tbp);
+ safe_chr('|', tbuf1, &tbp);
+ safe_str(get_namedreg(&global_eval_context.namedregs, key), tbuf1, &tbp);
+ safe_chr('|', tbuf1, &tbp);
+ }
tbp--;
*tbp = '\0';
dbref target, thing;
char pflags = 0x0;
int i;
+ char *key;
target = match_result(executor, args[0], TYPE_PLAYER, MAT_EVERYTHING);
if (!GoodObject(target) || !Connected(target)) {
}
safe_chr('|', tbuf1, &tbp);
}
+ for(key = hash_firstentry_key(&global_eval_context.namedregs); key; key = hash_nextentry_key(&global_eval_context.namedregs)) {
+ safe_str(key, tbuf1, &tbp);
+ safe_chr('|', tbuf1, &tbp);
+ safe_str(get_namedreg(&global_eval_context.namedregs, key), tbuf1, &tbp);
+ safe_chr('|', tbuf1, &tbp);
+ }
+
tbp--;
*tbp = '\0';
char *tbuf, *bp;
char *p_buf[NUMQ];
int rcnt, i;
+ char *key;
if (!strcmp(input, "IDLE"))
return 1;
strcpy(global_eval_context.renv[i], p_buf[i]);
global_eval_context.rnxt[i] = global_eval_context.renv[i];
}
+
+ for (; i < (rcnt - 1); i+= 2) {
+ if (p_buf[i] && strlen(p_buf[i]) > 0 && p_buf[i+1] && strlen(p_buf[i+1]) > 0) {
+ set_namedreg(&global_eval_context.namedregs, p_buf[i], p_buf[i+1]);
+ set_namedreg(&global_eval_context.namedregsnxt, p_buf[i], p_buf[i+1]);
+ }
+ }
}
strcpy(buf, atr_value(d->pinfo.atr));
global_eval_context.wnxt[0] = input;
}
safe_chr('|', buf, &bp);
}
+ for(key = hash_firstentry_key(&global_eval_context.namedregs); key; key = hash_nextentry_key(&global_eval_context.namedregs)) {
+ safe_str(key, buf, &bp);
+ safe_chr('|', buf, &bp);
+ safe_str(get_namedreg(&global_eval_context.namedregs, key), buf, &bp);
+ safe_chr('|', buf, &bp);
+ }
bp--;
*bp = '\0';
/* Now Save to XY_PROGENV */
}
for (j = 0; j < NUMQ; j++)
global_eval_context.renv[j][0] = '\0';
+ clear_namedregs(&global_eval_context.namedregs);
strcpy(arg, unparse_dbref(loc));
global_eval_context.wenv[0] = arg;
strcpy(arg2, defname);
global_eval_context.wnxt[j] = (char *) NULL;
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = (char *) NULL;
+ clear_namedregs(&global_eval_context.namedregsnxt);
return wild(s, d, 0, cs);
}
}
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = (char *) NULL;
+ clear_namedregs(&global_eval_context.namedregsnxt);
for (i = 0; (i < 10) && (i < NUMARGS); i++) {
pcre_copy_substring(d, offsets, subpatterns, i, wtmp[i], BUFFER_LEN);
global_eval_context.wnxt[j] = global_eval_context.wenv[j];
for (j = 0; j < NUMQ; j++)
global_eval_context.rnxt[j] = global_eval_context.renv[j];
+ copy_namedregs(&global_eval_context.namedregsnxt, &global_eval_context.namedregs);
if(ooref == NOTHING) {
ooref = player;
l = 1;