X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fclient.c;h=be1bae91adf60f3593c5ee8f6e2da817091ce73b;hb=46dfee528ed8d8b304918491799e36f112e05cda;hp=a7d069d55e98bc00774f5dd1c0c11b6c00fe0fbd;hpb=5c017d34db6ea43ee6a95b8c462b9b824c26fbb8;p=pazpar2-moved-to-github.git diff --git a/src/client.c b/src/client.c index a7d069d..be1bae9 100644 --- a/src/client.c +++ b/src/client.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2009 Index Data + Copyright (C) 2006-2010 Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -72,9 +72,10 @@ struct client { struct session *session; char *pquery; // Current search char *cqlquery; // used for SRU targets only - int hits; + Odr_int hits; int record_offset; int maxrecs; + int startrecs; int diagnostic; enum client_state state; struct show_raw *show_raw; @@ -404,7 +405,7 @@ void client_search_response(struct client *cl) } else { - cl->record_offset = 0; + cl->record_offset = cl->startrecs; cl->hits = ZOOM_resultset_size(resultset); se->total_hits += cl->hits; } @@ -498,7 +499,7 @@ void client_start_search(struct client *cl) const char *opt_maxrecs = session_setting_oneval(sdb, PZ_MAXRECS); const char *opt_sru = session_setting_oneval(sdb, PZ_SRU); const char *opt_sort = session_setting_oneval(sdb, PZ_SORT); - char maxrecs_str[24]; + char maxrecs_str[24], startrecs_str[24]; assert(link); @@ -527,11 +528,15 @@ void client_start_search(struct client *cl) } ZOOM_connection_option_set(link, "count", opt_maxrecs); + if (atoi(opt_maxrecs) > 20) ZOOM_connection_option_set(link, "presentChunk", "20"); else ZOOM_connection_option_set(link, "presentChunk", opt_maxrecs); - + + sprintf(startrecs_str, "%d", cl->startrecs); + ZOOM_connection_option_set(link, "start", startrecs_str); + if (databaseName) ZOOM_connection_option_set(link, "databaseName", databaseName); @@ -566,6 +571,7 @@ struct client *client_create(void) else r = xmalloc(sizeof(struct client)); r->maxrecs = 100; + r->startrecs = 0; r->pquery = 0; r->cqlquery = 0; r->database = 0; @@ -689,6 +695,7 @@ int client_parse_query(struct client *cl, const char *query) CCL_bibset ccl_map = prepare_cclmap(cl); const char *sru = session_setting_oneval(sdb, PZ_SRU); const char *pqf_prefix = session_setting_oneval(sdb, PZ_PQF_PREFIX); + const char *pqf_strftime = session_setting_oneval(sdb, PZ_PQF_STRFTIME); if (!ccl_map) return -1; @@ -709,7 +716,26 @@ int client_parse_query(struct client *cl, const char *query) wrbuf_puts(se->wrbuf, pqf_prefix); wrbuf_puts(se->wrbuf, " "); } - ccl_pquery(se->wrbuf, cn); + if (!pqf_strftime || !*pqf_strftime) + ccl_pquery(se->wrbuf, cn); + else + { + time_t cur_time = time(0); + struct tm *tm = localtime(&cur_time); + char tmp_str[300]; + const char *cp = tmp_str; + + /* see man strftime(3) for things .. In particular %% gets converted + to %.. And That's our original query .. */ + strftime(tmp_str, sizeof(tmp_str)-1, pqf_strftime, tm); + for (; *cp; cp++) + { + if (cp[0] == '%') + ccl_pquery(se->wrbuf, cn); + else + wrbuf_putc(se->wrbuf, cp[0]); + } + } xfree(cl->pquery); cl->pquery = xstrdup(wrbuf_cstr(se->wrbuf)); @@ -759,7 +785,7 @@ struct client *client_next_in_session(struct client *cl) } -int client_get_hits(struct client *cl) +Odr_int client_get_hits(struct client *cl) { return cl->hits; } @@ -769,6 +795,11 @@ int client_get_num_records(struct client *cl) return cl->record_offset; } +void client_set_diagnostic(struct client *cl, int diagnostic) +{ + cl->diagnostic = diagnostic; +} + int client_get_diagnostic(struct client *cl) { return cl->diagnostic; @@ -794,6 +825,11 @@ void client_set_maxrecs(struct client *cl, int v) cl->maxrecs = v; } +void client_set_startrecs(struct client *cl, int v) +{ + cl->startrecs = v; +} + /* * Local variables: * c-basic-offset: 4