Beispiel #1
0
static int
sort_query(struct query_sort *qs)
{
    search_query(qs);

    if (qs->query_string == NULL) {
        qs->append(qs, qs->url);
        return QS_OK;
    }

    qs->copy(qs, qs->url, qs->query_string - qs->url);

    int return_code = QS_OK;

    if( EOQS(qs->query_string[0]) ) {
        // no params, append the end of the url
        qs->append(qs, qs->query_string);
    }
    else {
        /* count query parameters... */
        count_params(qs);

        /* ...in order to allocate an array on the stack */
        struct query_param params[qs->count];
        qs->params = params;

        /* search and sort the parameters */
        const char *eoqs = search_params(qs);
        qsort(params, qs->count, sizeof(struct query_param), compare_params);

        /* append the sorted parameters and the end of the url */
        if ( append_params(qs) ) {
            return_code = QS_CLEANED;
        }
        qs->append(qs, eoqs);
    }

    return return_code;
}
Beispiel #2
0
const char *
guc_search_query(gnet_search_t sh)
{
    return search_query(sh);
}