361 #ifdef HAS_POSIX_REGEXP
373 #ifndef USE_DYNAMIC_MAPS
390 static HTABLE *dict_open_hash;
406 static void dict_open_init(
void)
408 const char *myname =
"dict_open_init";
411 if (dict_open_hash != 0)
412 msg_panic(
"%s: multiple initialization", myname);
415 for (dp = dict_open_info; dp->
type; dp++)
423 char *saved_dict_spec =
mystrdup(dict_spec);
427 if ((dict_name =
split_at(saved_dict_spec,
':')) == 0)
428 msg_fatal(
"open dictionary: expecting \"type:name\" form instead of \"%s\"",
431 dict =
dict_open3(saved_dict_spec, dict_name, open_flags, dict_flags);
440 int open_flags,
int dict_flags)
442 const char *myname =
"dict_open";
447 if (*dict_type == 0 || *dict_name == 0)
448 msg_fatal(
"open dictionary: expecting \"type:name\" form instead of \"%s:%s\"",
449 dict_type, dict_name);
450 if (dict_open_hash == 0)
453 if (dict_open_extend_hook != 0
454 && (open_fn = dict_open_extend_hook(dict_type)) != 0) {
459 return (
dict_surrogate(dict_type, dict_name, open_flags, dict_flags,
460 "unsupported dictionary type: %s", dict_type));
462 if ((dict = dp->
open(dict_name, open_flags, dict_flags)) == 0)
463 return (
dict_surrogate(dict_type, dict_name, open_flags, dict_flags,
464 "cannot open %s:%s: %m", dict_type, dict_name));
466 msg_info(
"%s: %s:%s", myname, dict_type, dict_name);
470 msg_panic(
"%s: attempt to open %s:%s with both \"open\" lock and \"access\" lock",
471 myname, dict_type, dict_name);
479 msg_fatal(
"%s:%s: unable to get exclusive lock: %m",
480 dict_type, dict_name);
493 const char *myname =
"dict_open_register";
497 if (dict_open_hash == 0)
500 msg_panic(
"%s: dictionary type exists: %s", myname, type);
513 old_cb = dict_open_extend_hook;
514 dict_open_extend_hook = new_cb;
520 static int dict_sort_alpha_cpp(
const void *a,
const void *b)
522 return (strcmp(((
char **) a)[0], ((
char **) b)[0]));
534 if (dict_open_hash == 0)
537 for (ht_info = ht =
htable_list(dict_open_hash); *ht; ht++) {
541 if (dict_mapnames_extend_hook != 0)
542 (void) dict_mapnames_extend_hook(mapnames);
543 qsort((
void *) mapnames->
argv, mapnames->
argc,
sizeof(mapnames->
argv[0]),
544 dict_sort_alpha_cpp);
556 old_cb = dict_mapnames_extend_hook;
557 dict_mapnames_extend_hook = new_cb;
574 int main(
int argc,
char **argv)
#define DICT_NEED_UTF8_ACTIVATION(enable, flags)
char * mystrdup(const char *str)
DICT_OPEN_EXTEND_FN dict_open_extend(DICT_OPEN_EXTEND_FN new_cb)
NORETURN msg_panic(const char *fmt,...)
DICT * dict_nisplus_open(const char *, int, int)
int main(int argc, char **argv)
#define MYFLOCK_OP_EXCLUSIVE
DICT * dict_ni_open(const char *, int, int)
DICT * dict_tcp_open(const char *map, int open_flags, int dict_flags)
DEFINE_DICT_LMDB_MAP_SIZE
void argv_add(ARGV *argvp,...)
#define DICT_TYPE_SOCKMAP
DICT_OPEN_FN(* DICT_OPEN_EXTEND_FN)(const char *)
DICT * dict_nis_open(const char *, int, int)
ARGV * argv_alloc(ssize_t len)
#define DICT_FLAG_MULTI_WRITER
DICT * dict_inline_open(const char *name, int open_flags, int dict_flags)
HTABLE * htable_create(ssize_t size)
int(* lock)(struct DICT *, int)
DICT * dict_pipe_open(const char *name, int open_flags, int dict_flags)
#define DICT_TYPE_ENVIRON
DICT * dict_static_open(const char *name, int open_flags, int dict_flags)
HTABLE_INFO ** htable_list(HTABLE *table)
DICT * dict_lmdb_open(const char *, int, int)
DICT * dict_open(const char *dict_spec, int open_flags, int dict_flags)
#define MYFLOCK_OP_NOWAIT
DICT * dict_fail_open(const char *name, int open_flags, int dict_flags)
void dict_type_override(DICT *dict, const char *type)
DICT * dict_thash_open(const char *path, int open_flags, int dict_flags)
void * htable_find(HTABLE *table, const char *key)
DICT * dict_ht_open(const char *name, int unused_open_flags, int dict_flags)
#define DICT_TYPE_NISPLUS
struct DICT *(* open)(const char *, int, int)
DICT * dict_unix_open(const char *map, int open_flags, int dict_flags)
DICT * dict_regexp_open(const char *, int, int)
NORETURN msg_fatal(const char *fmt,...)
DEFINE_DICT_DB_CACHE_SIZE
void(* DICT_MAPNAMES_EXTEND_FN)(ARGV *)
void dict_test(int, char **)
DICT * dict_btree_open(const char *, int, int)
DICT *(* DICT_OPEN_FN)(const char *, int, int)
DICT * dict_pcre_open(const char *, int, int)
void dict_open_register(const char *type, DICT_OPEN_FN open)
#define DICT_TYPE_NETINFO
DICT * dict_union_open(const char *name, int open_flags, int dict_flags)
DICT * dict_env_open(const char *name, int unused_flags, int dict_flags)
DICT * dict_cidr_open(const char *mapname, int open_flags, int dict_flags)
DICT * dict_random_open(const char *name, int open_flags, int dict_flags)
char * split_at(char *string, int delimiter)
DICT * dict_sdbm_open(const char *, int, int)
DICT * dict_dbm_open(const char *, int, int)
DICT * dict_utf8_activate(DICT *)
DICT * dict_sockmap_open(const char *mapname, int open_flags, int dict_flags)
DICT * dict_open3(const char *dict_type, const char *dict_name, int open_flags, int dict_flags)
DICT * dict_cdb_open(const char *, int, int)
DICT_MAPNAMES_EXTEND_FN dict_mapnames_extend(DICT_MAPNAMES_EXTEND_FN new_cb)
DICT * dict_hash_open(const char *, int, int)
#define DICT_FLAG_OPEN_LOCK
DICT * dict_surrogate(const char *dict_type, const char *dict_name, int open_flags, int dict_flags, const char *fmt,...)
#define DICT_FLAG_UTF8_ACTIVE
void * mymalloc(ssize_t len)
void argv_terminate(ARGV *argvp)
HTABLE_INFO * htable_enter(HTABLE *table, const char *key, void *value)
void msg_info(const char *fmt,...)