-// Callback. Adds a new entry to the dictionary if necessary
-// This is used in pass 1 to determine layout of dictionary
-// and to load any databases mentioned
-static void prepare_dictionary(struct conf_service *service,
- struct setting *set)
-{
- struct setting_dictionary *dictionary = service->dictionary;
-
- int i;
- char *p;
-
- // If target address is not wildcard, add the database
- if (*set->target && !zurl_wildcard(set->target))
- find_database(set->target, 0, service);
-
- // Determine if we already have a dictionary entry
- if (!strncmp(set->name, "pz:", 3) && (p = strchr(set->name + 3, ':')))
- *(p + 1) = '\0';
- for (i = 0; i < dictionary->num; i++)
- if (!strcmp(dictionary->dict[i], set->name))
- return;
-
- if (!strncmp(set->name, "pz:", 3)) // Probably a typo in config file
- {
- yaz_log(YLOG_FATAL, "Unknown pz: setting '%s'", set->name);
- exit(1);
- }
-
- // Create a new dictionary entry
- // Grow dictionary if necessary
- if (!dictionary->size)
- dictionary->dict =
- nmem_malloc(service->nmem, (dictionary->size = 50) * sizeof(char*));
- else if (dictionary->num + 1 > dictionary->size)
- {
- char **tmp =
- nmem_malloc(service->nmem, dictionary->size * 2 * sizeof(char*));
- memcpy(tmp, dictionary->dict, dictionary->size * sizeof(char*));
- dictionary->dict = tmp;
- dictionary->size *= 2;
- }
- dictionary->dict[dictionary->num++] = nmem_strdup(service->nmem, set->name);
-}
-
-