nsprpub/lib/libc/src/plerror.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/lib/libc/src/plerror.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 +** File:plerror.c
    1.11 +** Description: Simple routine to print translate the calling thread's
    1.12 +**  error numbers and print them to "syserr".
    1.13 +*/
    1.14 +
    1.15 +#include "plerror.h"
    1.16 +
    1.17 +#include "prprf.h"
    1.18 +#include "prerror.h"
    1.19 +
    1.20 +PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg)
    1.21 +{
    1.22 +PRErrorCode error = PR_GetError();
    1.23 +PRInt32 oserror = PR_GetOSError();
    1.24 +const char *name = PR_ErrorToName(error);
    1.25 +
    1.26 +	if (NULL != msg) PR_fprintf(fd, "%s: ", msg);
    1.27 +    if (NULL == name)
    1.28 +        PR_fprintf(
    1.29 +			fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
    1.30 +    else
    1.31 +        PR_fprintf(
    1.32 +            fd, "%s(%d), oserror = %d\n",
    1.33 +            name, error, oserror);
    1.34 +}  /* PL_FPrintError */
    1.35 +
    1.36 +PR_IMPLEMENT(void) PL_PrintError(const char *msg)
    1.37 +{
    1.38 +	static PRFileDesc *fd = NULL;
    1.39 +	if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError);
    1.40 +	PL_FPrintError(fd, msg);
    1.41 +}  /* PL_PrintError */
    1.42 +
    1.43 +/* plerror.c */

mercurial