src/zoom-query.c
static char *cql2pqf(ZOOM_connection c, const char *cql)
{
    CQL_parser parser;
    int error;
    const char *cqlfile;
    cql_transform_t trans;
    char *result = 0;

    parser = cql_parser_create();
    if ((error = cql_parser_string(parser, cql)) != 0) {
        cql_parser_destroy(parser);
        ZOOM_set_error(c, ZOOM_ERROR_CQL_PARSE, cql);
        return 0;
    }

    cqlfile = ZOOM_connection_option_get(c, "cqlfile");
    if (cqlfile == 0)
    {
        ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, "no CQL transform file");
    }
    else if ((trans = cql_transform_open_fname(cqlfile)) == 0)
    {
        char buf[512];
        sprintf(buf, "can't open CQL transform file '%.200s': %.200s",
                cqlfile, strerror(errno));
        ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, buf);
    }
    else
    {
        WRBUF wrbuf_result = wrbuf_alloc();
        error = cql_transform(trans, cql_parser_result(parser),
                              wrbuf_vp_puts, wrbuf_result);
        if (error != 0) {
            char buf[512];
            const char *addinfo;
            error = cql_transform_error(trans, &addinfo);
            sprintf(buf, "%.200s (addinfo=%.200s)",
                    cql_strerror(error), addinfo);
            ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, buf);
        }
        else
        {
            result = xstrdup(wrbuf_cstr(wrbuf_result));
        }
        cql_transform_close(trans);
        wrbuf_destroy(wrbuf_result);
    }
    cql_parser_destroy(parser);
    return result;
}
/*
 * Returns an xmalloc()d string containing RPN that corresponds to the
 * CQL passed in.  On error, sets the Connection object's error state
 * and returns a null pointer.
 * ### We could cache CQL parser and/or transformer in Connection.
 */
Returns an xmalloc()d string containing RPN that corresponds to the
CQL passed in.  On error, sets the Connection object's error state
and returns a null pointer.
We could cache CQL parser and/or transformer in Connection.
Returns an xmalloc () d string containing RPN that corresponds to the CQL passed in . On error sets the Connection object ' s error state and returns a null pointer . We could cache CQL parser and / or transformer in Connection .
static char *cql2pqf(ZOOM_connection c, const char *cql)
{
    CQL_parser parser;
    int error;
    const char *cqlfile;
    cql_transform_t trans;
    char *result = 0;
    parser = cql_parser_create();
    if ((error = cql_parser_string(parser, cql)) != 0) {
        cql_parser_destroy(parser);
        ZOOM_set_error(c, ZOOM_ERROR_CQL_PARSE, cql);
        return 0;
    }
    cqlfile = ZOOM_connection_option_get(c, "cqlfile");
    if (cqlfile == 0)
    {
        ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, "no CQL transform file");
    }
    else if ((trans = cql_transform_open_fname(cqlfile)) == 0)
    {
        char buf[512];
        sprintf(buf, "can't open CQL transform file '%.200s': %.200s",
                cqlfile, strerror(errno));
        ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, buf);
    }
    else
    {
        WRBUF wrbuf_result = wrbuf_alloc();
        error = cql_transform(trans, cql_parser_result(parser),
                              wrbuf_vp_puts, wrbuf_result);
        if (error != 0) {
            char buf[512];
            const char *addinfo;
            error = cql_transform_error(trans, &addinfo);
            sprintf(buf, "%.200s (addinfo=%.200s)",
                    cql_strerror(error), addinfo);
            ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, buf);
        }
        else
        {
            result = xstrdup(wrbuf_cstr(wrbuf_result));
        }
        cql_transform_close(trans);
        wrbuf_destroy(wrbuf_result);
    }
    cql_parser_destroy(parser);
    return result;
}
static char * cql2pqf ( ZOOM_connection c , const char * cql ) { CQL_parser parser ; int error ; const char * cqlfile ; cql_transform_t trans ; char * result = 0 ; parser = cql_parser_create ( ) ; if ( ( error = cql_parser_string ( parser , cql ) ) != 0 ) { cql_parser_destroy ( parser ) ; ZOOM_set_error ( c , ZOOM_ERROR_CQL_PARSE , cql ) ; return 0 ; } cqlfile = ZOOM_connection_option_get ( c , " " ) ; if ( cqlfile == 0 ) { ZOOM_set_error ( c , ZOOM_ERROR_CQL_TRANSFORM , " " ) ; } else if ( ( trans = cql_transform_open_fname ( cqlfile ) ) == 0 ) { char buf [ 512 ] ; sprintf ( buf , " " , cqlfile , strerror ( errno ) ) ; ZOOM_set_error ( c , ZOOM_ERROR_CQL_TRANSFORM , buf ) ; } else { WRBUF wrbuf_result = wrbuf_alloc ( ) ; error = cql_transform ( trans , cql_parser_result ( parser ) , wrbuf_vp_puts , wrbuf_result ) ; if ( error != 0 ) { char buf [ 512 ] ; const char * addinfo ; error = cql_transform_error ( trans , & addinfo ) ; sprintf ( buf , " " , cql_strerror ( error ) , addinfo ) ; ZOOM_set_error ( c , ZOOM_ERROR_CQL_TRANSFORM , buf ) ; } else { result = xstrdup ( wrbuf_cstr ( wrbuf_result ) ) ; } cql_transform_close ( trans ) ; wrbuf_destroy ( wrbuf_result ) ; } cql_parser_destroy ( parser ) ; return result ; }
Returns an xmalloc()d string containing RPN that corresponds to the
 CQL passed in.
Returns an xmalloc () d string containing RPN that corresponds to the CQL passed in .