コード例 #1
0
ファイル: list.c プロジェクト: aboudreault/tinyows
/*
 * Trunk an initial buffer into several pieces upon two separators
 * Careful returned list must then be free with list_free()
 */
list *list_explode_start_end(char separator_start, char separator_end, buffer * value)
{
    list *l;
    size_t i;
    buffer *buf;

    assert(value);

    l = list_init();

    /* If first char doesn't match separator, list contains only one element */
    if (value->buf[0] != separator_start) {
        list_add_by_copy(l, value);
        return l;
    }

    buf = buffer_init();

    for (i = 1 ; i < value->use ; i++)
             if (value->buf[i] == separator_end)   { list_add(l, buf); }
        else if (value->buf[i] != separator_start) { buffer_add(buf, value->buf[i]); }
        else     /* separator_start */             { buf = buffer_init(); }

    return l;
}
コード例 #2
0
ファイル: ows_layer.c プロジェクト: fredmorin/tinyows
/*
 * Retrieve a list of layer name who have a storage object
 * (concrete layer so)
 */
list * ows_layer_list_having_storage(const ows_layer_list * ll)
{
    ows_layer_node *ln;
    list *l;

    assert(ll);

    l = list_init();

    for (ln = ll->first; ln ; ln = ln->next)
        if (ln->layer->storage)
            list_add_by_copy(l, ln->layer->name);

    return l;
}
コード例 #3
0
ファイル: ows_layer.c プロジェクト: fredmorin/tinyows
/*
 * Retrieve a list of prefix used for a specified list of layers
 */
list *ows_layer_list_ns_prefix(ows_layer_list * ll, list * layer_name)
{
    list_node *ln;
    list *ml_ns_prefix;
    buffer *ns_prefix;

    assert(ll);
    assert(layer_name);

    ml_ns_prefix = list_init();

    for (ln = layer_name->first; ln ; ln = ln->next) {
        ns_prefix = ows_layer_ns_prefix(ll, ln->value);

        if (!in_list(ml_ns_prefix, ns_prefix))
            list_add_by_copy(ml_ns_prefix, ns_prefix);
    }

    return ml_ns_prefix;
}
コード例 #4
0
ファイル: ows_layer.c プロジェクト: fredmorin/tinyows
/*
 * Return a list of layer names grouped by prefix
 */
list *ows_layer_list_by_ns_prefix(ows_layer_list * ll, list * layer_name, buffer * ns_prefix)
{
    list *typ;
    list_node *ln;
    buffer *layer_ns_prefix;

    assert(ll);
    assert(layer_name);
    assert(ns_prefix);

    typ = list_init();

    for (ln = layer_name->first; ln ; ln = ln->next) {
        layer_ns_prefix = ows_layer_ns_prefix(ll, ln->value);

        if (buffer_cmp(layer_ns_prefix, ns_prefix->buf))
            list_add_by_copy(typ, ln->value);
    }

    return typ;
}