69 #define STR(x) vstring_str(x)
73 static const char *dict_union_lookup(
DICT *dict,
const char *query)
75 static const char myname[] =
"dict_union_lookup";
80 const char *result = 0;
86 for (cpp = dict_union->
map_union->
argv; (dict_type_name = *cpp) != 0; cpp++) {
88 msg_panic(
"%s: dictionary \"%s\" not found", myname, dict_type_name);
89 if ((result =
dict_get(map, query)) != 0) {
93 }
else if (map->
error != 0) {
104 static void dict_union_close(
DICT *dict)
108 char *dict_type_name;
110 for (cpp = dict_union->
map_union->
argv; (dict_type_name = *cpp) != 0; cpp++)
121 static const char myname[] =
"dict_union_open";
123 char *saved_name = 0;
124 char *dict_type_name;
135 #define DICT_UNION_RETURN(x) do { \
136 if (saved_name != 0) \
137 myfree(saved_name); \
146 if (open_flags != O_RDONLY)
148 open_flags, dict_flags,
149 "%s:%s map requires O_RDONLY access mode",
156 || *(saved_name =
mystrndup(name + 1, len - 2)) == 0
160 open_flags, dict_flags,
161 "bad syntax: \"%s:%s\"; "
162 "need \"%s:{type:name...}\"",
171 for (cpp = argv->
argv; (dict_type_name = *cpp) != 0; cpp++) {
173 msg_info(
"%s: %s", myname, dict_type_name);
174 if (strchr(dict_type_name,
':') == 0)
176 open_flags, dict_flags,
177 "bad syntax: \"%s:%s\"; "
178 "need \"%s:{type:name...}\"",
182 dict =
dict_open(dict_type_name, open_flags, dict_flags);
185 if (cpp == argv->
argv)
195 dict_union->
dict.
close = dict_union_close;
196 dict_union->
dict.
flags = dict_flags | match_flags;
void dict_register(const char *dict_name, DICT *dict_info)
#define DICT_OWNER_AGGREGATE_UPDATE(dst, src)
ARGV * argv_free(ARGV *argvp)
void(* close)(struct DICT *)
NORETURN msg_panic(const char *fmt,...)
#define DICT_OWNER_AGGREGATE_INIT(dst)
#define DICT_UNION_RETURN(x)
DICT * dict_open(const char *, int, int)
void dict_unregister(const char *dict_name)
#define VSTRING_ADDCH(vp, ch)
ARGV * argv_splitq(const char *, const char *, const char *)
#define dict_get(dp, key)
#define VSTRING_RESET(vp)
DICT * dict_handle(const char *dict_name)
VSTRING * vstring_alloc(ssize_t len)
const char *(* lookup)(struct DICT *, const char *)
#define DICT_ERR_VAL_RETURN(dict, err, val)
#define DICT_FLAG_PATTERN
char * mystrndup(const char *str, ssize_t len)
size_t balpar(const char *string, const char *parens)
DICT * dict_union_open(const char *name, int open_flags, int dict_flags)
VSTRING * vstring_free(VSTRING *vp)
DICT * dict_alloc(const char *, const char *, ssize_t)
VSTRING * vstring_strcat(VSTRING *vp, const char *src)
DICT * dict_surrogate(const char *dict_type, const char *dict_name, int open_flags, int dict_flags, const char *fmt,...)
void msg_info(const char *fmt,...)