view src/os/unix/ngx_errno.c @ 4:4b2dafa26fe2 NGINX_0_1_2

nginx 0.1.2 *) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS options in configure. *) Feature: the server_name directive supports *.domain.tld. *) Bugfix: the portability improvements. *) Bugfix: if configuration file was set in command line, the reconfiguration was impossible; bug appeared in 0.1.1. *) Bugfix: proxy module may get caught in an endless loop when sendfile is not used. *) Bugfix: with sendfile the response was not recoded according to the charset module directives; bug appeared in 0.1.1. *) Bugfix: very seldom bug in the kqueue processing. *) Bugfix: the gzip module compressed the proxied responses that was already compressed.
author Igor Sysoev <http://sysoev.ru>
date Thu, 21 Oct 2004 00:00:00 +0400
parents cc9f381affaa
children 80ba094c6b3e
line wrap: on
line source


/*
 * Copyright (C) Igor Sysoev
 */


#include <ngx_config.h>
#include <ngx_core.h>


#if (HAVE_STRERROR_R)

ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
{
    size_t  len;

    if (size == 0) {
        return 0;
    }

    errstr[0] = '\0';

    strerror_r(err, errstr, size);

    for (len = 0; len < size; len++) {
        if (errstr[len] == '\0') {
            break;
        }
    }

    return len;
}

#elif (HAVE_GNU_STRERROR_R)

/* Linux strerror_r() */

ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
{
    char    *str;
    size_t   len;

    if (size == 0) {
        return 0;
    }

    errstr[0] = '\0';

    str = strerror_r(err, errstr, size);

    if (str != errstr) {
        return ngx_cpystrn((u_char *) errstr, (u_char *) str, size)
                                                           - (u_char *) errstr;
    }

    for (len = 0; len < size; len++) {
        if (errstr[len] == '\0') {
            break;
        }
    }

    return len;
}

#endif