Logo Search packages:      
Sourcecode: pulseaudio version File versions

PA_C_DECL_BEGIN const char* pa_cstrerror ( int  errnum  ) 

A wrapper around the standard strerror() function that converts the string to UTF-8. The function is thread safe but the returned string is only guaranteed to exist until the thread exits or pa_cstrerror() is called again from the same thread.

Definition at line 45 of file core-error.c.

    const char *original = NULL;
    char *translated, *t;
    char errbuf[128];

    if ((t = PA_STATIC_TLS_GET(cstrerror)))

#if defined(HAVE_STRERROR_R) && defined(__GLIBC__)
    original = strerror_r(errnum, errbuf, sizeof(errbuf));
#elif defined(HAVE_STRERROR_R)
    if (strerror_r(errnum, errbuf, sizeof(errbuf)) == 0) {
        errbuf[sizeof(errbuf) - 1] = 0;
        original = errbuf;
    /* This might not be thread safe, but we hope for the best */
    original = strerror(errnum);

    if (!original) {
        pa_snprintf(errbuf, sizeof(errbuf), "Unknown error %i", errnum);
        original = errbuf;

    if (!(translated = pa_locale_to_utf8(original))) {
        pa_log_warn("Unable to convert error string to locale, filtering.");
        translated = pa_utf8_filter(original);

    PA_STATIC_TLS_SET(cstrerror, translated);

    return translated;

Generated by  Doxygen 1.6.0   Back to index