projects
/
pazpar2-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into paz-927
[pazpar2-moved-to-github.git]
/
src
/
http_command.c
diff --git
a/src/http_command.c
b/src/http_command.c
index
f11ae21
..
7c23404
100644
(file)
--- a/
src/http_command.c
+++ b/
src/http_command.c
@@
-1,5
+1,5
@@
/* This file is part of Pazpar2.
/* This file is part of Pazpar2.
- Copyright (C) 2006-2013 Index Data
+ Copyright (C) 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
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
@@
-299,7
+299,7
@@
static void error(struct http_response *rs,
enum pazpar2_error_code code,
const char *addinfo)
{
enum pazpar2_error_code code,
const char *addinfo)
{
- return error2(rs, code, addinfo, 0);
+ error2(rs, code, addinfo, 0);
}
static void response_open_command(struct http_channel *c, const char *command)
}
static void response_open_command(struct http_channel *c, const char *command)
@@
-401,6
+401,7
@@
static int process_settings(struct session *se, struct http_request *rq,
struct http_response *rs)
{
struct http_argument *a;
struct http_response *rs)
{
struct http_argument *a;
+ NMEM nmem = nmem_create();
for (a = rq->arguments; a; a = a->next)
if (strchr(a->name, '['))
for (a = rq->arguments; a; a = a->next)
if (strchr(a->name, '['))
@@
-411,17
+412,18
@@
static int process_settings(struct session *se, struct http_request *rq,
char *setting;
// Nmem_strsplit *rules*!!!
char *setting;
// Nmem_strsplit *rules*!!!
- nmem_strsplit(se->session_nmem, "[]", a->name, &res, &num);
+ nmem_strsplit(nmem, "[]", a->name, &res, &num);
if (num != 2)
{
error(rs, PAZPAR2_MALFORMED_SETTING, a->name);
if (num != 2)
{
error(rs, PAZPAR2_MALFORMED_SETTING, a->name);
+ nmem_destroy(nmem);
return -1;
}
setting = res[0];
dbname = res[1];
return -1;
}
setting = res[0];
dbname = res[1];
- session_apply_setting(se, dbname, setting,
- nmem_strdup(se->session_nmem, a->value));
+ session_apply_setting(se, dbname, setting, a->value);
}
}
+ nmem_destroy(nmem);
return 0;
}
return 0;
}
@@
-507,9
+509,7
@@
static void apply_local_setting(void *client_data,
{
struct session *se = (struct session *) client_data;
{
struct session *se = (struct session *) client_data;
- session_apply_setting(se, nmem_strdup(se->session_nmem, set->target),
- nmem_strdup(se->session_nmem, set->name),
- nmem_strdup(se->session_nmem, set->value));
+ session_apply_setting(se, set->target, set->name, set->value);
}
static void cmd_settings(struct http_channel *c)
}
static void cmd_settings(struct http_channel *c)
@@
-788,9
+788,9
@@
static void bytarget_response(struct http_channel *c, struct http_session *s,
wrbuf_printf(c->wrbuf, "<records>%d</records>\n",
ht[i].records - ht[i].filtered);
wrbuf_printf(c->wrbuf, "<records>%d</records>\n",
ht[i].records - ht[i].filtered);
+ wrbuf_printf(c->wrbuf, "<filtered>%d</filtered>\n", ht[i].filtered);
if (version >= 2)
{
if (version >= 2)
{
- wrbuf_printf(c->wrbuf, "<filtered>%d</filtered>\n", ht[i].filtered);
wrbuf_printf(c->wrbuf, "<approximation>" ODR_INT_PRINTF
"</approximation>\n", ht[i].approximation);
}
wrbuf_printf(c->wrbuf, "<approximation>" ODR_INT_PRINTF
"</approximation>\n", ht[i].approximation);
}
@@
-925,6
+925,9
@@
static void write_metadata(WRBUF w, struct conf_service *service,
if (md->data.number.min != md->data.number.max)
wrbuf_printf(w, "-%d", md->data.number.max);
break;
if (md->data.number.min != md->data.number.max)
wrbuf_printf(w, "-%d", md->data.number.max);
break;
+ case Metadata_type_float:
+ wrbuf_printf(w, "%f", md->data.fnumber);
+ break;
default:
wrbuf_puts(w, "[can't represent]");
break;
default:
wrbuf_puts(w, "[can't represent]");
break;
@@
-1285,7
+1288,7
@@
static void cmd_show(struct http_channel *c)
status = session_active_clients(s->psession);
status = session_active_clients(s->psession);
- if (block)
+ if (block && reclist_get_num_records(s->psession->reclist) == 0)
{
if (!strcmp(block, "preferred")
&& !session_is_preferred_clients_ready(s->psession)
{
if (!strcmp(block, "preferred")
&& !session_is_preferred_clients_ready(s->psession)
@@
-1454,6
+1457,17
@@
static void cmd_stat(struct http_channel *c)
release_session(c, s);
}
release_session(c, s);
}
+static void cmd_stop(struct http_channel *c)
+{
+ struct http_session *s = locate_session(c);
+ if (!s)
+ return;
+ response_open_ok(c, "stop");
+ session_stop(s->psession);
+ response_close(c, "stop");
+ release_session(c, s);
+}
+
static void cmd_info(struct http_channel *c)
{
char yaz_version_str[20];
static void cmd_info(struct http_channel *c)
{
char yaz_version_str[20];
@@
-1513,6
+1527,7
@@
struct {
{ "ping", cmd_ping },
{ "record", cmd_record },
{ "info", cmd_info },
{ "ping", cmd_ping },
{ "record", cmd_record },
{ "info", cmd_info },
+ { "stop", cmd_stop },
{0,0}
};
{0,0}
};