Use the new ANTLR parser for DAAP queries

This commit is contained in:
Julien BLACHE 2009-06-02 16:31:36 +02:00
parent 68db2ae7c2
commit 7642b1c6d7
3 changed files with 30 additions and 31 deletions

View File

@ -60,6 +60,7 @@ typedef struct tag_dbqueryinfo {
int uri_count;
int correct_order;
char *uri_sections[10];
char *filter; /* SQL WHERE clause */
PARSETREE pt;
void *output_info;
} DBQUERYINFO;

View File

@ -1253,8 +1253,19 @@ int db_sql_enum_start(char **pe, DBQUERYINFO *pinfo) {
}
/* Apply the query/filter */
if(pinfo->pt) {
DPRINTF(E_DBG,L_DB,"Got query/filter\n");
if (pinfo->filter) { /* New parsers */
DPRINTF(E_DBG, L_DB, "Got new-style query/filter\n");
if(have_clause) {
strcat(query_rest, " and ");
} else {
strcpy(query_rest, " where ");
have_clause = 1;
}
strcat(query_rest, pinfo->filter);
}
else if (pinfo->pt) { /* Old parsers (smart-parser.c) */
DPRINTF(E_DBG,L_DB,"Got old-style query/filter\n");
filter = sp_sql_clause(pinfo->pt);
if(filter) {
if(have_clause) {
@ -1276,7 +1287,7 @@ int db_sql_enum_start(char **pe, DBQUERYINFO *pinfo) {
/* disable empty */
if(browse) {
if((have_clause) || (pinfo->pt)) {
if((have_clause) || (pinfo->filter) || (pinfo->pt)) {
strcat(query_rest," and (");
} else {
strcpy(query_rest," where (");

View File

@ -625,22 +625,9 @@ get_query_params(struct evkeyvalq *query, DBQUERYINFO *qi)
{
DPRINTF(E_DBG, L_DAAP, "DAAP browse query filter: %s\n", param);
qi->pt = sp_init();
if (!qi->pt)
{
DPRINTF(E_LOG, L_DAAP, "Could not init query filter\n");
}
else
{
ret = sp_parse(qi->pt, param, FILTER_TYPE_APPLE);
if (ret != 1)
{
DPRINTF(E_LOG, L_DAAP, "Ignoring improper query: %s\n", sp_get_error(qi->pt));
sp_dispose(qi->pt);
qi->pt = NULL;
}
}
qi->filter = daap_query_parse_sql(param);
if (!qi->filter)
DPRINTF(E_LOG, L_DAAP, "Ignoring improper DAAP query\n");
}
qi->want_count = 1;
@ -1099,8 +1086,8 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
free(meta);
evbuffer_free(song);
evbuffer_free(songlist);
if (qi.pt)
sp_dispose(qi.pt);
if (qi.filter)
free(qi.filter);
return;
}
@ -1258,8 +1245,8 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
evbuffer_free(song);
if (qi.pt)
sp_dispose(qi.pt);
if (qi.filter)
free(qi.filter);
if (ret != DB_E_SUCCESS)
{
@ -1440,8 +1427,8 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
free(meta);
evbuffer_free(playlist);
evbuffer_free(playlistlist);
if (qi.pt)
sp_dispose(qi.pt);
if (qi.filter)
free(qi.filter);
return;
}
@ -1522,8 +1509,8 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
free(meta);
evbuffer_free(playlist);
if (qi.pt)
sp_dispose(qi.pt);
if (qi.filter)
free(qi.filter);
if (ret != DB_E_SUCCESS)
{
@ -1657,8 +1644,8 @@ daap_reply_browse(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
free(db_errmsg);
evbuffer_free(itemlist);
if (qi.pt)
sp_dispose(qi.pt);
if (qi.filter)
free(qi.filter);
return;
}
@ -1670,8 +1657,8 @@ daap_reply_browse(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
dmap_add_string(itemlist, "mlit", *item);
}
if (qi.pt)
sp_dispose(qi.pt);
if (qi.filter)
free(qi.filter);
if (ret != DB_E_SUCCESS)
{