tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

plerror.c (1147B)


      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/. */
      5 
      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 */
     11 
     12 #include "plerror.h"
     13 
     14 #include "prprf.h"
     15 #include "prerror.h"
     16 
     17 PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc* fd, const char* msg) {
     18  PRErrorCode error = PR_GetError();
     19  PRInt32 oserror = PR_GetOSError();
     20  const char* name = PR_ErrorToName(error);
     21 
     22  if (NULL != msg) {
     23    PR_fprintf(fd, "%s: ", msg);
     24  }
     25  if (NULL == name)
     26    PR_fprintf(fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
     27  else
     28    PR_fprintf(fd, "%s(%d), oserror = %d\n", name, error, oserror);
     29 } /* PL_FPrintError */
     30 
     31 PR_IMPLEMENT(void) PL_PrintError(const char* msg) {
     32  static PRFileDesc* fd = NULL;
     33  if (NULL == fd) {
     34    fd = PR_GetSpecialFD(PR_StandardError);
     35  }
     36  PL_FPrintError(fd, msg);
     37 } /* PL_PrintError */
     38 
     39 /* plerror.c */