X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp_command.c;h=223903dfdabf9e947863a7d080b3a1e231eaeaca;hb=8acdfb7a90bd20104f67a2b1dfc9023c54473422;hp=86c67d47c64533f42e59f3c92bd146bdd27f8b61;hpb=47b679560c26472b212ea4b851ad108859e0e9a6;p=pazpar2-moved-to-github.git diff --git a/src/http_command.c b/src/http_command.c index 86c67d4..223903d 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,5 +1,5 @@ /* - * $Id: http_command.c,v 1.24 2007-01-17 15:27:34 quinn Exp $ + * $Id: http_command.c,v 1.28 2007-03-20 07:27:51 adam Exp $ */ #include @@ -168,7 +168,8 @@ static void targets_termlist(WRBUF wrbuf, struct session *se, int num) for (i = 0; i < count && i < num && ht[i].hits > 0; i++) { wrbuf_puts(wrbuf, "\n\n"); - wrbuf_printf(wrbuf, "%s\n", ht[i].id); + wrbuf_printf(wrbuf, "%s\n", ht[i].id); + wrbuf_printf(wrbuf, "%s\n", ht[i].name); wrbuf_printf(wrbuf, "%d\n", ht[i].hits); wrbuf_printf(wrbuf, "%s\n", ht[i].state); wrbuf_printf(wrbuf, "%d\n", ht[i].diagnostic); @@ -236,7 +237,7 @@ static void cmd_termlist(struct http_channel *c) name++; } wrbuf_puts(c->wrbuf, ""); - rs->payload = nmem_strdup(rq->channel->nmem, wrbuf_buf(c->wrbuf)); + rs->payload = nmem_strdup(rq->channel->nmem, wrbuf_cstr(c->wrbuf)); http_send_response(c); } @@ -271,7 +272,7 @@ static void cmd_bytarget(struct http_channel *c) } wrbuf_puts(c->wrbuf, ""); - rs->payload = nmem_strdup(c->nmem, wrbuf_buf(c->wrbuf)); + rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf)); http_send_response(c); } @@ -307,12 +308,22 @@ static void write_metadata(WRBUF w, struct conf_service *service, } } +static void write_subrecord(struct record *r, WRBUF w, struct conf_service *service) +{ + wrbuf_printf(w, "\n", + r->client->database->url, + r->client->database->name ? r->client->database->name : ""); + write_metadata(w, service, r->metadata, 1); + wrbuf_puts(w, "\n"); +} + static void cmd_record(struct http_channel *c) { struct http_response *rs = c->response; struct http_request *rq = c->request; struct http_session *s = locate_session(rq, rs); struct record_cluster *rec; + struct record *r; struct conf_service *service = global_parameters.server->service; char *idstr = http_argbyname(rq, "id"); int id; @@ -334,8 +345,10 @@ static void cmd_record(struct http_channel *c) wrbuf_puts(c->wrbuf, "\n"); wrbuf_printf(c->wrbuf, "%d", rec->recid); write_metadata(c->wrbuf, service, rec->metadata, 1); + for (r = rec->records; r; r = r->next) + write_subrecord(r, c->wrbuf, service); wrbuf_puts(c->wrbuf, "\n"); - rs->payload = nmem_strdup(c->nmem, wrbuf_buf(c->wrbuf)); + rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf)); http_send_response(c); } @@ -402,7 +415,7 @@ static void show_records(struct http_channel *c, int active) } wrbuf_puts(c->wrbuf, "\n"); - rs->payload = nmem_strdup(c->nmem, wrbuf_buf(c->wrbuf)); + rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf)); http_send_response(c); } @@ -456,6 +469,7 @@ static void cmd_search(struct http_channel *c) struct http_response *rs = c->response; struct http_session *s = locate_session(rq, rs); char *query = http_argbyname(rq, "query"); + char *filter = http_argbyname(rq, "filter"); char *res; if (!s) @@ -465,7 +479,7 @@ static void cmd_search(struct http_channel *c) error(rs, "417", "Must supply query", 0); return; } - res = search(s->psession, query); + res = search(s->psession, query, filter); if (res) { error(rs, "417", res, res); @@ -505,7 +519,7 @@ static void cmd_stat(struct http_channel *c) wrbuf_printf(c->wrbuf, "%d\n", stat.num_failed); wrbuf_printf(c->wrbuf, "%d\n", stat.num_error); wrbuf_puts(c->wrbuf, ""); - rs->payload = nmem_strdup(c->nmem, wrbuf_buf(c->wrbuf)); + rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf)); http_send_response(c); } @@ -525,7 +539,7 @@ static void cmd_info(struct http_channel *c) wrbuf_printf(c->wrbuf, " \n"); wrbuf_puts(c->wrbuf, ""); - rs->payload = nmem_strdup(c->nmem, wrbuf_buf(c->wrbuf)); + rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf)); http_send_response(c); }