aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-31 06:52:52 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-31 06:52:52 +0200
commit4e1310ad8e07a9c470cf66529dd0286f5de9a075 (patch)
treed54b5c5c1b310715f05e2ae470bd10600c0c47ac
parentm (diff)
downloadlibgamma-4e1310ad8e07a9c470cf66529dd0286f5de9a075.tar.gz
libgamma-4e1310ad8e07a9c470cf66529dd0286f5de9a075.tar.bz2
libgamma-4e1310ad8e07a9c470cf66529dd0286f5de9a075.tar.xz
add special support for LIBGAMMA_DEVICE_REQUIRE_GROUP in libgamma_perror
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--info/libgamma.texinfo4
-rw-r--r--src/libgamma-error.c.gpp14
-rw-r--r--src/libgamma-error.h5
3 files changed, 21 insertions, 2 deletions
diff --git a/info/libgamma.texinfo b/info/libgamma.texinfo
index 98c4ca7..2189a9d 100644
--- a/info/libgamma.texinfo
+++ b/info/libgamma.texinfo
@@ -619,6 +619,10 @@ If the error code is the value of @code{LIBGAMMA_ERRNO_SET}
stored in @code{errno}. If the error code is non-negative
(an @code{errno} value`), that value will be stored in
@code{errno} and @code{perror} will be used to print it.
+Additionally, if the error code is the value of
+@code{LIBGAMMA_DEVICE_REQUIRE_GROUP} the required group
+will be printed with its numerical value and, if known,
+its name.
@node GNU Free Documentation License
diff --git a/src/libgamma-error.c.gpp b/src/libgamma-error.c.gpp
index 7e44c0d..9b274ab 100644
--- a/src/libgamma-error.c.gpp
+++ b/src/libgamma-error.c.gpp
@@ -55,7 +55,10 @@ const char* libgamma_group_name = NULL;
* used to print the current error stored in `errno`.
* If `error_code` is non-negative (an `errno` value`), that
* value will be stored in `errno` and `perror` will be
- * used to print it.
+ * used to print it. Additionally, if the `error_code` is
+ * the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the
+ * required group will be printed with its numerical value
+ * and, if known, its name.
*
* @param name The text to add at the beginning.
* @param value The error code, may be an `errno` value.
@@ -69,6 +72,15 @@ void libgamma_perror(const char* name, int error_code)
}
else if (error_code == LIBGAMMA_ERRNO_SET)
perror(name);
+ else if (error_code == LIBGAMMA_DEVICE_REQUIRE_GROUP)
+ {
+ const char* error = libgamma_name_of_error(error_code);
+ long int gid = (long int)libgamma_group_gid;
+ if (libgamma_group_name == NULL)
+ fprintf(stderr, "%s: %s: %ld\n", name, error, gid);
+ else
+ fprintf(stderr, "%s: %s: %s (%lid)\n", name, error, libgamma_group_name, gid);
+ }
else if (error_code < LIBGAMMA_ERROR_MIN)
fprintf(stderr, "%s: (?)\n", name);
else
diff --git a/src/libgamma-error.h b/src/libgamma-error.h
index 1591fe1..06a7077 100644
--- a/src/libgamma-error.h
+++ b/src/libgamma-error.h
@@ -297,7 +297,10 @@ extern const char* libgamma_group_name;
* used to print the current error stored in `errno`.
* If `error_code` is non-negative (an `errno` value`), that
* value will be stored in `errno` and `perror` will be
- * used to print it.
+ * used to print it. Additionally, if the `error_code` is
+ * the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the
+ * required group will be printed with its numerical value
+ * and, if known, its name.
*
* @param name The text to add at the beginning.
* @param value The error code, may be an `errno` value.