Example #1
0
void
op_in(void)
{
    Var		left, right, r;

    right = pop();
    left = pop();
    r.type = NUM;

    if (right.type == LIST) {
	r.v.num = list_ismember(left, right.v.list);
	push(r);
    } else if (right.type == STR) {
	if (left.type != STR) {
	    raise(E_TYPE);
	} else {
	    r.v.num = str_in(left.v.str->str, right.v.str->str);
	    push(r);
	}
    } else {
	raise(E_TYPE);
    }
    var_free(left);
    var_free(right);
}
Example #2
0
void suspend_current(struct list_node *queue)
{
	kthread_t *cur;
	/* current thread must be on the run queue */
	cur = current;
	if(list_ismember(&run_list, cur)) {
		list_del_obj(current);
		list_append_obj(queue, current);
	} else {
		printk("error: can't suspend thread not on run queue\n");
	}
	schedule();
}
Example #3
0
int
owns(Objid player, Objid what)
{
    Var		p, owners;
    Object     *o;

    if (!valid(player) || !(o = retrieve(what))) {
	return 0;
    }
    p.type = OBJ; p.v.obj = player;

    if (var_get_global(o, "owners", &owners) != E_NONE) {
	return 1;
    } else if (owners.type != LIST) {
	return 1;
    } else if (list_ismember(p, owners.v.list)) {
	return 1;
    }
    return 0;
}
Example #4
0
int
is_wizard(Objid player)
{
    Var    	p, wizards;

    p.type = OBJ; p.v.obj = player;
    if (player.server == 0 && player.id == SYS_OBJ) {
	return 1;		/* SYS_OBJ is always a wizard :) */
    } else if (!valid(player)) {
	return 0;
    } else if (var_get_global(retrieve(sys_obj), "wizards", &wizards)
		!= E_NONE) {
	return 0;
    } else if (wizards.type != LIST) {
	return 0;
    } else if (list_ismember(p, wizards.v.list)) {
	return 1;
    }
    return 0;
}