aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 79b7576..a6357c4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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()
{

Return to:

Send suggestions and report system problems to the System administrator.