コード例 #1
0
/** Evaluate a lock.
 * Evaluate lock ltype on thing for player, passing dbrefs for %0/%1.
 * \param player dbref attempting to pass the lock.
 * \param thing object containing the lock.
 * \param ltype type of lock to check.
 * \retval 1 player passes the lock.
 * \retval 0 player does not pass the lock.
 */
int
eval_lock_with(dbref player, dbref thing, lock_type ltype, dbref env0,
	       dbref env1)
{
  char *myenv[10] = { NULL };
  char e0[SBUF_LEN], e1[SBUF_LEN], *ep;
  char *preserves[10];
  int result;

  if (env0 != NOTHING) {
    ep = e0;
    safe_dbref(env0, e0, &ep);
    *ep = '\0';
    myenv[0] = e0;
  }

  if (env1 != NOTHING) {
    ep = e1;
    safe_dbref(env1, e1, &ep);
    *ep = '\0';
    myenv[1] = e1;
  }

  save_global_env("eval_lock_save", preserves);
  restore_global_env("eval_lock", myenv);

  boolexp b = getlock(thing, ltype);
  log_activity(LA_LOCK, thing, unparse_boolexp(player, b, UB_DBREF));
  result = eval_boolexp(player, b, thing, NULL);
  restore_global_env("eval_lock_save", preserves);
  return result;
}
コード例 #2
0
ファイル: extract.c プロジェクト: GlowMUCK/GlowMUCK
void 
check_common(dbref obj)
{
    printf("\nObject %s\n", unparse_object(me, obj));
    printf("Name: %s\n", uncompress(DBFETCH(obj)->name));
    if (GETDESC(obj))
	printf("Desc: %s\n", uncompress(GETDESC(obj)));
    printf("Loc: #%s\n", unparse_object(me, DBFETCH(obj)->location));
    printf("Owner: #%d\n", unparse_object(me, DBFETCH(obj)->owner));
    printf("First contents: #%d\n", unparse_object(me, DBFETCH(obj)->contents));
    printf("Next item: #%d\n", unparse_object(me, DBFETCH(obj)->next));
    printf("Key: %s\n", unparse_boolexp(me, GETLOCK(obj)), 1);
    if (GETFAIL(obj))
	printf("Fail: %s\n", uncompress(GETFAIL(obj)));
    if (GETSUCC(obj))
	printf("Succ: %s\n", uncompress(GETSUCC(obj)));
    if (GETDROP(obj))
	printf("Drop: %s\n", uncompress(GETDROP(obj)));
    if (GETOFAIL(obj))
	printf("Ofail: %s\n", uncompress(GETOFAIL(obj)));
    if (GETOSUCC(obj))
	printf("Osucc: %s\n", uncompress(GETOSUCC(obj)));
    if (GETODROP(obj))
	printf("Odrop: %s\n", uncompress(GETODROP(obj)));
    printf("Properties:\n");
    check_properties("/", obj);
    printf("End of properties.\n");
}
コード例 #3
0
/** Evaluate a lock.
 * Evaluate lock ltype on thing for player.
 * \param player dbref attempting to pass the lock.
 * \param thing object containing the lock.
 * \param ltype type of lock to check.
 * \retval 1 player passes the lock.
 * \retval 0 player does not pass the lock.
 */
int
eval_lock(dbref player, dbref thing, lock_type ltype)
{
  boolexp b = getlock(thing, ltype);
  log_activity(LA_LOCK, thing, unparse_boolexp(player, b, UB_DBREF));
  if(Pass_Lock(player, thing) && IS_passlock_type(ltype))
    return 1;
  return eval_boolexp(player, getlock(thing, ltype), thing, NULL);
}
コード例 #4
0
ファイル: lock.c プロジェクト: MrWigggles/pennmush
/** Evaluate a lock.
 * Evaluate lock ltype on thing for player.
 * \param player dbref attempting to pass the lock.
 * \param thing object containing the lock.
 * \param ltype type of lock to check.
 * \param pe_info the pe_info to use when evaluating softcode in the lock
 * \retval 1 player passes the lock.
 * \retval 0 player does not pass the lock.
 */
int
eval_lock_with(dbref player, dbref thing, lock_type ltype, NEW_PE_INFO *pe_info)
{
  boolexp b = getlock(thing, ltype);
  /* Prevent overwriting a static buffer in unparse_boolexp() */
  if (!unparsing_boolexp)
    log_activity(LA_LOCK, thing, unparse_boolexp(player, b, UB_DBREF));
  return eval_boolexp(player, b, thing, pe_info);
}
コード例 #5
0
ファイル: property.c プロジェクト: CyberLeo/protomuck
char *
displayprop(dbref player, dbref obj, const char *name, char *buf)
{
    char mybuf[BUFFER_LEN], tbuf[BUFFER_LEN];
    int pdflag;
    PropPtr p = get_property(obj, name);

    if (!p) {
        sprintf(buf, SYSGLOOM "%s: No such property.", name);
        return buf;
    }
#ifdef DISKBASE
    propfetch(obj, p);
#endif
    pdflag = (PropDir(p) != NULL);
    sprintf(tbuf, "%.*s%c", (BUFFER_LEN / 4), name,
            (pdflag) ? PROPDIR_DELIMITER : '\0');
    tct(tbuf, mybuf);
    switch (PropType(p)) {
        case PROP_STRTYP:
            sprintf(buf, SYSAQUA "str " SYSGREEN "%s" SYSRED ":" SYSCYAN
                    "%.*s", mybuf, (BUFFER_LEN / 2),
                    tct(PropDataUNCStr(p), tbuf));
            break;
        case PROP_REFTYP:
            sprintf(buf, SYSBROWN "ref " SYSGREEN "%s" SYSRED ":%s", mybuf,
                    ansi_unparse_object(player, PropDataRef(p)));
            break;
        case PROP_INTTYP:
            sprintf(buf, SYSFOREST "int " SYSGREEN "%s" SYSRED ":" SYSYELLOW
                    "%d", mybuf, PropDataVal(p));
            break;
        case PROP_FLTTYP:
            sprintf(buf, SYSNAVY "flt " SYSGREEN "%s" SYSRED ":" SYSBROWN
                    "%.15g", mybuf, PropDataFVal(p));
            break;
        case PROP_LOKTYP:
            if (PropFlags(p) & PROP_ISUNLOADED) {
                sprintf(buf, SYSCRIMSON "lok " SYSGREEN "%s" SYSRED ":"
                        SYSPURPLE "*UNLOCKED*", mybuf);
            } else {
                sprintf(buf, SYSCRIMSON "lok " SYSGREEN "%s" SYSRED ":"
                        SYSPURPLE "%.*s", mybuf, (BUFFER_LEN / 2),
                        tct(unparse_boolexp(player, PropDataLok(p), 1), tbuf));
            }
            break;
        case PROP_DIRTYP:
            sprintf(buf, SYSWHITE "dir " SYSGREEN "%s" SYSRED ":", mybuf);
            break;
    }
    return buf;
}
コード例 #6
0
ファイル: p_misc.c プロジェクト: CyberLeo/protomuck
void 
prim_prettylock(PRIM_PROTOTYPE)
{
    const char *ptr;

    CHECKOP(1);
    oper1 = POP();		/* lock: lock */
    if (oper1->type != PROG_LOCK)
	abort_interp("Invalid argument");
    ptr = unparse_boolexp(ProgUID, oper1->data.lock, 1);
    CHECKOFLOW(1);
    CLEAR(oper1);
    PushString(ptr);
}
コード例 #7
0
ファイル: hsinterface.cpp プロジェクト: jrsteensen/hspace-old
HS_DBREF CHSInterface::GetLock(int objnum, HS_LOCKTYPE lock)
{
#ifdef PENNMUSH                 // No change in code between versions
    boolexp boolExp = getlock(objnum, Use_Lock);

    if (boolExp == TRUE_BOOLEXP)
    {
        return NOTHING;
    }
    else
    {
        return strtodbref(unparse_boolexp(objnum, boolExp, UB_DBREF));
    }
#endif

#if defined(TM3) || defined(MUX)
    char *value;
    BOOLEXP *key;
    int aowner, aflags;
    dbref lockobj;

#ifdef TM3
    int alen;
    value = atr_get((dbref) objnum, A_LUSE, &aowner, &aflags, &alen);
#else
    value = atr_get((dbref) objnum, A_LUSE, &aowner, &aflags);
#endif
    key = parse_boolexp((dbref) objnum, value, 1);
    free_lbuf(value);
    if (key == TRUE_BOOLEXP)
    {
        free_boolexp(key);
        return NOTHING;
    }
    else
    {
        lockobj = key->thing;
        free_boolexp(key);
        return lockobj;
    }
#endif
}
コード例 #8
0
ファイル: p_misc.c プロジェクト: CyberLeo/protomuck
void 
prim_unparselock(PRIM_PROTOTYPE)
{
    const char *ptr;

    CHECKOP(1);
    oper1 = POP();		/* lock: lock */
    if (oper1->type != PROG_LOCK)
	abort_interp("Invalid argument");
    if (oper1->data.lock != (struct boolexp *) TRUE_BOOLEXP) {
	ptr = unparse_boolexp(ProgUID, oper1->data.lock, 0);
    } else {
	ptr = NULL;
    }
    CHECKOFLOW(1);
    CLEAR(oper1);
    if (ptr) {
	PushString(ptr);
    } else {
	PushNullStr;
    }
}
コード例 #9
0
ファイル: disassem.c プロジェクト: GlowMUCK/GlowMUCK
void
disassemble(dbref player, dbref program)
{
    struct inst *curr;
    struct inst *codestart;
    int     i;
    char    buf[BUFFER_LEN];

    codestart = curr = DBFETCH(program)->sp.program.code;
    if (!DBFETCH(program)->sp.program.siz) {
	notify(player, "Nothing to disassemble!");
	return;
    }
    for (i = 0; i < DBFETCH(program)->sp.program.siz; i++, curr++) {
	switch (curr->type) {
	    case PROG_PRIMITIVE:
		if (curr->data.number >= BASE_MIN && curr->data.number <= BASE_MAX)
		    sprintf(buf, "%d: (line %d) PRIMITIVE: %s", i,
			curr->line, base_inst[curr->data.number - BASE_MIN]);
		else
		    sprintf(buf, "%d: (line %d) PRIMITIVE: %d", i,
			    curr->line, curr->data.number);
		break;
	    case PROG_STRING:
		sprintf(buf, "%d: (line %d) STRING: \"%s\"", i, curr->line,
			curr->data.string ? curr->data.string->data : "");
		break;
	    case PROG_FUNCTION:
		sprintf(buf,"%d: (line %d) FUNCTION HEADER: %s",i,curr->line,
			curr->data.string ? curr->data.string->data : "");
		break;
	    case PROG_LOCK:
		sprintf(buf, "%d: (line %d) LOCK: [%s]", i, curr->line,
			curr->data.lock == TRUE_BOOLEXP ? "TRUE_BOOLEXP" :
			unparse_boolexp(0, curr->data.lock, 0));
		break;
	    case PROG_INTEGER:
		sprintf(buf, "%d: (line %d) INTEGER: %d", i,
			curr->line, curr->data.number);
		break;
	    case PROG_FLOAT:
  	        sprintf(buf, "%d: (line %d) FLOAT: %f", i, curr->line,
                        curr->data.float_n);
	        break;
	    case PROG_ADD:
		sprintf(buf, "%d: (line %d) ADDRESS: %d", i,
			curr->line, (int)(curr->data.addr->data - codestart));
		break;
	    case PROG_IF:
		sprintf(buf, "%d: (line %d) IF: %d", i,
			curr->line, (int)(curr->data.call - codestart));
		break;
	    case PROG_JMP:
		sprintf(buf, "%d: (line %d) JMP: %d", i,
			curr->line, (int)(curr->data.call - codestart));
		break;
	    case PROG_EXEC:
		sprintf(buf, "%d: (line %d) EXEC: %d", i,
			curr->line, (int)(curr->data.call - codestart));
		break;
	    case PROG_OBJECT:
		sprintf(buf, "%d: (line %d) OBJECT REF: %d", i,
			curr->line, curr->data.number);
		break;
	    case PROG_VAR:
		sprintf(buf, "%d: (line %d) VARIABLE: %d", i,
			curr->line, curr->data.number);
		break;
	    case PROG_LVAR:
		sprintf(buf, "%d: (line %d) LOCALVAR: %d", i,
			curr->line, curr->data.number);
	}
	notify(player, buf);
    }
}
コード例 #10
0
ファイル: array.c プロジェクト: CyberLeo/zetamuck
/* natural = 1 performs a "natural" numeric sort on strings -Hinoserm */
static int
array_tree_compare(array_iter *a, array_iter *b, int case_sens, int objname, bool natural)
{
    char pad_char[] = "";

    if (a->type != b->type) {
        if (a->type == PROG_INTEGER && b->type == PROG_FLOAT) {
            if (fabs
                (((double) a->data.number -
                  b->data.fnumber) / (double) a->data.number) < DBL_EPSILON) {
                return 0;
            } else if (a->data.number > b->data.fnumber) {
                return 1;
            } else {
                return -1;
            }
        } else if (a->type == PROG_FLOAT && b->type == PROG_INTEGER) {
            if (a->data.fnumber == b->data.fnumber) {
                return 0;
            } else
                if (fabs((a->data.fnumber - b->data.number) / a->data.fnumber) <
                    DBL_EPSILON) {
                return 0;
            } else if (a->data.fnumber > b->data.number) {
                return 1;
            } else {
                return -1;
            }
        } else if (a->type == PROG_OBJECT && b->type == PROG_STRING
                   && objname && valid_obj(a->data.objref)) {
            char *astr = (char *) NAME(a->data.objref);
            char *bstr = (b->data.string) ? b->data.string->data : pad_char;

            if (case_sens) {
				if (natural)
					return strnatcmp(astr, bstr);
				else
					return strcmp(astr, bstr);
            } else {
				if (natural)
					return strnatcasecmp(astr, bstr);
				else
					return string_compare(astr, bstr);
            }
        } else if (a->type == PROG_STRING && b->type == PROG_OBJECT
                   && objname && valid_obj(b->data.objref)) {
            char *astr = (a->data.string) ? a->data.string->data : pad_char;
            char *bstr = (char *) NAME(b->data.objref);

            if (case_sens) {
				if (natural)
					return strnatcmp(astr, bstr);
				else
					return strcmp(astr, bstr);
            } else {
				if (natural)
					return strnatcasecmp(astr, bstr);
				else
					return string_compare(astr, bstr);
			}
        }
        return (a->type - b->type);
    }
    /* Indexes are of same type if we reached here. */
    if (a->type == PROG_OBJECT && objname && valid_obj(a->data.objref)
        && valid_obj(b->data.objref)) {
        char *astr = (char *) NAME(a->data.objref);
        char *bstr = (char *) NAME(b->data.objref);

		if (case_sens) {
			if (natural)
				return strnatcmp(astr, bstr);
			else
				return strcmp(astr, bstr);
		} else {
			if (natural)
				return strnatcasecmp(astr, bstr);
			else
				return string_compare(astr, bstr);
		}
    }
    if (a->type == PROG_OBJECT) {
        if (a->data.objref > b->data.objref)
            return 1;
        else if (a->data.objref < b->data.objref)
            return -1;
        else
            return 0;
    }
    if (a->type == PROG_FLOAT) {
        if (a->data.fnumber == b->data.fnumber) {
            return 0;
        } else
            if (fabs((a->data.fnumber - b->data.fnumber) / a->data.fnumber) <
                DBL_EPSILON) {
            return 0;
        } else if (a->data.fnumber > b->data.fnumber) {
            return 1;
        } else {
            return -1;
        }
    } else if (a->type == PROG_STRING) {
        char pad_char[] = "";
        char *astr = (a->data.string) ? a->data.string->data : pad_char;
        char *bstr = (b->data.string) ? b->data.string->data : pad_char;

		if (case_sens) {
			if (natural)
				return strnatcmp(astr, bstr);
			else
				return strcmp(astr, bstr);
		} else {
			if (natural)
				return strnatcasecmp(astr, bstr);
			else
				return string_compare(astr, bstr);
		}
    } else if (a->type == PROG_ARRAY) {
        /* Sort arrays by memory address. */
        /* This is a bug, really. */
        /* in a perfect world, we'd compare the array elements recursively. */
        return (a->data.array - b->data.array);
    } else if (a->type == PROG_LOCK) {
        /* Sort locks by memory address. */
        /* This is a bug, really. */
        /* in a perfect world, we'd compare the locks by element. */
        char *la;
        char *lb;
        int retval = 0;

        la = (char *) unparse_boolexp((dbref) 1, a->data.lock, 0);
        la = string_dup(la);
        lb = (char *) unparse_boolexp((dbref) 1, b->data.lock, 0);
        retval = strcmp(la, lb);
        free(la);
        return retval;
    } else if (a->type == PROG_ADD) {
        int result = (a->data.addr->progref - b->data.addr->progref);

        if (result) {
            return result;
        }
        return (a->data.addr->data - b->data.addr->data);
    } else {
        return (a->data.number - b->data.number);
    }
}
コード例 #11
0
ファイル: property.c プロジェクト: CyberLeo/protomuck
void
db_putprop(FILE * f, const char *dir, PropPtr p)
{
    char buf[BUFFER_LEN * 2];
    char fbuf[BUFFER_LEN];
    char num[16];
    char *ptr;
    const char *ptr2;


    if (PropType(p) == PROP_DIRTYP)
        return;

    for (ptr = buf, ptr2 = dir + 1; *ptr2;)
        *ptr++ = *ptr2++;
    for (ptr2 = PropName(p); *ptr2;)
        *ptr++ = *ptr2++;
    *ptr++ = PROP_DELIMITER;

    ptr2 =
        intostr(num,
                PropFlagsRaw(p) & ~(PROP_TOUCHED | PROP_ISUNLOADED |
                                    PROP_NOASCIICHK));
    while (*ptr2)
        *ptr++ = *ptr2++;
    *ptr++ = PROP_DELIMITER;

    ptr2 = "";
    switch (PropType(p)) {
        case PROP_INTTYP:
            if (!PropDataVal(p))
                return;
            ptr2 = intostr(num, PropDataVal(p));
            break;
        case PROP_FLTTYP:
            if (!PropDataFVal(p))
                return;
            ptr2 = fltostr(fbuf, PropDataFVal(p));
            break;
        case PROP_REFTYP:
            if (PropDataRef(p) == NOTHING)
                return;
            ptr2 = intostr(num, (int) PropDataRef(p));
            break;
        case PROP_STRTYP:
            if (!*PropDataStr(p))
                return;
            if (db_decompression_flag) {
                ptr2 = PropDataUNCStr(p);
            } else {
                ptr2 = PropDataStr(p);
            }
            break;
        case PROP_LOKTYP:
            if (PropFlags(p) & PROP_ISUNLOADED)
                return;
            if (PropDataLok(p) == TRUE_BOOLEXP)
                return;
            ptr2 = unparse_boolexp((dbref) 1, PropDataLok(p), 0);
            break;
    }
    while (*ptr2)
        if (*ptr2 != '\n')
            *ptr++ = *ptr2++;
        else {
            *ptr++ = '\\';
            *ptr++ = 'n';
            ptr2++;
        }
    *ptr++ = '\n';
    *ptr++ = '\0';
    if (fputs(buf, f) == EOF) {
        fprintf(stderr, "PANIC: Unable to write to db to write prop.\n");
        abort();
    }
}
コード例 #12
0
ファイル: disassem.c プロジェクト: CyberLeo/protomuck
void
disassemble(dbref player, dbref program)
{
    struct inst *curr;
    struct inst *codestart;
    int i;
    char buf[BUFFER_LEN];

    codestart = curr = DBFETCH(program)->sp.program.code;
    if (!DBFETCH(program)->sp.program.siz) {
        notify(player, "Nothing to disassemble!");
        return;
    }
    for (i = 0; i < DBFETCH(program)->sp.program.siz; i++, curr++) {
        switch (curr->type) {
            case PROG_PRIMITIVE:
                if (curr->data.number >= BASE_MIN
                    && curr->data.number <= BASE_MAX)
                    sprintf(buf, "%d: (line %d) PRIMITIVE: %s", i, curr->line,
                            base_inst[curr->data.number - BASE_MIN]);
                else
                    sprintf(buf, "%d: (line %d) PRIMITIVE: %d", i, curr->line,
                            curr->data.number);
                break;
            case PROG_MARK:
                sprintf(buf, "%d: (line %d) MARK", i, curr->line);
                break;
            case PROG_STRING:
                sprintf(buf, "%d: (line %d) STRING: \"%s\"", i, curr->line,
                        curr->data.string ? curr->data.string->data : "");
                break;
            case PROG_ARRAY:
                sprintf(buf, "%d: (line %d) ARRAY: %d items", i, curr->line,
                        curr->data.array ? curr->data.array->items : 0);
                break;
            case PROG_FUNCTION:
                sprintf(buf, "%d: (line %d) FUNCTION: %s, VARS: %d, ARGS: %d",
                        i, curr->line,
                        curr->data.mufproc->procname ? curr->data.mufproc->
                        procname : "", curr->data.mufproc->vars,
                        curr->data.mufproc->args);
                break;
            case PROG_LOCK:
                sprintf(buf, "%d: (line %d) LOCK: [%s]", i, curr->line,
                        curr->data.lock ==
                        TRUE_BOOLEXP ? "TRUE_BOOLEXP" : unparse_boolexp(0,
                                                                        curr->
                                                                        data.
                                                                        lock,
                                                                        0));
                break;
            case PROG_INTEGER:
                sprintf(buf, "%d: (line %d) INTEGER: %d", i, curr->line,
                        curr->data.number);
                break;
            case PROG_FLOAT:
                sprintf(buf, " %d: (line %d) FLOAT: %.15g", i, curr->line,
                        curr->data.fnumber);
                break;
            case PROG_ADD:
                sprintf(buf, "%d: (line %d) ADDRESS: %d", i, curr->line,
                        (int) (curr->data.addr->data - codestart));
                break;
            case PROG_TRY:
                sprintf(buf, "%d: (line %d) TRY: %d", i, curr->line,
                        (int) (curr->data.call - codestart));
            case PROG_IF:
                sprintf(buf, "%d: (line %d) IF: %d", i, curr->line,
                        (int) (curr->data.call - codestart));
                break;
            case PROG_JMP:
                sprintf(buf, "%d: (line %d) JMP: %d", i, curr->line,
                        (int) (curr->data.call - codestart));
                break;
            case PROG_EXEC:
                sprintf(buf, "%d: (line %d) EXEC: %d", i, curr->line,
                        (int) (curr->data.call - codestart));
                break;
            case PROG_OBJECT:
                sprintf(buf, "%d: (line %d) OBJECT REF: %d", i, curr->line,
                        curr->data.number);
                break;
            case PROG_VAR:
                sprintf(buf, "%d: (line %d) VARIABLE: %d", i, curr->line,
                        curr->data.number);
                break;
            case PROG_SVAR:
                sprintf(buf, "%d: (line %d) SCOPEDVAR: %d", i, curr->line,
                        curr->data.number);
                break;
            case PROG_SVAR_AT:
                sprintf(buf, "%d: (line %d) GET SCOPEDVAR: %d", i, curr->line,
                        curr->data.number);
                break;
            case PROG_SVAR_BANG:
                sprintf(buf, "%d: (line %d) SET SCOPEDVAR: %d", i, curr->line,
                        curr->data.number);
                break;
            case PROG_LVAR:
                sprintf(buf, "%d: (line %d) LOCALVAR: %d", i,
                        curr->line, curr->data.number);
                break;
            case PROG_LABEL:
                sprintf(buf, "%d: (line %d) LABEL: %s", i, curr->line,
                        curr->data.labelname);
                break;
#ifdef MUF_SOCKETS
            case PROG_SOCKET:
                sprintf(buf, "%d: (line %d) SOCKET", i, curr->line);
                break;
#endif
#ifdef SQL_SUPPORT
            case PROG_MYSQL:
                sprintf(buf, "%d: (line %d) MYSQL", i, curr->line);
                break;
#endif
            case PROG_CLEARED:
                sprintf(buf, "%d: (line ?) CLEARED INST AT %s:%d", i,
                        (char *) curr->data.addr, curr->line);
            default:
                sprintf(buf, "%d: (line ?) UNKNOWN INST", i);
        }
        notify(player, buf);
    }
}
コード例 #13
0
ファイル: disassem.c プロジェクト: PyroMuddypaw/fuzzball
void
disassemble(dbref player, dbref program)
{
	struct inst *curr;
	struct inst *codestart;
	int i;
	char buf[BUFFER_LEN];

	codestart = curr = PROGRAM_CODE(program);
	if (!PROGRAM_SIZ(program)) {
		notify(player, "Nothing to disassemble!");
		return;
	}
	for (i = 0; i < PROGRAM_SIZ(program); i++, curr++) {
		switch (curr->type) {
		case PROG_PRIMITIVE:
			if (curr->data.number >= BASE_MIN && curr->data.number <= BASE_MAX)
				snprintf(buf, sizeof(buf), "%d: (line %d) PRIMITIVE: %s", i,
						curr->line, base_inst[curr->data.number - BASE_MIN]);
			else
				snprintf(buf, sizeof(buf), "%d: (line %d) PRIMITIVE: %d", i, curr->line, curr->data.number);
			break;
		case PROG_MARK:
			snprintf(buf, sizeof(buf), "%d: (line %d) MARK", i, curr->line);
			break;
		case PROG_STRING:
			snprintf(buf, sizeof(buf), "%d: (line %d) STRING: \"%s\"", i, curr->line,
					curr->data.string ? curr->data.string->data : "");
			break;
		case PROG_ARRAY:
			snprintf(buf, sizeof(buf), "%d: (line %d) ARRAY: %d items", i, curr->line,
					curr->data.array ? curr->data.array->items : 0);
			break;
		case PROG_FUNCTION:
			snprintf(buf, sizeof(buf), "%d: (line %d) FUNCTION: %s, VARS: %d, ARGS: %d", i, curr->line,
					curr->data.mufproc->procname ? curr->data.mufproc->procname : "",
					curr->data.mufproc->vars, curr->data.mufproc->args);
			break;
		case PROG_LOCK:
			snprintf(buf, sizeof(buf), "%d: (line %d) LOCK: [%s]", i, curr->line,
					curr->data.lock == TRUE_BOOLEXP ? "TRUE_BOOLEXP" :
					unparse_boolexp(0, curr->data.lock, 0));
			break;
		case PROG_INTEGER:
			snprintf(buf, sizeof(buf), "%d: (line %d) INTEGER: %d", i, curr->line, curr->data.number);
			break;
		case PROG_FLOAT:
			snprintf(buf, sizeof(buf), "%d: (line %d) FLOAT: %.17g", i, curr->line, curr->data.fnumber);
			break;
		case PROG_ADD:
			snprintf(buf, sizeof(buf), "%d: (line %d) ADDRESS: %d", i,
					curr->line, (int)(curr->data.addr->data - codestart));
			break;
		case PROG_TRY:
			snprintf(buf, sizeof(buf), "%d: (line %d) TRY: %d", i, curr->line, (int)(curr->data.call - codestart));
			break;
		case PROG_IF:
			snprintf(buf, sizeof(buf), "%d: (line %d) IF: %d", i, curr->line, (int)(curr->data.call - codestart));
			break;
		case PROG_JMP:
			snprintf(buf, sizeof(buf), "%d: (line %d) JMP: %d", i, curr->line, (int)(curr->data.call - codestart));
			break;
		case PROG_EXEC:
			snprintf(buf, sizeof(buf), "%d: (line %d) EXEC: %d", i, curr->line, (int)(curr->data.call - codestart));
			break;
		case PROG_OBJECT:
			snprintf(buf, sizeof(buf), "%d: (line %d) OBJECT REF: %d", i, curr->line, curr->data.number);
			break;
		case PROG_VAR:
			snprintf(buf, sizeof(buf), "%d: (line %d) VARIABLE: %d", i, curr->line, curr->data.number);
			break;
		case PROG_SVAR:
			snprintf(buf, sizeof(buf), "%d: (line %d) SCOPEDVAR: %d (%s)", i, curr->line, curr->data.number, scopedvar_getname_byinst(curr, curr->data.number));
			break;
		case PROG_SVAR_AT:
			snprintf(buf, sizeof(buf), "%d: (line %d) FETCH SCOPEDVAR: %d (%s)", i, curr->line, curr->data.number, scopedvar_getname_byinst(curr, curr->data.number));
			break;
		case PROG_SVAR_AT_CLEAR:
			snprintf(buf, sizeof(buf), "%d: (line %d) FETCH SCOPEDVAR (clear optim): %d (%s)", i, curr->line, curr->data.number, scopedvar_getname_byinst(curr, curr->data.number));
			break;
		case PROG_SVAR_BANG:
			snprintf(buf, sizeof(buf), "%d: (line %d) SET SCOPEDVAR: %d (%s)", i, curr->line, curr->data.number, scopedvar_getname_byinst(curr, curr->data.number));
			break;
		case PROG_LVAR:
			snprintf(buf, sizeof(buf), "%d: (line %d) LOCALVAR: %d", i, curr->line, curr->data.number);
			break;
		case PROG_LVAR_AT:
			snprintf(buf, sizeof(buf), "%d: (line %d) FETCH LOCALVAR: %d", i, curr->line, curr->data.number);
			break;
		case PROG_LVAR_AT_CLEAR:
			snprintf(buf, sizeof(buf), "%d: (line %d) FETCH LOCALVAR (clear optim): %d", i, curr->line, curr->data.number);
			break;
		case PROG_LVAR_BANG:
			snprintf(buf, sizeof(buf), "%d: (line %d) SET LOCALVAR: %d", i, curr->line, curr->data.number);
			break;
		case PROG_CLEARED:
			snprintf(buf, sizeof(buf), "%d: (line ?) CLEARED INST AT %s:%d", i, (char *) curr->data.addr,
					curr->line);
		default:
			snprintf(buf, sizeof(buf), "%d: (line ?) UNKNOWN INST", i);
		}
		notify(player, buf);
	}
}
コード例 #14
0
ファイル: p_props.c プロジェクト: hyena/fuzzball
void
prim_array_filter_prop(PRIM_PROTOTYPE)
{
	char pattern[BUFFER_LEN];
	char tname[BUFFER_LEN];
	struct inst *in;
	struct inst temp1;
	stk_array *arr;
	stk_array *nu;
	char* prop;
	int len;

	CHECKOP(3);
	oper3 = POP();				/* str     pattern */
	oper2 = POP();				/* str     propname */
	oper1 = POP();				/* refarr  Array */
	if (oper1->type != PROG_ARRAY)
		abort_interp("Argument not an array. (1)");
	if (!array_is_homogenous(oper1->data.array, PROG_OBJECT))
		abort_interp("Argument not an array of dbrefs. (1)");
	if (oper2->type != PROG_STRING || !oper2->data.string)
		abort_interp("Argument not a non-null string. (2)");
	if (oper3->type != PROG_STRING)
		abort_interp("Argument not a string pattern. (3)");

	len = oper2->data.string ? oper2->data.string->length : 0;
	strcpyn(tname, sizeof(tname), DoNullInd(oper2->data.string));
	while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) {
		tname[len] = '\0';
	}

	nu = new_array_packed(0);
	arr = oper1->data.array;
	prop = tname;
	strcpyn(pattern, sizeof(pattern), DoNullInd(oper3->data.string));
	if (array_first(arr, &temp1)) {
		do {
			in = array_getitem(arr, &temp1);
			if (valid_object(in)) {
				ref = in->data.objref;
				CHECKREMOTE(ref);
				if (prop_read_perms(ProgUID, ref, prop, mlev)) {
					PropPtr pptr = get_property(ref, prop);

					if (pptr)
					{
						switch(PropType(pptr))
						{
							case PROP_STRTYP:
								strncpy(buf, PropDataStr(pptr), BUFFER_LEN);
							break;

							case PROP_LOKTYP:
								if (PropFlags(pptr) & PROP_ISUNLOADED) {
									strncpy(buf, "*UNLOCKED*", BUFFER_LEN);
								} else {
									strncpy(buf, unparse_boolexp(ProgUID, PropDataLok(pptr), 0), BUFFER_LEN);
								}
							break;

							case PROP_REFTYP:
								snprintf(buf, BUFFER_LEN, "#%i", PropDataRef(pptr));
							break;

							case PROP_INTTYP:
								snprintf(buf, BUFFER_LEN, "%i", PropDataVal(pptr));
							break;

							case PROP_FLTTYP:
								snprintf(buf, BUFFER_LEN, "%g", PropDataFVal(pptr));
							break;

							default:
								strncpy(buf, "", BUFFER_LEN);
							break;
						}
					}
					else
						strncpy(buf, "", BUFFER_LEN);

					if (equalstr(pattern, buf)) {
						array_appenditem(&nu, in);
					}
				}
			}
		} while (array_next(arr, &temp1));
	}

	CLEAR(oper3);
	CLEAR(oper2);
	CLEAR(oper1);

	PushArrayRaw(nu);
}
コード例 #15
0
ファイル: p_props.c プロジェクト: hyena/fuzzball
void
prim_envpropstr(PRIM_PROTOTYPE)
{
	CHECKOP(2);
	oper1 = POP();
	oper2 = POP();
	if (oper1->type != PROG_STRING)
		abort_interp("Non-string argument (2)");
	if (!oper1->data.string)
		abort_interp("Empty string argument (2)");
	if (!valid_object(oper2))
		abort_interp("Non-object argument (1)");
	CHECKREMOTE(oper2->data.objref);
	{
		char tname[BUFFER_LEN];
		dbref what;
		PropPtr ptr;
		const char *temp;
		int len = oper1->data.string->length;

		strcpyn(tname, sizeof(tname), oper1->data.string->data);
		while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) {
			tname[len] = '\0';
		}

		what = oper2->data.objref;
		ptr = envprop(&what, tname, 0);
		if (!ptr) {
			temp = "";
		} else {
#ifdef DISKBASE
			propfetch(what, ptr);
#endif
			switch (PropType(ptr)) {
			case PROP_STRTYP:
				temp = PropDataStr(ptr);
				break;
				/*
				 *case PROP_INTTYP:
				 *    snprintf(buf, sizeof(buf), "%d", PropDataVal(ptr));
				 *    temp = buf;
				 *    break;
				 */
			case PROP_REFTYP:
				snprintf(buf, sizeof(buf), "#%d", PropDataRef(ptr));
				temp = buf;
				break;
			case PROP_LOKTYP:
				if (PropFlags(ptr) & PROP_ISUNLOADED) {
					temp = "*UNLOCKED*";
				} else {
					temp = unparse_boolexp(ProgUID, PropDataLok(ptr), 1);
				}
				break;
			default:
				temp = "";
				break;
			}
		}

#ifdef LOG_PROPS
		log2file("props.log", "#%d (%d) ENVPROPSTR: o=%d so=%d n=\"%s\" s=\"%s\"",
				 program, pc->line, what, oper2->data.objref, tname, temp);
#endif

		if (what != NOTHING) {
			if (!prop_read_perms(ProgUID, what, oper1->data.string->data, mlev))
				abort_interp("Permission denied.");
			/* if (Typeof(what) != TYPE_PLAYER)
			 *     ts_lastuseobject(what); */
		}
		CLEAR(oper1);
		CLEAR(oper2);
		PushObject(what);
		PushString(temp);
	}
}
コード例 #16
0
ファイル: p_props.c プロジェクト: hyena/fuzzball
void
prim_parsepropex(PRIM_PROTOTYPE)
{
	struct inst*	oper1 = NULL; /* prevents reentrancy issues! */
	struct inst*	oper2 = NULL; /* prevents reentrancy issues! */
	struct inst*	oper3 = NULL; /* prevents reentrancy issues! */
	struct inst*	oper4 = NULL; /* prevents reentrancy issues! */
	stk_array*		vars;
	const char*		mpi;
	char*			str = 0;
	array_iter		idx;
	extern int		varc; /* from msgparse.c */
	int				mvarcnt = 0;
	char*			buffers = NULL;
	int				novars;
	int				hashow = 0;
	int				i;
	int             len;
	char			tname[BUFFER_LEN];
	char			buf[BUFFER_LEN];

	CHECKOP(4);

	oper4 = POP(); /* int:Private */
	oper3 = POP(); /* dict:Vars */
	oper2 = POP(); /* str:Prop */
	oper1 = POP(); /* ref:Object */

	if (mlev < 3)
		abort_interp("Mucker level 3 or greater required.");

	if (oper1->type != PROG_OBJECT)
		abort_interp("Non-object argument. (1)");
	if (oper2->type != PROG_STRING)
		abort_interp("Non-string argument. (2)");
	if (oper3->type != PROG_ARRAY)
		abort_interp("Non-array argument. (3)");
	if (oper3->data.array && (oper3->data.array->type != ARRAY_DICTIONARY))
		abort_interp("Dictionary array expected. (3)");
	if (oper4->type != PROG_INTEGER)
		abort_interp("Non-integer argument. (4)");

	if (!valid_object(oper1))
		abort_interp("Invalid object. (1)");
	if (!oper2->data.string)
		abort_interp("Empty string argument. (2)");
	if ((oper4->data.number != 0) && (oper4->data.number != 1))
		abort_interp("Integer of 0 or 1 expected. (4)");

	CHECKREMOTE(oper1->data.objref);

	if (!prop_read_perms(ProgUID, oper1->data.objref, oper2->data.string->data, mlev))
		abort_interp("Permission denied.");

	len = oper2->data.string->length;
	strcpyn(tname, sizeof(tname), oper2->data.string->data);
	while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) {
		tname[len] = '\0';
	}

	mpi		= get_property_class(oper1->data.objref, tname);
	vars	= oper3->data.array;
	novars	= array_count(vars);

	if (check_mvar_overflow(novars))
		abort_interp("Out of MPI variables. (3)");

	if (array_first(vars, &idx))
	{
		do
		{
			array_data*	val = array_getitem(vars, &idx);

			if (idx.type != PROG_STRING)
			{
				CLEAR(&idx);
				abort_interp("Only string keys supported. (3)");
			}

			if (idx.data.string == NULL)
			{
				CLEAR(&idx);
				abort_interp("Empty string keys not supported. (3)");
			}

			if (strlen(idx.data.string->data) > MAX_MFUN_NAME_LEN)
			{
				CLEAR(&idx);
				abort_interp("Key too long to be an MPI variable. (3)");
			}

			switch(val->type)
			{
				case PROG_INTEGER:
				case PROG_FLOAT:
				case PROG_OBJECT:
				case PROG_STRING:
				case PROG_LOCK:
				break;

				default:
					CLEAR(&idx);
					abort_interp("Only integer, float, dbref, string and lock values supported. (3)");
				break;
			}

			if (string_compare(idx.data.string->data, "how") == 0)
				hashow = 1;
		}
		while(array_next(vars, &idx));
	}

	if (mpi && *mpi)
	{
		if (novars > 0)
		{
			mvarcnt = varc;

			if ((buffers = (char*)malloc(novars * BUFFER_LEN)) == NULL)
				abort_interp("Out of memory.");

			if (array_first(vars, &idx))
			{
				i = 0;

				do
				{
					char*		var_buf = buffers + (i++ * BUFFER_LEN);
					array_data*	val;

					val = array_getitem(vars, &idx);

					switch(val->type)
					{
						case PROG_INTEGER:
							snprintf(var_buf, BUFFER_LEN, "%i", val->data.number);
						break;

						case PROG_FLOAT:
							snprintf(var_buf, BUFFER_LEN, "%g", val->data.fnumber);
						break;

						case PROG_OBJECT:
							snprintf(var_buf, BUFFER_LEN, "#%i", val->data.objref);
						break;

						case PROG_STRING:
							strncpy(var_buf, DoNullInd(val->data.string), BUFFER_LEN);
						break;

						case PROG_LOCK:
							strncpy(var_buf, unparse_boolexp(ProgUID, val->data.lock, 1), BUFFER_LEN);
						break;

						default:
							var_buf[0] = '\0';
						break;
					}

					var_buf[BUFFER_LEN - 1] = '\0';

					new_mvar(idx.data.string->data, var_buf);
				}
				while(array_next(vars, &idx));
			}
		}

		result = 0;

		if (oper4->data.number)
			result |= MPI_ISPRIVATE;

		if (Prop_Blessed(oper1->data.objref, oper2->data.string->data))
			result |= MPI_ISBLESSED;

		if (hashow)
			result |= MPI_NOHOW;

		str = do_parse_mesg(fr->descr, player, oper1->data.objref, mpi, "(parsepropex)", buf, sizeof(buf), result);

		if (novars > 0)
		{
			if (array_first(vars, &idx))
			{
				i = 0;

				do
				{
					char*		var_buf = buffers + (i++ * BUFFER_LEN);
					struct inst	temp;

					temp.type			= PROG_STRING;
					temp.data.string	= alloc_prog_string(var_buf);

					array_setitem(&vars, &idx, &temp);

					CLEAR(&temp);
				}
				while(array_next(vars, &idx));
			}

			free(buffers);

			varc = mvarcnt;
		}
	}

	oper3->data.array = NULL;

	CLEAR(oper1);
	CLEAR(oper2);
	CLEAR(oper3);
	CLEAR(oper4);

	PushArrayRaw(vars);
	PushString(str);
}