135
139
/* associated data structures.
137
141
/* dict_open_register() adds support for a new dictionary type.
143
/* dict_mapnames() returns an ARGV list containing all of the known
144
/* map types, including dynamic maps.
146
/* dict_mkmap_func() returns a pointer to the mkmap setup function
147
/* for the given map type, as given in /etc/dynamicmaps.cf
139
150
/* Fatal error: open error, unsupported dictionary type, attempt to
140
151
/* update non-writable dictionary.
268
305
if (dict_open_hash == 0)
269
306
dict_open_init();
270
if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0)
271
msg_fatal("unsupported dictionary type: %s", dict_type);
307
if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0) {
308
#ifdef NO_DYNAMIC_MAPS
309
msg_fatal("%s: unsupported dictionary type: %s", myname, dict_type);
313
DICT *(*open) (const char *, int, int);
314
DLINFO *dl=dict_open_dlfind(dict_type);
316
msg_fatal("%s: unsupported dictionary type: %s: Is the postfix-%s package installed?", myname, dict_type, dict_type);
317
if (stat(dl->soname,&st) < 0) {
318
msg_fatal("%s: unsupported dictionary type: %s (%s not found. Is the postfix-%s package installed?)",
319
myname, dict_type, dl->soname, dict_type);
321
fn[0].name = dl->openfunc;
322
fn[0].ptr = (void**)&open;
324
load_library_symbols(dl->soname, fn, NULL);
325
dict_open_register(dict_type, open);
326
dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type);
330
msg_info("%s: calling %s open routine",myname,dict_type);
272
332
if ((dict = dp->open(dict_name, open_flags, dict_flags)) == 0)
273
333
msg_fatal("opening %s:%s %m", dict_type, dict_name);
339
dict_mkmap_func_t dict_mkmap_func(const char *dict_type)
341
char *myname="dict_mkmap_func";
344
dict_mkmap_func_t mkmap;
346
#ifndef NO_DYNAMIC_MAPS
348
msg_fatal("dlinfo==NULL");
349
dl=dict_open_dlfind(dict_type);
351
msg_fatal("%s: unsupported dictionary type: %s: Is the postfix-%s package installed?", myname, dict_type, dict_type);
352
if (stat(dl->soname,&st) < 0) {
353
msg_fatal("%s: unsupported dictionary type: %s (%s not found. Is the postfix-%s package installed?)",
354
myname, dict_type, dl->soname, dict_type);
356
fn[0].name = dl->mkmapfunc;
357
fn[0].ptr = (void**)&mkmap;
359
load_library_symbols(dl->soname, fn, NULL);
362
return (void(*)())NULL;
279
366
/* dict_open_register - register dictionary type */
281
368
void dict_open_register(const char *type,
310
400
dp = (DICT_OPEN_INFO *) ht[0]->value;
311
401
argv_add(mapnames, dp->type, ARGV_END);
403
#ifndef NO_DYNAMIC_MAPS
405
msg_fatal("dlinfo==NULL");
406
for (dlp=dict_dlinfo; dlp->pattern; dlp++) {
407
argv_add(mapnames, dlp->pattern, ARGV_END);
313
410
myfree((char *) ht_info);
314
411
argv_terminate(mapnames);
415
#ifndef NO_DYNAMIC_MAPS
416
#define STREQ(x,y) (x == y || (x[0] == y[0] && strcmp(x,y) == 0))
418
void dict_open_dlinfo(const char *path)
420
char *myname="dict_open_dlinfo";
421
VSTREAM *conf_fp=vstream_fopen(path,O_RDONLY,0);
422
VSTRING *buf = vstring_alloc(100);
429
dict_dlinfo=(DLINFO*)mvect_alloc(&vector,sizeof(DLINFO),3,NULL,NULL);
432
msg_warn("%s: cannot open %s. No dynamic maps will be allowed.",
435
while (vstring_get_nonl(buf,conf_fp) != VSTREAM_EOF) {
436
cp = vstring_str(buf);
438
if (*cp == '#' || *cp == '\0')
440
argv = argv_split(cp, " \t");
441
if (argv->argc != 3 && argv->argc != 4) {
442
msg_fatal("%s: Expected \"pattern .so-name open-function [mkmap-function]\" at line %d",
445
if (STREQ(argv->argv[0],"*")) {
446
msg_warn("%s: wildcard dynamic map entry no longer supported.",
450
if (argv->argv[1][0] != '/') {
451
msg_fatal("%s: .so name must begin with a \"/\" at line %d",
454
if (nelm >= vector.nelm) {
455
dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+3);
457
dict_dlinfo[nelm].pattern = mystrdup(argv->argv[0]);
458
dict_dlinfo[nelm].soname = mystrdup(argv->argv[1]);
459
dict_dlinfo[nelm].openfunc = mystrdup(argv->argv[2]);
461
dict_dlinfo[nelm].mkmapfunc = mystrdup(argv->argv[3]);
463
dict_dlinfo[nelm].mkmapfunc = NULL;
468
if (nelm >= vector.nelm) {
469
dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+1);
471
dict_dlinfo[nelm].pattern = NULL;
472
dict_dlinfo[nelm].soname = NULL;
473
dict_dlinfo[nelm].openfunc = NULL;
474
dict_dlinfo[nelm].mkmapfunc = NULL;
476
vstream_fclose(conf_fp);
480
static DLINFO *dict_open_dlfind(const char *type)
487
for (dp=dict_dlinfo; dp->pattern; dp++) {
488
if (STREQ(dp->pattern,type))
494
#endif /* !NO_DYNAMIC_MAPS */