aboutsummaryrefslogtreecommitdiff
path: root/lib/map.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-10-08 17:36:05 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-10-08 17:36:05 +0300
commit9b56a5b05db6630a667ad0c9b16ec45a4e52044d (patch)
treeeca8c25be90428656c24f76f68899c22d0091528 /lib/map.c
parent04f58aaf7a6f27e3b79e8f5ccffeb006db56aeaf (diff)
downloadeclat-9b56a5b05db6630a667ad0c9b16ec45a4e52044d.tar.gz
eclat-9b56a5b05db6630a667ad0c9b16ec45a4e52044d.tar.bz2
Improve LDAP map.
* lib/expand.c: New file. * lib/getans.c: New file. * lib/Makefile.am: Add new files. * lib/ldapmap.c (ldap_map) <passfile,prompt>: New members. (ldapmap_kw) <passfile,prompt>: New keywords. (ldap_map_open): Prompt for undefined credentials if the "prompt" statement is set to true. (ldap_map_get): Use eclat_expand_kw to expand the filter. * lib/libeclat.h (eclat_trimnl,eclat_getans) (eclat_expand_kw): New protos. * lib/map.c (eclat_map_get): Use eclat_expand_kw. * src/eclat.c (read_format): Likewise.
Diffstat (limited to 'lib/map.c')
-rw-r--r--lib/map.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/lib/map.c b/lib/map.c
index 5a8d2fd..c8acfee 100644
--- a/lib/map.c
+++ b/lib/map.c
@@ -242,7 +242,7 @@ int
eclat_map_get(struct eclat_map *map, const char *key, char **value)
{
int rc;
- struct wordsplit ws;
+ char *p = NULL;
debug(map_dbg, 1,
("looking up \"%s\" in map \"%s\"", key, map->name));
@@ -252,30 +252,23 @@ eclat_map_get(struct eclat_map *map, const char *key, char **value)
}
if (map->keytrans) {
- const char *kve[5];
- kve[0] = "key";
- kve[1] = key;
- kve[2] = "map";
- kve[3] = map->name;
- kve[4] = NULL;
-
- ws.ws_env = kve;
+ const char *kwe[5];
+ kwe[0] = "key";
+ kwe[1] = key;
+ kwe[2] = "map";
+ kwe[3] = map->name;
+ kwe[4] = NULL;
- if (wordsplit(map->keytrans, &ws,
- WRDSF_NOSPLIT | WRDSF_NOCMD |
- WRDSF_ENV | WRDSF_ENV_KV))
- die(EX_SOFTWARE, "error transforming key: %s",
- wordsplit_strerror(&ws));
+ p = eclat_expand_kw(map->keytrans, kwe);
debug(map_dbg, 1,
("transformed key \"%s\" => \"%s\"",
- key, ws.ws_wordv[0]));
- key = ws.ws_wordv[0];
+ key, p));
+ key = p;
}
rc = map->drv->map_get(map_dbg, map->data, key, value);
- if (map->keytrans)
- wordsplit_free(&ws);
+ free(p);
debug(map_dbg, 1, ("result: \"%s\"", eclat_map_strerror(rc)));
if (rc == eclat_map_ok)

Return to:

Send suggestions and report system problems to the System administrator.