示例#1
0
array_t *commands P1(object_t *, ob)
{
    sentence_t *s;
    array_t *v, *p;
    int cnt = 0;
    svalue_t *sv;

    for (s = ob->sent; s && s->verb; s = s->next) {
	if (++cnt == max_array_size) break;
    }
    v = allocate_empty_array(cnt);
    sv = v->item;
    for (s = ob->sent; cnt-- && s && s->verb; s = s->next) {
	sv->type = T_ARRAY;
	(sv++)->u.arr = p = allocate_empty_array(4);
	p->item[0].type = T_STRING;
	p->item[0].u.string = ref_string(s->verb);	/* the verb is shared */
	p->item[0].subtype = STRING_SHARED;
	p->item[1].type = T_NUMBER;
	p->item[1].u.number = s->flags;
	p->item[2].type = T_OBJECT;
	p->item[2].u.ob = s->ob;
	p->item[3].type = T_STRING;
        if (s->flags & V_FUNCTION) {
            p->item[3].u.string = "<function>";
            p->item[3].subtype = STRING_CONSTANT;
        } else {
            p->item[3].u.string = ref_string(s->function.s);
            p->item[3].subtype = STRING_SHARED;
        }
	add_ref(s->ob, "commands");
    }
    return v;
}
示例#2
0
static void copy_close_callback (int to, int from)
{
    char *s;

    if (lpc_socks[to].flags & S_CLOSE_FP) {
        free_funp(lpc_socks[to].close_callback.f);
    } else if ((s = lpc_socks[to].close_callback.s))
        free_string(s);

    if (lpc_socks[from].flags & S_CLOSE_FP) {
        lpc_socks[to].flags |= S_CLOSE_FP;
        lpc_socks[to].close_callback.f = lpc_socks[from].close_callback.f;
        lpc_socks[to].close_callback.f->hdr.ref++;
    } else {
        lpc_socks[to].flags &= ~S_CLOSE_FP;
        s = lpc_socks[to].close_callback.s = lpc_socks[from].close_callback.s;
        if (s)
            ref_string(s);
    }
}