From: Adam Dickmeiss Date: Fri, 17 Aug 2007 12:39:11 +0000 (+0000) Subject: Changed session_setting_oneval to return 'const string' rather than X-Git-Tag: PAZPAR2.1.0.2~1 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=aeca8671e89c5ade0a14aa95429632bd83772409;p=pazpar2-moved-to-github.git Changed session_setting_oneval to return 'const string' rather than string. Settings returned are strictly read-only. --- diff --git a/src/client.c b/src/client.c index 7b82c69..25fbb5f 100644 --- a/src/client.c +++ b/src/client.c @@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.17 2007-08-17 12:25:26 adam Exp $ +/* $Id: client.c,v 1.18 2007-08-17 12:39:11 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -403,8 +403,8 @@ void client_send_search(struct client *cl) char **databaselist; Z_Query *zquery; int ssub = 0, lslb = 100000, mspn = 10; - char *piggyback = 0; - char *queryenc = session_setting_oneval(sdb, PZ_QUERYENCODING); + const char *piggyback = session_setting_oneval(sdb, PZ_PIGGYBACK); + const char *queryenc = session_setting_oneval(sdb, PZ_QUERYENCODING); yaz_log(YLOG_DEBUG, "Sending search to %s", sdb->database->url); @@ -436,8 +436,7 @@ void client_send_search(struct client *cl) for (ndb = 0; sdb->database->databases[ndb]; ndb++) databaselist[ndb] = sdb->database->databases[ndb]; - if (!(piggyback = session_setting_oneval(sdb, PZ_PIGGYBACK)) - || *piggyback == '1') + if (!piggyback || *piggyback == '1') { const char *elements = session_setting_oneval(sdb, PZ_ELEMENTS); const char *recsyn = session_setting_oneval(sdb, PZ_REQUESTSYNTAX); @@ -743,7 +742,7 @@ int client_is_our_response(struct client *cl) static void init_authentication(struct client *cl, Z_InitRequest *req) { struct session_database *sdb = client_get_database(cl); - char *auth = session_setting_oneval(sdb, PZ_AUTHENTICATION); + const char *auth = session_setting_oneval(sdb, PZ_AUTHENTICATION); if (*auth) { @@ -752,7 +751,7 @@ static void init_authentication(struct client *cl, Z_InitRequest *req) Z_IdAuthentication *idAuth = odr_malloc(global_parameters.odr_out, sizeof(*idAuth)); idAuth->which = Z_IdAuthentication_open; - idAuth->u.open = auth; + idAuth->u.open = odr_strdup(global_parameters.odr_out, auth); req->idAuthentication = idAuth; connection_set_authentication(co, nmem_strdup(se->session_nmem, auth)); } @@ -763,8 +762,8 @@ static void init_zproxy(struct client *cl, Z_InitRequest *req) struct session_database *sdb = client_get_database(cl); char *ztarget = sdb->database->url; //char *ztarget = sdb->url; - char *zproxy = session_setting_oneval(sdb, PZ_ZPROXY); - + const char *zproxy = session_setting_oneval(sdb, PZ_ZPROXY); + if (*zproxy) yaz_oi_set_string_oid(&req->otherInfo, global_parameters.odr_out, diff --git a/src/http_command.c b/src/http_command.c index 087f53d..0ad6492 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.57 2007-07-16 17:01:46 adam Exp $ +/* $Id: http_command.c,v 1.58 2007-08-17 12:39:11 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.57 2007-07-16 17:01:46 adam Exp $ + * $Id: http_command.c,v 1.58 2007-08-17 12:39:11 adam Exp $ */ #include @@ -477,7 +477,8 @@ static void write_metadata(WRBUF w, struct conf_service *service, static void write_subrecord(struct record *r, WRBUF w, struct conf_service *service, int show_details) { - char *name = session_setting_oneval(client_get_database(r->client), PZ_NAME); + const char *name = session_setting_oneval( + client_get_database(r->client), PZ_NAME); wrbuf_puts(w, "client)->database->url); diff --git a/src/logic.c b/src/logic.c index 4146612..f98d240 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1,4 +1,4 @@ -/* $Id: logic.c,v 1.61 2007-08-16 11:30:45 adam Exp $ +/* $Id: logic.c,v 1.62 2007-08-17 12:39:11 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -291,7 +291,7 @@ static void insert_settings_parameters(struct session_database *sdb, if (md->setting == Metadata_setting_parameter && (setting = settings_offset(md->name)) > 0) { - char *val = session_setting_oneval(sdb, setting); + const char *val = session_setting_oneval(sdb, setting); if (val && nparms < MAX_XSLT_ARGS) { char *buf; @@ -324,7 +324,7 @@ static void insert_settings_values(struct session_database *sdb, xmlDoc *doc) if (md->setting == Metadata_setting_postproc && (offset = settings_offset(md->name)) > 0) { - char *val = session_setting_oneval(sdb, offset); + const char *val = session_setting_oneval(sdb, offset); if (val) { xmlNode *r = xmlDocGetRootElement(doc); @@ -393,7 +393,7 @@ xmlDoc *normalize_record(struct session_database *sdb, struct session *se, // Retrieve first defined value for 'name' for given database. // Will be extended to take into account user associated with session -char *session_setting_oneval(struct session_database *db, int offset) +const char *session_setting_oneval(struct session_database *db, int offset) { if (!db->settings[offset]) return ""; @@ -405,7 +405,7 @@ char *session_setting_oneval(struct session_database *db, int offset) // Initialize YAZ Map structures for MARC-based targets static int prepare_yazmarc(struct session_database *sdb) { - char *s; + const char *s; if (!sdb->settings) { @@ -445,7 +445,7 @@ static int prepare_yazmarc(struct session_database *sdb) // setting. However, this is not a realistic use scenario. static int prepare_map(struct session *se, struct session_database *sdb) { - char *s; + const char *s; if (!sdb->settings) { @@ -461,8 +461,8 @@ static int prepare_map(struct session *se, struct session_database *sdb) if (!strcmp(s, "auto")) { - char *request_syntax = session_setting_oneval(sdb, - PZ_REQUESTSYNTAX); + const char *request_syntax = session_setting_oneval( + sdb, PZ_REQUESTSYNTAX); if (request_syntax) { char *cp; @@ -866,7 +866,8 @@ struct hitsbytarget *hitsbytarget(struct session *se, int *count) *count = 0; for (cl = se->clients; cl; cl = client_next_in_session(cl)) { - char *name = session_setting_oneval(client_get_database(cl), PZ_NAME); + const char *name = session_setting_oneval(client_get_database(cl), + PZ_NAME); res[*count].id = client_get_database(cl)->database->url; res[*count].name = *name ? name : "Unknown"; diff --git a/src/pazpar2.h b/src/pazpar2.h index 91f3aab..5ccf667 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -1,4 +1,4 @@ -/* $Id: pazpar2.h,v 1.46 2007-07-30 23:16:33 quinn Exp $ +/* $Id: pazpar2.h,v 1.47 2007-08-17 12:39:11 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -158,7 +158,7 @@ struct statistics { struct hitsbytarget { char *id; - char *name; + const char *name; int hits; int diagnostic; int records; @@ -182,7 +182,7 @@ struct termlist_score **termlist(struct session *s, const char *name, int *num); int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c); int session_active_clients(struct session *s); void session_apply_setting(struct session *se, char *dbname, char *setting, char *value); -char *session_setting_oneval(struct session_database *db, int offset); +const char *session_setting_oneval(struct session_database *db, int offset); void start_http_listener(void); void start_proxy(void);