aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-04-26 17:18:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2013-04-26 17:48:21 +0300
commit699ba6cd496d8401959a0581a1d49c448d3f3c7c (patch)
treee576553ef6531cdf7b1f9b375036f9dd28f2332d /src/util.c
parentaf02bbe4ab84ddd6a5ec8da3bab0fa360e8bded2 (diff)
downloadeclat-699ba6cd496d8401959a0581a1d49c448d3f3c7c.tar.gz
eclat-699ba6cd496d8401959a0581a1d49c448d3f3c7c.tar.bz2
Improve ID mapping.
* doc/eclat.conf.5: Update. * src/cmdline.opt: New option --no-translate (-X) * src/config.c (eclat_kw): New statement: translate. * src/eclat.c (main): override the value of translation_enabled from the command line. * src/eclat.h (translate_option): Rename to translation_enabled. All uses changed. (MAP_IMAGE,MAP_INSTANCE) (MAP_GROUPID,MAP_GROUPNAME) (MAP_SNAPSHOT,MAP_VOLUME) (MAP_AZ,MAP_REG): New defines, to use instead of literal map names. All sources updated accordingly. * src/util.c (translate_option): Rename to translation_enabled. (translate_ids): It is not an error if the name is not found in the map. Use it as the resource ID in that case.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/util.c b/src/util.c
index 65b8385..85a7e02 100644
--- a/src/util.c
+++ b/src/util.c
@@ -18,7 +18,7 @@
#include <termios.h>
#include <sys/ioctl.h>
-int translate_option;
+int translation_enabled;
char *custom_map;
void
@@ -29,8 +29,9 @@ translate_ids(int argc, char **argv, const char *mapname)
char *val;
char *q, *realname;
int dir;
+ int rc;
- if (!translate_option || argc == 0)
+ if (!translation_enabled || argc == 0)
return;
if (custom_map)
mapname = custom_map;
@@ -50,12 +51,21 @@ translate_ids(int argc, char **argv, const char *mapname)
for (i = 0; i < argc; i++) {
if (!strchr(argv[i], '=')) {
- int rc = eclat_map_get(map, dir, argv[i], &val);
- if (rc != eclat_map_ok) {
+ switch (rc = eclat_map_get(map, dir, argv[i], &val)) {
+ case eclat_map_ok:
+ argv[i] = val;
+ break;
+
+ case eclat_map_not_found:
+ debug(ECLAT_DEBCAT_MAIN, 1,
+ ("%s not found in map %s",
+ argv[i], mapname));
+ break;
+
+ default:
die(EX_UNAVAILABLE, "cannot translate %s: %s",
argv[i], eclat_map_strerror(rc));
}
- argv[i] = val;
}
}
}
@@ -81,7 +91,7 @@ translate_resource_ids(int argc, char **argv)
struct wordsplit ws;
int wsflags = WRDSF_DEFFLAGS|WRDSF_DELIM;
- if (!translate_option || argc == 0)
+ if (!translation_enabled || argc == 0)
return;
ws.ws_delim = ",";
for (i = 0; i < argc; i++) {

Return to:

Send suggestions and report system problems to the System administrator.