Пример #1
0
/******* internal expat callbacks *********/
static void _xode_stream_startElement(xode_stream xs, const char* name, const char** atts)
{
    xode_pool p;

    /* if xode_stream is bad, get outa here */
    if(xs->status > XODE_STREAM_NODE) return;

    if(xs->node == NULL)
    {
        p = xode_pool_heap(5*1024); /* 5k, typically 1-2k each plus copy of self and workspace */
        xs->node = xode_new_frompool(p,name);
        _xode_put_expatattribs(xs->node, atts);

        if(xs->status == XODE_STREAM_ROOT)
        {
            xs->status = XODE_STREAM_NODE; /* flag status that we're processing nodes now */
            (xs->f)(XODE_STREAM_ROOT, xs->node, xs->arg); /* send the root, f must free all nodes */
            xs->node = NULL;
        }
    }else{
        xs->node = xode_insert_tag(xs->node, name);
        _xode_put_expatattribs(xs->node, atts);
    }

    /* depth check */
    xs->depth++;
    if(xs->depth > XODE_STREAM_MAXDEPTH)
        xs->status = XODE_STREAM_ERROR;
}
Пример #2
0
static void _xode_expat_startElement(void* userdata, const char* name, const char** atts)
{
    /* get the xmlnode pointed to by the userdata */
    xode *x = userdata;
    xode current = *x;

    if (current == NULL)
    {
        /* allocate a base node */
        current = xode_new(name);
        _xode_put_expatattribs(current, atts);
        *x = current;
    }
    else
    {
        *x = xode_insert_tag(current, name);
        _xode_put_expatattribs(*x, atts);
    }
}