Ejemplo n.º 1
0
object_t *find_living_object (const char* str, int user)
{
    object_t **obp, *tmp;
    object_t **hl;

    if (!str)
	return 0;
    num_searches++;
    hl = &hashed_living[hash_living_name(str)];
    for (obp = hl; *obp; obp = &(*obp)->next_hashed_living) {
	search_length++;
#ifdef F_SET_HIDE
	if ((*obp)->flags & O_HIDDEN) {
	    if (!valid_hide(current_object))
		continue;
	}
#endif
	if (user && !((*obp)->flags & O_ONCE_INTERACTIVE))
	    continue;
	if (!((*obp)->flags & O_ENABLE_COMMANDS))
	    continue;
	if (strcmp((*obp)->living_name, str) == 0)
	    break;
    }
    if (*obp == 0)
	return 0;
    /* Move the found ob first. */
    if (obp == hl)
	return *obp;
    tmp = *obp;
    *obp = tmp->next_hashed_living;
    tmp->next_hashed_living = *hl;
    *hl = tmp;
    return tmp;
}
Ejemplo n.º 2
0
array_t *users()
{
    register object_t *ob;
    int i, j;
    int display_hidden = 0;
    array_t *ret;

    if (num_hidden > 0) {
	if (current_object->flags & O_HIDDEN) {
	    display_hidden = 1;
	} else {
	    display_hidden = valid_hide(current_object);
	}
    }
    ret = allocate_empty_array(num_user - (display_hidden ? 0 : num_hidden));
    for (i = j = 0; i < max_users; i++) {
	if (!all_users[i]) {
	    continue;
	}
	ob = all_users[i]->ob;
	if (!display_hidden && (ob->flags & O_HIDDEN)) {
	    continue;
	}
	ret->item[j].type = T_OBJECT;
	ret->item[j].u.ob = ob;
	add_ref(ob, "users");
	j++;
    }
    return ret;
}
Ejemplo n.º 3
0
array_t *get_heart_beats() {
    int nob = 0, n = num_hb_objs;
    heart_beat_t *hb = heart_beats;
    object_t **obtab;
    array_t *arr;
#ifdef F_SET_HIDE
    int apply_valid_hide = 1, display_hidden = 0;
#endif

    obtab = CALLOCATE(n, object_t *, TAG_TEMPORARY, "heart_beats");
    while (n--) {
#ifdef F_SET_HIDE
        if (hb->ob->flags & O_HIDDEN) {
            if (apply_valid_hide) {
                apply_valid_hide = 0;
                display_hidden = valid_hide(current_object);
            }
            if (!display_hidden)
                continue;
        }
#endif
        obtab[nob++] = (hb++)->ob;
    }

    arr = allocate_empty_array(nob);
    while (nob--) {
        arr->item[nob].type = T_OBJECT;
        arr->item[nob].u.ob = obtab[nob];
        add_ref(arr->item[nob].u.ob, "get_heart_beats");
    }

    FREE(obtab);

    return arr;
}
Ejemplo n.º 4
0
void dumpstat (const char * tfn)
{
    FILE *f;
    object_t *ob;
    const char *fn;
#ifdef F_SET_HIDE
    int display_hidden;
#endif

    fn = check_valid_path(tfn, current_object, "dumpallobj", 1);
    if (!fn) {
        error("Invalid path '/%s' for writing.\n", tfn);
        return;
    }
    f = fopen(fn, "w");
    if (!f) {
        error("Unable to open '/%s' for writing.\n", fn);
        return;
    }

#ifdef F_SET_HIDE
    display_hidden = -1;
#endif
    for (ob = obj_list; ob; ob = ob->next_all) {
        long tmp;

#ifdef F_SET_HIDE
        if (ob->flags & O_HIDDEN) {
            if (display_hidden == -1)
                display_hidden = valid_hide(current_object);
            if (!display_hidden)
                continue;
        }
#endif
        /* FIXME */
        if (ob->prog && (ob->prog->ref == 1 || !(ob->flags & O_CLONE)))
            tmp = ob->prog->total_size;
        else
            tmp = 0;
        fprintf(f, "%-20s %ld ref %2d %s %s (%d)\n", ob->obname,
                tmp + data_size(ob) + sizeof(object_t), ob->ref,
                ob->flags & O_HEART_BEAT ? "HB" : "  ",
#ifndef NO_ENVIRONMENT
                ob->super ? ob->super->obname : "--",
#else
                "--",
#endif
                /* ob->cpu */ 0);
    }
    fclose(f);
}
Ejemplo n.º 5
0
void f_named_livings() {
    int i;
    int nob;
#ifdef F_SET_HIDE
    int apply_valid_hide, display_hidden = 0;
#endif
    object_t *ob, **obtab;
    array_t *vec;

    nob = 0;
#ifdef F_SET_HIDE
    apply_valid_hide = 1;
#endif

    obtab = CALLOCATE(max_array_size, object_t *, TAG_TEMPORARY, "named_livings");

    for (i = 0; i < CFG_LIVING_HASH_SIZE; i++) {
	for (ob = hashed_living[i]; ob; ob = ob->next_hashed_living) {
	    if (!(ob->flags & O_ENABLE_COMMANDS))
		continue;
#ifdef F_SET_HIDE
	    if (ob->flags & O_HIDDEN) {
		if (apply_valid_hide) {
		    apply_valid_hide = 0;
		    display_hidden = valid_hide(current_object);
		}
		if (!display_hidden)
		    continue;
	    }
#endif
	    if (nob == max_array_size)
		break;
	    obtab[nob++] = ob;
	}
    }

    vec = allocate_empty_array(nob);
    while (--nob >= 0) {
	vec->item[nob].type = T_OBJECT;
	vec->item[nob].u.ob = obtab[nob];
	add_ref(obtab[nob], "livings");
    }

    FREE(obtab);

    push_refed_array(vec);
}    
Ejemplo n.º 6
0
void dumpstat P1(char *, tfn)
{
    FILE *f;
    object_t *ob;
    char *fn;
    int display_hidden;

    fn = check_valid_path(tfn, current_object, "dumpallobj", 1);
    if (!fn) {
        error("Invalid path '%s' for writing.\n", tfn);
        return;
    }
    f = fopen(fn, "w");
    if (!f) {
        error("Unable to open '/%s' for writing.\n", fn);
        return;
    }

    display_hidden = -1;
    for (ob = obj_list; ob; ob = ob->next_all) {
        int tmp;

        if (ob->flags & O_HIDDEN) {
            if (display_hidden == -1)
                display_hidden = valid_hide(current_object);
            if (!display_hidden)
                continue;
        }
        if (ob->prog && (ob->prog->ref == 1 || !(ob->flags & O_CLONE)))
            tmp = ob->prog->total_size;
        else
            tmp = 0;
        fprintf(f, "%-20s %i ref %2d %s %s (%d) %s\n", ob->name,
                tmp + data_size(ob) + sizeof(object_t), ob->ref,
                ob->flags & O_HEART_BEAT ? "HB" : "  ",
#ifndef NO_ENVIRONMENT
                ob->super ? ob->super->name : "--",
#else
                "--",
#endif
                /* ob->cpu */ 0,
                (ob->swap_num >= 0) ? ((ob->flags & O_SWAPPED) ?
                                       "SWAPPED(out)" : "SWAPPED(in)") : "");
    }
    fclose(f);
}