diff options
Diffstat (limited to 'set_error.c')
-rw-r--r-- | set_error.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/set_error.c b/set_error.c index a44aac6..e7a16ac 100644 --- a/set_error.c +++ b/set_error.c @@ -8,6 +8,7 @@ liberror_set_error(const char description[256], const char source[64], const cha struct liberror_error *cause = NULL, *old; struct liberror_error *error; int have_cause = 0, saved_errno; + const char *errstr; old = liberror_get_error(); if (old) { @@ -29,6 +30,24 @@ liberror_set_error(const char description[256], const char source[64], const cha } else if (!strcmp(code_group, "errno")) { if (code >= (long long int)INT_MIN && code <= (long long int)INT_MAX) strerror_r((int)code, error->description, sizeof(error->description)); + } else if (!strcmp(code_group, "h_errno")) { + if (code >= (long long int)INT_MIN && code <= (long long int)INT_MAX) { + saved_errno = errno; + errstr = hstrerror(code); + if (errstr) + strncpy(error->description, errstr, sizeof(error->description)); + errno = saved_errno; + } + } else if (!strcmp(code_group, "addrinfo")) { + if (code == (long long int)EAI_SYSTEM) { + strerror_r(errno, error->description, sizeof(error->description)); + } else if (code >= (long long int)INT_MIN && code <= (long long int)INT_MAX) { + saved_errno = errno; + errstr = gai_strerror(code); + if (errstr) + strncpy(error->description, errstr, sizeof(error->description)); + errno = saved_errno; + } } stpcpy(error->source, source); stpcpy(error->code_group, code_group); |