From: Theodore Ts'o Date: Sun, 14 Mar 2010 23:34:53 +0000 (-0400) Subject: libcom_err: Add support for Heimdal com_right_r function() X-Git-Tag: v1.41.11~4 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=1601b10e65a55a1f8e4b262fa295cdab8cb5d98d;p=tools%2Fe2fsprogs.git libcom_err: Add support for Heimdal com_right_r function() Addresses-Sourceforge-Bug: #2963865 Addresses-Debian-Bug: #558910 Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/et/com_err.h b/lib/et/com_err.h index de0146e..eb2106f 100644 --- a/lib/et/com_err.h +++ b/lib/et/com_err.h @@ -16,6 +16,7 @@ #define COM_ERR_ATTR(x) #endif +#include #include 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 173fd1a..f00e910 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;