aboutsummaryrefslogtreecommitdiff
path: root/lib/libeclat.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-12-15 20:57:55 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2012-12-15 20:57:55 +0200
commite60288d595ec405c5d416e5da54b516e65f8a8c5 (patch)
treed88aaa4352658be717b463ca60c05d85b41d1cd0 /lib/libeclat.h
parent00110918072f77e0e5705e93ad91207f1bd0d873 (diff)
downloadeclat-e60288d595ec405c5d416e5da54b516e65f8a8c5.tar.gz
eclat-e60288d595ec405c5d416e5da54b516e65f8a8c5.tar.bz2
Implement direct and reverse map lookups.
Not all maps support reverse lookups generically (for example, gdbm does not), therefore introduce a new "bidi" (bi-directional) map, which is a compound of two maps, each one used for a particular lookup direction. * lib/Makefile.am (maps): List all maps here. * lib/bidimap.c: New file. Implementation of a bi-directional map. * lib/filemap.c: Update to the changes in API. Implement reverse lookup. * lib/gdbmmap.c: Update to the changes in API. * lib/nullmap.c: Likewise. * lib/seqmap.c: Likewise. * lib/ldapmap.c: Update to the changes in API. Implement reverse lookup. New configuration keywords: reverse-filter, reverse-attr. * lib/libeclat.h (eclat_map_drv) <map_get>: Change signature, take search direction as a new argument. (eclat_map_get): Likewise. (eclat_map) <eclat_map_bad_dir>: New status code. (MAP_DIR, MAP_REV): New macros. (eclat_map_name_split): New function. (eclat_map_drv_bidi): New extern. * lib/map.c (eclat_map_get): Change signature, take search direction as a new argument. Pass new keyword to the "key" translation: "dir". (eclat_map_strerror): Handle new status code. (eclat_map_name_split): New function. * src/eclat.c (main): Register eclat_map_drv_bidi. * src/util.c (translate_ids): Use eclat_map_name_split to obtain direction code from the map name. (translate_resource_ids): Use direct lookups. * tests/Makefile.am: Add new testcases. * tests/testsuite.at: Likewise. * tests/bidimap.at: New testcase. * tests/filemap.at: Test reverse lookups.
Diffstat (limited to 'lib/libeclat.h')
-rw-r--r--lib/libeclat.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libeclat.h b/lib/libeclat.h
index a558dae..a0ae6d7 100644
--- a/lib/libeclat.h
+++ b/lib/libeclat.h
@@ -129,7 +129,7 @@ struct eclat_map_drv {
int (*map_config)(int, struct grecs_node *, void *);
int (*map_open)(int, void *);
int (*map_close)(int, void *);
- int (*map_get)(int, void *, const char *, char **);
+ int (*map_get)(int, int, void *, const char *, char **);
void (*map_free)(int, void *);
void (*map_confhelp)(void);
};
@@ -145,22 +145,29 @@ struct eclat_map {
enum eclat_map_status {
eclat_map_ok,
eclat_map_failure,
+ eclat_map_bad_dir,
eclat_map_not_found
};
+#define MAP_DIR 0
+#define MAP_REV 1
+
void eclat_map_init(void);
struct eclat_map *eclat_map_lookup(const char *name);
int eclat_map_config(struct grecs_node *node, struct eclat_map **return_map);
void eclat_map_free(struct eclat_map *map);
int eclat_map_open(struct eclat_map *map);
int eclat_map_close(struct eclat_map *map);
-int eclat_map_get(struct eclat_map *map, const char *key, char **value);
+int eclat_map_get(struct eclat_map *map, int dir, const char *key,
+ char **value);
const char *eclat_map_strerror(int rc);
int eclat_map_drv_register(struct eclat_map_drv *drv);
void eclat_map_foreach(int (*fun)(struct eclat_map *, void *), void *data);
void eclat_map_free_all(void);
void eclat_map_confhelp(void);
+int eclat_map_name_split(const char *mapname, char **name, char **endp);
+
int eclat_get_string_node(struct grecs_node *node, const char *name,
int optional,
struct grecs_node **pret);
@@ -170,3 +177,4 @@ extern struct eclat_map_drv eclat_map_drv_gdbm;
extern struct eclat_map_drv eclat_map_drv_ldap;
extern struct eclat_map_drv eclat_map_drv_null;
extern struct eclat_map_drv eclat_map_drv_seq;
+extern struct eclat_map_drv eclat_map_drv_bidi;

Return to:

Send suggestions and report system problems to the System administrator.