1 #ifndef _DICT_H_INCLUDED_
2 #define _DICT_H_INCLUDED_
21 #define DICT_JMP_BUF jmp_buf
23 #define DICT_JMP_BUF sigjmp_buf
45 #define DICT_OWNER_UNKNOWN (-1)
46 #define DICT_OWNER_TRUSTED (!1)
47 #define DICT_OWNER_UNTRUSTED (!0)
55 #define DICT_OWNER_AGGREGATE_INIT(dst) { \
56 (dst).status = DICT_OWNER_TRUSTED; \
63 #define DICT_OWNER_AGGREGATE_UPDATE(dst, src) do { \
64 if ((dst).status == DICT_OWNER_TRUSTED \
65 || (src).status == DICT_OWNER_UNKNOWN) { \
67 } else if ((dst).status == (src).status \
68 && (dst).uid != (src).uid) { \
69 (dst).status = DICT_OWNER_UNKNOWN; \
82 const char *(*lookup) (
struct DICT *,
const char *);
84 int (*
delete) (
struct DICT *,
const char *);
104 #define DICT_DEBUG(d) ((d)->flags & DICT_FLAG_DEBUG ? dict_debug(d) : (d))
109 #define DICT_FLAG_NONE (0)
110 #define DICT_FLAG_DUP_WARN (1<<0)
111 #define DICT_FLAG_DUP_IGNORE (1<<1)
112 #define DICT_FLAG_TRY0NULL (1<<2)
113 #define DICT_FLAG_TRY1NULL (1<<3)
114 #define DICT_FLAG_FIXED (1<<4)
115 #define DICT_FLAG_PATTERN (1<<5)
116 #define DICT_FLAG_LOCK (1<<6)
117 #define DICT_FLAG_DUP_REPLACE (1<<7)
118 #define DICT_FLAG_SYNC_UPDATE (1<<8)
119 #define DICT_FLAG_DEBUG (1<<9)
121 #define DICT_FLAG_NO_REGSUB (1<<11)
122 #define DICT_FLAG_NO_PROXY (1<<12)
123 #define DICT_FLAG_NO_UNAUTH (1<<13)
124 #define DICT_FLAG_FOLD_FIX (1<<14)
125 #define DICT_FLAG_FOLD_MUL (1<<15)
126 #define DICT_FLAG_FOLD_ANY (DICT_FLAG_FOLD_FIX | DICT_FLAG_FOLD_MUL)
127 #define DICT_FLAG_OPEN_LOCK (1<<16)
128 #define DICT_FLAG_BULK_UPDATE (1<<17)
129 #define DICT_FLAG_MULTI_WRITER (1<<18)
130 #define DICT_FLAG_UTF8_REQUEST (1<<19)
131 #define DICT_FLAG_UTF8_ACTIVE (1<<20)
133 #define DICT_FLAG_UTF8_MASK (DICT_FLAG_UTF8_REQUEST)
158 #define DICT_FLAG_PARANOID \
159 (DICT_FLAG_NO_REGSUB | DICT_FLAG_NO_PROXY | DICT_FLAG_NO_UNAUTH)
160 #define DICT_FLAG_IMPL_MASK (DICT_FLAG_FIXED | DICT_FLAG_PATTERN | \
161 DICT_FLAG_MULTI_WRITER)
162 #define DICT_FLAG_RQST_MASK (DICT_FLAG_FOLD_ANY | DICT_FLAG_LOCK | \
163 DICT_FLAG_DUP_REPLACE | DICT_FLAG_DUP_WARN | \
164 DICT_FLAG_DUP_IGNORE | DICT_FLAG_SYNC_UPDATE | \
165 DICT_FLAG_PARANOID | DICT_FLAG_UTF8_MASK)
166 #define DICT_FLAG_INST_MASK ~(DICT_FLAG_IMPL_MASK | DICT_FLAG_RQST_MASK)
171 #define DICT_NEED_UTF8_ACTIVATION(enable, flags) \
172 ((enable) && ((flags) & DICT_FLAG_UTF8_MASK))
177 #define DICT_ERR_NONE 0
178 #define DICT_ERR_RETRY (-1)
179 #define DICT_ERR_CONFIG (-2)
185 #define DICT_STAT_FAIL 1
186 #define DICT_STAT_SUCCESS 0
187 #define DICT_STAT_ERROR (-1)
192 #define DICT_ERR_VAL_RETURN(dict, err, val) do { \
193 (dict)->error = (err); \
200 #define DICT_SEQ_FUN_FIRST 0
201 #define DICT_SEQ_FUN_NEXT 1
217 extern int dict_update(
const char *,
const char *,
const char *);
218 extern const char *
dict_lookup(
const char *,
const char *);
219 extern int dict_delete(
const char *,
const char *);
220 extern int dict_sequence(
const char *,
const int,
const char **,
const char **);
223 extern const char *
dict_eval(
const char *,
const char *,
int);
236 #define dict_get(dp, key) ((const char *) (dp)->lookup((dp), (key)))
237 #define dict_put(dp, key, val) (dp)->update((dp), (key), (val))
238 #define dict_del(dp, key) (dp)->delete((dp), (key))
239 #define dict_seq(dp, f, key, val) (dp)->sequence((dp), (f), (key), (val))
240 #define dict_close(dp) (dp)->close(dp)
253 const char *(*lookup) (
struct DICT *,
const char *);
275 #define DICT_TYPE_NOFILE "non-existent"
276 #define DICT_TYPE_NOUTF8 "non-UTF-8"
289 #define dict_setjmp(dict) setjmp((dict)->jbuf[0])
290 #define dict_longjmp(dict, val) longjmp((dict)->jbuf[0], (val))
292 #define dict_setjmp(dict) sigsetjmp((dict)->jbuf[0], 1)
293 #define dict_longjmp(dict, val) siglongjmp((dict)->jbuf[0], (val))
295 #define dict_isjmp(dict) ((dict)->jbuf != 0)
void(* close)(struct DICT *)
int dict_delete(const char *, const char *)
const char * dict_lookup(const char *, const char *)
int(* update)(struct DICT *, const char *, const char *)
const char * dict_flags_str(int)
void dict_unregister(const char *)
DICT * dict_open(const char *, int, int)
DICT_OPEN_FN(* DICT_OPEN_EXTEND_FN)(const char *)
int dict_flags_mask(const char *)
DICT * dict_open3(const char *, const char *, int, int)
DICT * dict_handle(const char *)
int(* lock)(struct DICT *, int)
DICT_MAPNAMES_EXTEND_FN dict_mapnames_extend(DICT_MAPNAMES_EXTEND_FN)
int(* update)(struct DICT *, const char *, const char *)
void dict_jmp_alloc(DICT *)
int dict_error(const char *)
int dict_sequence(const char *, const int, const char **, const char **)
void dict_load_fp(const char *, VSTREAM *)
DICT * dict_debug(DICT *)
void dict_type_override(DICT *, const char *)
DICT_OPEN_EXTEND_FN dict_open_extend(DICT_OPEN_EXTEND_FN)
void dict_open_register(const char *, DICT_OPEN_FN)
struct DICT_UTF8_BACKUP DICT_UTF8_BACKUP
const char * dict_changed_name(void)
void(* DICT_WALK_ACTION)(const char *, DICT *, void *)
void(* DICT_MAPNAMES_EXTEND_FN)(ARGV *)
void dict_test(int, char **)
ARGV * dict_mapnames(void)
struct DICT_UTF8_BACKUP * utf8_backup
DICT *(* DICT_OPEN_FN)(const char *, int, int)
struct DICT_OWNER DICT_OWNER
int dict_load_file_xt(const char *, const char *)
void dict_register(const char *, DICT *)
int dict_update(const char *, const char *, const char *)
void dict_walk(DICT_WALK_ACTION, void *)
int(* sequence)(struct DICT *, int, const char **, const char **)
DICT * dict_alloc(const char *, const char *, ssize_t)
DICT * dict_utf8_activate(DICT *)
DICT * PRINTFLIKE(5, 6) dict_surrogate(const char *
const char * dict_eval(const char *, const char *, int)
DICT * dict_surrogate(const char *dict_type, const char *dict_name, int open_flags, int dict_flags, const char *fmt,...)