diff options
author | Theodore Ts'o <tytso@mit.edu> | 2010-03-14 19:34:53 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-03-15 00:14:12 -0400 |
commit | 1601b10e65a55a1f8e4b262fa295cdab8cb5d98d (patch) | |
tree | 3a17a5e2493bbc45a61fdeda24f2e76469215d98 /lib | |
parent | 59119646bd7e079aaed70366c405322d2dc7fa53 (diff) | |
download | e2fsprogs-1601b10e65a55a1f8e4b262fa295cdab8cb5d98d.tar.gz |
libcom_err: Add support for Heimdal com_right_r function()
Addresses-Sourceforge-Bug: #2963865
Addresses-Debian-Bug: #558910
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/et/com_err.h | 2 | ||||
-rw-r--r-- | lib/et/com_right.c | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/et/com_err.h b/lib/et/com_err.h index de0146e2..eb2106fa 100644 --- a/lib/et/com_err.h +++ b/lib/et/com_err.h @@ -16,6 +16,7 @@ #define COM_ERR_ATTR(x) #endif +#include <stddef.h> #include <stdarg.h> typedef long errcode_t; @@ -49,6 +50,7 @@ extern void add_to_error_table(struct et_list *new_table); /* Provided for Heimdall compatibility */ extern const char *com_right(struct et_list *list, long code); +extern const char *com_right_r(struct et_list *list, long code, char *str, size_t len); extern void initialize_error_table_r(struct et_list **list, const char **messages, int num_errors, diff --git a/lib/et/com_right.c b/lib/et/com_right.c index 173fd1a3..f00e9104 100644 --- a/lib/et/com_right.c +++ b/lib/et/com_right.c @@ -55,6 +55,21 @@ com_right(struct et_list *list, long code) return NULL; } +const char * +com_right_r(struct et_list *list, long code, char *str, size_t len) +{ + struct et_list *p; + for (p = list; p; p = p->next) { + if ((code >= p->table->base) && + (code < p->table->base + p->table->n_msgs)) { + strncpy(str, p->table->msgs[code - p->table->base], len); + str[len-1] = '\0'; + return str; + } + } + return NULL; +} + struct foobar { struct et_list etl; struct error_table tab; |