nsprpub/lib/libc/src/plerror.c

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /*
     7 ** File:plerror.c
     8 ** Description: Simple routine to print translate the calling thread's
     9 **  error numbers and print them to "syserr".
    10 */
    12 #include "plerror.h"
    14 #include "prprf.h"
    15 #include "prerror.h"
    17 PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg)
    18 {
    19 PRErrorCode error = PR_GetError();
    20 PRInt32 oserror = PR_GetOSError();
    21 const char *name = PR_ErrorToName(error);
    23 	if (NULL != msg) PR_fprintf(fd, "%s: ", msg);
    24     if (NULL == name)
    25         PR_fprintf(
    26 			fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
    27     else
    28         PR_fprintf(
    29             fd, "%s(%d), oserror = %d\n",
    30             name, error, oserror);
    31 }  /* PL_FPrintError */
    33 PR_IMPLEMENT(void) PL_PrintError(const char *msg)
    34 {
    35 	static PRFileDesc *fd = NULL;
    36 	if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError);
    37 	PL_FPrintError(fd, msg);
    38 }  /* PL_PrintError */
    40 /* plerror.c */

mercurial