From: Adam Dickmeiss Date: Thu, 6 Oct 2011 10:40:04 +0000 (+0200) Subject: struct database: rename member url to id X-Git-Tag: v1.6.4~5^2~17 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=44981e9f52420f6a42bb1ac55712f74a31d17020;p=pazpar2-moved-to-github.git struct database: rename member url to id --- diff --git a/src/client.c b/src/client.c index ee0aa98..b650273 100644 --- a/src/client.c +++ b/src/client.c @@ -996,7 +996,7 @@ static void apply_limit(struct session_database *sdb, if (!s) { yaz_log(YLOG_WARN, "Target %s: limit %s used, but no limitmap defined", - (sdb->database ? sdb->database->url : ""), name); + (sdb->database ? sdb->database->id : ""), name); } } nmem_destroy(nmem_tmp); diff --git a/src/connection.c b/src/connection.c index 2df1d25..4c69f49 100644 --- a/src/connection.c +++ b/src/connection.c @@ -443,7 +443,7 @@ int client_prep_connection(struct client *cl, zproxy = 0; if (!url || !*url) - url = sdb->database->url; + url = sdb->database->id; host = find_host(client_get_session(cl)->service->server->database_hosts, url); diff --git a/src/database.c b/src/database.c index fb03b40..41e0f06 100644 --- a/src/database.c +++ b/src/database.c @@ -106,7 +106,7 @@ struct database *new_database(const char *id, NMEM nmem) struct setting *idset; db = nmem_malloc(nmem, sizeof(*db)); - db->url = nmem_strdup(nmem, id); + db->id = nmem_strdup(nmem, id); db->num_settings = PZ_MAX_EOF; db->settings = nmem_malloc(nmem, sizeof(struct settings*) * db->num_settings); @@ -115,7 +115,7 @@ struct database *new_database(const char *id, NMEM nmem) idset = nmem_malloc(nmem, sizeof(*idset)); idset->precedence = 0; idset->name = "pz:id"; - idset->target = idset->value = db->url; + idset->target = idset->value = db->id; idset->next = 0; db->settings[PZ_ID] = idset; @@ -129,7 +129,7 @@ struct database *create_database_for_service(const char *id, { struct database *p; for (p = service->databases; p; p = p->next) - if (!strcmp(p->url, id)) + if (!strcmp(p->id, id)) return p; p = new_database(id, service->nmem); diff --git a/src/http_command.c b/src/http_command.c index 7f7f98a..a4f7405 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -696,7 +696,7 @@ static void write_subrecord(struct record *r, WRBUF w, client_get_database(r->client), PZ_NAME); wrbuf_puts(w, "client)->database->url); + wrbuf_xmlputs(w, client_get_url(r->client)); wrbuf_puts(w, "\" "); wrbuf_puts(w, "name=\""); diff --git a/src/session.c b/src/session.c index 751117e..202c5dd 100644 --- a/src/session.c +++ b/src/session.c @@ -246,13 +246,13 @@ static xmlDoc *record_to_xml(struct session *se, if (!rdoc) { session_log(se, YLOG_FATAL, "Non-wellformed XML received from %s", - db->url); + db->id); return 0; } if (global_parameters.dump_records) { - session_log(se, YLOG_LOG, "Un-normalized record from %s", db->url); + session_log(se, YLOG_LOG, "Un-normalized record from %s", db->id); log_xml_doc(rdoc); } @@ -340,7 +340,7 @@ static xmlDoc *normalize_record(struct session *se, if (normalize_record_transform(sdb->map, &rdoc, (const char **)parms)) { session_log(se, YLOG_WARN, "Normalize failed from %s", - sdb->database->url); + sdb->database->id); } else { @@ -349,7 +349,7 @@ static xmlDoc *normalize_record(struct session *se, if (global_parameters.dump_records) { session_log(se, YLOG_LOG, "Normalized record from %s", - sdb->database->url); + sdb->database->id); log_xml_doc(rdoc); } } @@ -401,7 +401,7 @@ static int prepare_map(struct session *se, struct session_database *sdb) if (!sdb->settings) { - session_log(se, YLOG_WARN, "No settings on %s", sdb->database->url); + session_log(se, YLOG_WARN, "No settings on %s", sdb->database->id); return -1; } if ((s = session_setting_oneval(sdb, PZ_XSLT))) @@ -447,7 +447,7 @@ static int prepare_session_database(struct session *se, if (!sdb->settings) { session_log(se, YLOG_WARN, - "No settings associated with %s", sdb->database->url); + "No settings associated with %s", sdb->database->id); return -1; } if (sdb->settings[PZ_XSLT] && !sdb->map) @@ -524,12 +524,8 @@ void session_alert_watch(struct session *s, int what) static void select_targets_callback(struct session *se, struct session_database *db) { - struct client *cl = client_create(db->database->url); + struct client *cl = client_create(db->database->id); struct client_list *l; - const char *url = session_setting_oneval(db, PZ_URL); - - if (!url || !*url) - url = db->database->url; client_set_database(cl, db); @@ -735,7 +731,7 @@ static struct session_database *find_session_database(struct session *se, struct session_database *sdb; for (sdb = se->databases; sdb; sdb = sdb->next) - if (!strcmp(sdb->database->url, id)) + if (!strcmp(sdb->database->id, id)) return sdb; return load_session_database(se, id); } @@ -859,7 +855,7 @@ static struct hitsbytarget *hitsbytarget_nb(struct session *se, const char *name = session_setting_oneval(client_get_database(cl), PZ_NAME); - res[*count].id = client_get_database(cl)->database->url; + res[*count].id = client_get_url(cl); res[*count].name = *name ? name : "Unknown"; res[*count].hits = client_get_hits(cl); res[*count].records = client_get_num_records(cl); @@ -1309,7 +1305,7 @@ static const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, if (wrbuf_len(norm_wr) == 0) { wrbuf_printf(norm_wr, "%s-%d", - client_get_database(cl)->database->url, record_no); + client_get_url(cl), record_no); } if (wrbuf_len(norm_wr) > 0) mergekey_norm = nmem_strdup(nmem, wrbuf_cstr(norm_wr)); @@ -1413,7 +1409,7 @@ int ingest_record(struct client *cl, const char *rec, if (!check_record_filter(root, sdb)) { session_log(se, YLOG_LOG, "Filtered out record no %d from %s", - record_no, sdb->database->url); + record_no, sdb->database->id); xmlFreeDoc(xdoc); return -2; } @@ -1473,7 +1469,7 @@ static int ingest_to_cluster(struct client *cl, return -1; if (global_parameters.dump_records) session_log(se, YLOG_LOG, "Cluster id %s from %s (#%d)", cluster->recid, - sdb->database->url, record_no); + sdb->database->id, record_no); relevance_newrec(se->relevance, cluster); // now parsing XML record and adding data to cluster or record metadata diff --git a/src/session.h b/src/session.h index 11e2624..2cb6289 100644 --- a/src/session.h +++ b/src/session.h @@ -54,7 +54,7 @@ enum pazpar2_error_code { // Represents a database struct database { - char *url; + char *id; int num_settings; struct setting **settings; struct database *next; @@ -130,7 +130,7 @@ struct statistics { }; struct hitsbytarget { - char *id; + const char *id; const char *name; Odr_int hits; int diagnostic; diff --git a/src/settings.c b/src/settings.c index 759d4bc..ac66c5a 100644 --- a/src/settings.c +++ b/src/settings.c @@ -344,7 +344,7 @@ static void update_database_fun(void *context, struct database *db) int offset; // Is this the right database? - if (!match_zurl(db->url, set->target)) + if (!match_zurl(db->id, set->target)) return; offset = settings_create_offset(service, set->name);