~ubuntu-branches/ubuntu/utopic/tinymux/utopic

« back to all changes in this revision

Viewing changes to src/boolexp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ervin Hearn III
  • Date: 2008-04-11 23:18:25 UTC
  • mfrom: (1.1.5 upstream) (6.1.1 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080411231825-1pq4trckagyk8roo
Tags: 2.6.5.27-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// boolexp.cpp
2
 
//
3
 
// $Id: boolexp.cpp,v 1.18 2006/01/08 04:28:44 sdennis Exp $
4
 
//
 
1
/*! \file boolexp.cpp
 
2
 *  Boolean Expressions for @locks
 
3
 *
 
4
 * $Id: boolexp.cpp 3182 2008-01-18 08:01:21Z brazilofmux $
 
5
 *
 
6
 * The functions here evaluate and organize boolean expressions used in
 
7
 * locks.  Lock evaluation contains one of server's the three parsers.  The
 
8
 * other two parsers are for functions (see eval.cpp) and commands (see
 
9
 * command.cpp).
 
10
 */
 
11
 
5
12
#include "copyright.h"
6
13
#include "autoconf.h"
7
14
#include "config.h"
110
117
                STARTLOG(LOG_BUGS, "BUG", "LOCK");
111
118
                log_name_and_loc(player);
112
119
                buff = alloc_mbuf("eval_boolexp.LOG.indir");
113
 
                sprintf(buff, ": Lock had bad indirection (%c, type %d)",
 
120
                mux_sprintf(buff, MBUF_SIZE, ": Lock had bad indirection (%c, type %d)",
114
121
                    INDIR_TOKEN, b->sub1->type);
115
122
                log_text(buff);
116
123
                free_mbuf(buff);
183
190
        {
184
191
            bCheck = true;
185
192
        }
 
193
 
186
194
        if (bCheck)
187
195
        {
188
 
            char **preserve = NULL;
189
 
            int *preserve_len = NULL;
190
 
            preserve = PushPointers(MAX_GLOBAL_REGS);
191
 
            preserve_len = PushIntegers(MAX_GLOBAL_REGS);
192
 
            save_global_regs("eval_boolexp_save", preserve, preserve_len);
 
196
            reg_ref **preserve = NULL;
 
197
            preserve = PushRegisters(MAX_GLOBAL_REGS);
 
198
            save_global_regs(preserve);
193
199
 
194
200
            buff2 = bp = alloc_lbuf("eval_boolexp");
195
201
            str = buff;
196
202
            mux_exec(buff2, &bp, source, player, player,
197
 
                EV_FIGNORE | EV_EVAL | EV_FCHECK | EV_TOP, &str,
198
 
                (char **)NULL, 0);
 
203
                AttrTrace(aflags, EV_FIGNORE|EV_EVAL|EV_FCHECK|EV_TOP), &str,
 
204
                NULL, 0);
199
205
            *bp = '\0';
200
206
 
201
 
            restore_global_regs("eval_boolexp_save", preserve, preserve_len);
202
 
            PopIntegers(preserve_len, MAX_GLOBAL_REGS);
203
 
            PopPointers(preserve, MAX_GLOBAL_REGS);
 
207
            restore_global_regs(preserve);
 
208
            PopRegisters(preserve, MAX_GLOBAL_REGS);
204
209
 
205
210
            bCheck = !string_compare(buff2, (char *)b->sub1);
206
211
            free_lbuf(buff2);
307
312
    boolexp_type locktype;
308
313
 
309
314
    char *buff = alloc_lbuf("test_atr");
310
 
    strcpy(buff, s);
 
315
    mux_strncpy(buff, s, LBUF_SIZE-1);
311
316
    for (s = buff; *s && (*s != ':') && (*s != '/'); s++)
312
317
    {
313
318
        ; // Nothing.
691
696
 
692
697
BOOLEXP *parse_boolexp(dbref player, const char *buf, bool internal)
693
698
{
 
699
    if (  NULL == buf
 
700
       || '\0' == buf[0])
 
701
    {
 
702
        return TRUE_BOOLEXP;
 
703
    }
 
704
 
694
705
    size_t n = strlen(buf);
695
706
    if (n > sizeof(parsestore)-1)
696
707
    {
699
710
    memcpy(parsestore, buf, n+1);
700
711
    parsebuf = parsestore;
701
712
    parse_player = player;
702
 
    if (  buf == NULL
703
 
       || *buf == '\0')
704
 
    {
705
 
        return TRUE_BOOLEXP;
706
 
    }
707
713
    if (!mudstate.bStandAlone)
708
714
    {
709
715
        parsing_internal = internal;