diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -18,6 +18,36 @@ #include <termios.h> #include <sys/ioctl.h> +int translate_option; + +void +translate_ids(int argc, char **argv, const char *mapname) +{ + int i; + struct eclat_map *map; + char *val; + + if (!translate_option) + return; + map = eclat_map_lookup(mapname); + if (!map) + die(EX_UNAVAILABLE, "no such map: %s", mapname); + + if (eclat_map_open(map) != eclat_map_ok) + exit(EX_UNAVAILABLE); + + for (i = 0; i < argc; i++) { + if (!strchr(argv[i], '=')) { + int rc = eclat_map_get(map, argv[i], &val); + if (rc != eclat_map_ok) { + die(EX_UNAVAILABLE, "cannot translate %s: %s", + argv[i], eclat_map_strerror(rc)); + } + argv[i] = val; + } + } +} + int get_scr_cols() { |