+ const char *name = names[i];
+ const char *value = values[i];
+ assert(name);
+ assert(value);
+ if (!strcmp(name, "user"))
+ param_user = value;
+ else if (!strcmp(name, "password"))
+ param_password = value;
+ else if (!strcmp(name, "content-user"))
+ param_content_user = value;
+ else if (!strcmp(name, "content-password"))
+ param_content_password = value;
+ else if (!strcmp(name, "content-proxy"))
+ content_proxy = value;
+ else if (!strcmp(name, "proxy"))
+ {
+ char **dstr;
+ int dnum = 0;
+ nmem_strsplit(odr->mem, ",", value, &dstr, &dnum);
+ if (*proxy_step >= dnum)
+ *proxy_step = 0;
+ else
+ {
+ proxy = dstr[*proxy_step];
+
+ (*proxy_step)++;
+ if (*proxy_step == dnum)
+ *proxy_step = 0;
+ }
+ }
+ else if (!strcmp(name, "cproxysession"))
+ {
+ out_names[no_out_args] = name;
+ out_values[no_out_args++] = value;
+ torus_url = m_p->torus_content_url;
+ }
+ else if (!strcmp(name, "realm"))
+ realm = value;
+ else if (name[0] == 'x' && name[1] == '-')
+ {
+ out_names[no_out_args] = name;
+ out_values[no_out_args++] = value;
+ }
+ else
+ {
+ BackendPtr notfound;
+ char *msg = (char*) odr_malloc(odr, strlen(name) + 30);
+ *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
+ sprintf(msg, "Bad database argument: %s", name);
+ *addinfo = msg;
+ return notfound;
+ }
+ }
+ if (param_user)
+ {
+ authentication = std::string(param_user);
+ if (param_password)
+ authentication += "/" + std::string(param_password);
+ }
+ if (param_content_user)
+ {
+ content_authentication = std::string(param_content_user);
+ if (param_content_password)
+ content_authentication += "/" + std::string(param_content_password);
+ }
+ SearchablePtr sptr;
+
+ std::map<std::string,SearchablePtr>::iterator it;
+ it = m_p->s_map.find(torus_db);
+ if (it != m_p->s_map.end())
+ sptr = it->second;
+ else if (torus_url.length() > 0)
+ {
+ xmlDoc *doc = mp::get_searchable(package,torus_url, torus_db,
+ realm, m_p->proxy);
+ if (!doc)
+ {
+ *error = YAZ_BIB1_DATABASE_DOES_NOT_EXIST;
+ *addinfo = odr_strdup(odr, database.c_str());
+ BackendPtr b;
+ return b;
+ }
+ const xmlNode *ptr = xmlDocGetRootElement(doc);
+ if (ptr)
+ { // presumably ptr is a records element node
+ // parse first record in document
+ for (ptr = ptr->children; ptr; ptr = ptr->next)
+ {
+ if (ptr->type == XML_ELEMENT_NODE
+ && !strcmp((const char *) ptr->name, "record"))
+ {
+ if (sptr)
+ {
+ *error = YAZ_BIB1_UNSPECIFIED_ERROR;
+ *addinfo = (char*) odr_malloc(odr, 40 + database.length()),
+ sprintf(*addinfo, "multiple records for udb=%s",
+ database.c_str());
+ xmlFreeDoc(doc);
+ BackendPtr b;
+ return b;
+ }
+ sptr = m_p->parse_torus_record(ptr);
+ }
+ }
+ }
+ xmlFreeDoc(doc);