VirtualBox

Ignore:
Timestamp:
Nov 21, 2023 1:46:00 PM (14 months ago)
Author:
vboxsync
Message:

libs/xpcom: Remove unused error handling code, bugref:10545

Location:
trunk/src/libs/xpcom18a4/nsprpub/pr
Files:
4 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/prerror.h

    r11551 r102207  
    4343#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
    4444#define PR_SetError VBoxNsprPR_SetError
    45 #define PR_SetErrorText VBoxNsprPR_SetErrorText
    46 #define PR_GetError VBoxNsprPR_GetError
    47 #define PR_GetOSError VBoxNsprPR_GetOSError
    48 #define PR_GetErrorTextLength VBoxNsprPR_GetErrorTextLength
    49 #define PR_GetErrorText VBoxNsprPR_GetErrorText
    50 #define PR_ErrorToString VBoxNsprPR_ErrorToString
    51 #define PR_ErrorToName VBoxNsprPR_ErrorToName
    52 #define PR_ErrorLanguages VBoxNsprPR_ErrorLanguages
    53 #define PR_ErrorInstallTable VBoxNsprPR_ErrorInstallTable
    54 #define PR_ErrorInstallCallback VBoxNsprPR_ErrorInstallCallback
    5545#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
    5646PR_BEGIN_EXTERN_C
     
    7060NSPR_API(void) PR_SetError(PRErrorCode errorCode, PRInt32 oserr);
    7161
    72 /*
    73 ** The text value specified may be NULL. If it is not NULL and the text length
    74 ** is zero, the string is assumed to be a null terminated C string. Otherwise
    75 ** the text is assumed to be the length specified and possibly include NULL
    76 ** characters (e.g., a multi-national string).
    77 **
    78 ** The text will be copied into to thread structure and remain there
    79 ** until the next call to PR_SetError.
    80 */
    81 NSPR_API(void) PR_SetErrorText(
    82     PRIntn textLength, const char *text);
    83 
    84 /*
    85 ** Return the current threads last set error code.
    86 */
    87 NSPR_API(PRErrorCode) PR_GetError(void);
    88 
    89 /*
    90 ** Return the current threads last set os error code. This is used for
    91 ** machine specific code that desires the underlying os error.
    92 */
    93 NSPR_API(PRInt32) PR_GetOSError(void);
    94 
    95 /*
    96 ** Get the length of the error text. If a zero is returned, then there
    97 ** is no text. Otherwise, the value returned is sufficient to contain
    98 ** the error text currently available.
    99 */
    100 NSPR_API(PRInt32) PR_GetErrorTextLength(void);
    101 
    102 /*
    103 ** Copy the current threads current error text. Then actual number of bytes
    104 ** copied is returned as the result. If the result is zero, the 'text' area
    105 ** is unaffected.
    106 */
    107 NSPR_API(PRInt32) PR_GetErrorText(char *text);
    108 
    109 
    110 /*
    111 Copyright (C) 1987, 1988 Student Information Processing Board of the
    112 Massachusetts Institute of Technology.
    113 
    114 Permission to use, copy, modify, and distribute this software and its
    115 documentation for any purpose and without fee is hereby granted, provided
    116 that the above copyright notice appear in all copies and that both that
    117 copyright notice and this permission notice appear in supporting
    118 documentation, and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
    119 used in advertising or publicity pertaining to distribution of the software
    120 without specific, written prior permission.  M.I.T. and the M.I.T. S.I.P.B.
    121 make no representations about the suitability of this software for any
    122 purpose.  It is provided "as is" without express or implied warranty.
    123 */
    124 
    125 
    126 /*
    127  * NOTE:
    128  *              The interfaces for error-code-translation described in the rest of
    129  *              this file are preliminary in the 3.1 release of nspr and are subject
    130  *              to change in future releases.
    131  */
    132 
    133 /*
    134 ** Description: Localizable error code to string function.
    135 **
    136 **
    137 ** NSPR provides a mechanism for converting an error code to a
    138 ** descriptive string, in a caller-specified language.
    139 **
    140 ** Error codes themselves are 32 bit (signed) integers.  Typically,
    141 ** the high order 24 bits are an identifier of which error table the
    142 ** error code is from, and the low order 8 bits are a sequential error
    143 ** number within the table.  NSPR supports error tables whose first
    144 ** error code is not a multiple of 256, such error code assignments
    145 ** should be avoided when possible.
    146 **
    147 ** Error table 0 is defined to match the UNIX system call error table
    148 ** (sys_errlist); this allows errno values to be used directly in the
    149 ** library.  Other error table numbers are typically formed by
    150 ** compacting together the first four characters of the error table
    151 ** name.  The mapping between characters in the name and numeric
    152 ** values in the error code are defined in a system-independent
    153 ** fashion, so that two systems that can pass integral values between
    154 ** them can reliably pass error codes without loss of meaning; this
    155 ** should work even if the character sets used are not the
    156 ** same. (However, if this is to be done, error table 0 should be
    157 ** avoided, since the local system call error tables may differ.)
    158 **
    159 ** Libraries defining error codes need only provide a table mapping
    160 ** error code numbers to names and default English descriptions,
    161 ** calling a routine to install the table, making it ``known'' to NSPR
    162 ** library.  Once installed, a table may not be removed.  Any error
    163 ** code the library generates can be converted to the corresponding
    164 ** error message.  There is also a default format for error codes
    165 ** accidentally returned before making the table known, which is of
    166 ** the form "unknown code foo 32", where "foo" would be the name of
    167 ** the table.
    168 **
    169 ** Normally, the error code conversion routine only supports the
    170 ** languages "i-default" and "en", returning the error-table-provided
    171 ** English description for both languages.  The application may
    172 ** provide a localization plugin, allowing support for additional
    173 ** languages.
    174 **
    175 **/
    176 
    177 /**********************************************************************/
    178 /************************* TYPES AND CONSTANTS ************************/
    179 /**********************************************************************/
    180 
    181 /*
    182  * PRLanguageCode --
    183  *
    184  *    NSPR represents a language code as a non-negative integer.
    185  *    Languages 0 is always "i-default" the language you get without
    186  *    explicit negotiation.  Language 1 is always "en", English
    187  *    which has been explicitly negotiated.  Additional language
    188  *    codes are defined by an application-provided localization plugin.
    189  */
    190 typedef PRUint32 PRLanguageCode;
    191 #define PR_LANGUAGE_I_DEFAULT 0 /* i-default, the default language */
    192 #define PR_LANGUAGE_EN 1 /* English, explicitly negotiated */
    193 
    194 /*
    195  * struct PRErrorMessage --
    196  *
    197  *    An error message in an error table.
    198  */
    199 struct PRErrorMessage {
    200     const char * name;    /* Macro name for error */
    201     const char * en_text; /* Default English text */
    202 };
    203 
    204 /*
    205  * struct PRErrorTable --
    206  *
    207  *    An error table, provided by a library.
    208  */
    209 struct PRErrorTable {
    210     const struct PRErrorMessage * msgs; /* Array of error information */
    211     const char *name; /* Name of error table source */
    212     PRErrorCode base; /* Error code for first error in table */
    213     int n_msgs; /* Number of codes in table */
    214 };
    215 
    216 /*
    217  * struct PRErrorCallbackPrivate --
    218  *
    219  *    A private structure for the localization plugin
    220  */
    221 struct PRErrorCallbackPrivate;
    222 
    223 /*
    224  * struct PRErrorCallbackTablePrivate --
    225  *
    226  *    A data structure under which the localization plugin may store information,
    227  *    associated with an error table, that is private to itself.
    228  */
    229 struct PRErrorCallbackTablePrivate;
    230 
    231 /*
    232  * PRErrorCallbackLookupFn --
    233  *
    234  *    A function of PRErrorCallbackLookupFn type is a localization
    235  *    plugin callback which converts an error code into a description
    236  *    in the requested language.  The callback is provided the
    237  *    appropriate error table, private data for the plugin and the table.
    238  *    The callback returns the appropriate UTF-8 encoded description, or NULL
    239  *    if no description can be found.
    240  */
    241 typedef const char *
    242 PRErrorCallbackLookupFn(PRErrorCode code, PRLanguageCode language,
    243                    const struct PRErrorTable *table,
    244                    struct PRErrorCallbackPrivate *cb_private,
    245                    struct PRErrorCallbackTablePrivate *table_private);
    246 
    247 /*
    248  * PRErrorCallbackNewTableFn --
    249  *
    250  *    A function PRErrorCallbackNewTableFn type is a localization plugin
    251  *    callback which is called once with each error table registered
    252  *    with NSPR.  The callback is provided with the error table and
    253  *    the plugin's private structure.  The callback returns any table private
    254  *    data it wishes to associate with the error table.  Does not need to be thread
    255  *    safe.
    256  */
    257 typedef struct PRErrorCallbackTablePrivate *
    258 PRErrorCallbackNewTableFn(const struct PRErrorTable *table,
    259                         struct PRErrorCallbackPrivate *cb_private);
    260 
    261 /**********************************************************************/
    262 /****************************** FUNCTIONS *****************************/
    263 /**********************************************************************/
    264 
    265 /***********************************************************************
    266 ** FUNCTION:    PR_ErrorToString
    267 ** DESCRIPTION:
    268 **  Returns the UTF-8 message for an error code in
    269 **  the requested language.  May return the message
    270 **  in the default language if a translation in the requested
    271 **  language is not available.  The returned string is
    272 **  valid for the duration of the process.  Never returns NULL.
    273 **
    274 ***********************************************************************/
    275 NSPR_API(const char *) PR_ErrorToString(PRErrorCode code,
    276     PRLanguageCode language);
    277 
    278 
    279 /***********************************************************************
    280 ** FUNCTION:    PR_ErrorToName
    281 ** DESCRIPTION:
    282 **  Returns the macro name for an error code, or NULL
    283 **  if the error code is not known.  The returned string is
    284 **  valid for the duration of the process.
    285 **
    286 **  Does not work for error table 0, the system error codes.
    287 **
    288 ***********************************************************************/
    289 NSPR_API(const char *) PR_ErrorToName(PRErrorCode code);
    290 
    291 
    292 /***********************************************************************
    293 ** FUNCTION:    PR_ErrorLanguages
    294 ** DESCRIPTION:
    295 **  Returns the RFC 1766 language tags for the language
    296 **  codes PR_ErrorToString() supports.  The returned array is valid
    297 **  for the duration of the process.  Never returns NULL.  The first
    298 **  item in the returned array is the language tag for PRLanguageCode 0,
    299 **  the second is for PRLanguageCode 1, and so on.  The array is terminated
    300 **  with a null pointer.
    301 **
    302 ***********************************************************************/
    303 NSPR_API(const char * const *) PR_ErrorLanguages(void);
    304 
    305 
    306 /***********************************************************************
    307 ** FUNCTION:    PR_ErrorInstallTable
    308 ** DESCRIPTION:
    309 **  Registers an error table with NSPR.  Must be done exactly once per
    310 **  table.  Memory pointed to by `table' must remain valid for the life
    311 **  of the process.
    312 **
    313 **  NOT THREAD SAFE!
    314 ** 
    315 ***********************************************************************/
    316 NSPR_API(PRErrorCode) PR_ErrorInstallTable(const struct PRErrorTable *table);
    317 
    318 
    319 /***********************************************************************
    320 ** FUNCTION:    PR_ErrorInstallCallback
    321 ** DESCRIPTION:
    322 **  Registers an error localization plugin with NSPR.  May be called
    323 **  at most one time.  `languages' contains the language codes supported
    324 **  by this plugin.  Languages 0 and 1 must be "i-default" and "en"
    325 **  respectively.  `lookup' and `newtable' contain pointers to
    326 **  the plugin callback functions.  `cb_private' contains any information
    327 **  private to the plugin functions.
    328 **
    329 **  NOT THREAD SAFE!
    330 **
    331 ***********************************************************************/
    332 NSPR_API(void) PR_ErrorInstallCallback(const char * const * languages,
    333                               PRErrorCallbackLookupFn *lookup,
    334                               PRErrorCallbackNewTableFn *newtable,
    335                               struct PRErrorCallbackPrivate *cb_private);
    336 
    33762PR_END_EXTERN_C
    33863
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prerror.c

    r1 r102207  
    3838#include "primpl.h"
    3939
    40 #include <string.h>
    41 #include <stdlib.h>
    42 
    43 PR_IMPLEMENT(PRErrorCode) PR_GetError(void)
    44 {
    45     PRThread *thread = PR_GetCurrentThread();
    46     return thread->errorCode;
    47 }
    48 
    49 PR_IMPLEMENT(PRInt32) PR_GetOSError(void)
    50 {
    51     PRThread *thread = PR_GetCurrentThread();
    52     return thread->osErrorCode;
    53 }
    54 
    5540PR_IMPLEMENT(void) PR_SetError(PRErrorCode code, PRInt32 osErr)
    5641{
     
    6045    thread->errorStringLength = 0;
    6146}
    62 
    63 PR_IMPLEMENT(void) PR_SetErrorText(PRIntn textLength, const char *text)
    64 {
    65     PRThread *thread = PR_GetCurrentThread();
    66 
    67     if (0 == textLength)
    68     {
    69             if (NULL != thread->errorString)
    70                 PR_DELETE(thread->errorString);
    71             thread->errorStringSize = 0;
    72     }
    73     else
    74     {
    75             PRIntn size = textLength + 31;  /* actual length to allocate. Plus a little extra */
    76         if (thread->errorStringSize < textLength+1)  /* do we have room? */
    77         {
    78                 if (NULL != thread->errorString)
    79                     PR_DELETE(thread->errorString);
    80                     thread->errorString = (char*)PR_MALLOC(size);
    81             if ( NULL == thread->errorString ) {
    82                 thread->errorStringSize = 0;
    83                 thread->errorStringLength = 0;
    84                 return;
    85             }
    86             thread->errorStringSize = size;
    87             }
    88         memcpy(thread->errorString, text, textLength+1 );
    89     }
    90     thread->errorStringLength = textLength;
    91 }
    92 
    93 PR_IMPLEMENT(PRInt32) PR_GetErrorTextLength(void)
    94 {
    95     PRThread *thread = PR_GetCurrentThread();
    96     return thread->errorStringLength;
    97 }  /* PR_GetErrorTextLength */
    98 
    99 PR_IMPLEMENT(PRInt32) PR_GetErrorText(char *text)
    100 {
    101     PRThread *thread = PR_GetCurrentThread();
    102     if (0 != thread->errorStringLength)
    103         memcpy(text, thread->errorString, thread->errorStringLength+1);
    104     return thread->errorStringLength;
    105 }  /* PR_GetErrorText */
    106 
    107 
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinit.c

    r102203 r102207  
    7878    _PR_InitThreads(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
    7979
    80     nspr_InitializePRErrorTable();
    81 
    8280    _PR_MD_FINAL_INIT();
    8381}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette