/security/nss/lib/ssl/sslerr.c

http://github.com/zpao/v8monkey · C · 74 lines · 24 code · 5 blank · 45 comment · 1 complexity · c9b6dcb167da229bdd93a3a50472b174 MD5 · raw file

  1. /*
  2. * Function to set error code only when meaningful error has not already
  3. * been set.
  4. *
  5. * ***** BEGIN LICENSE BLOCK *****
  6. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  7. *
  8. * The contents of this file are subject to the Mozilla Public License Version
  9. * 1.1 (the "License"); you may not use this file except in compliance with
  10. * the License. You may obtain a copy of the License at
  11. * http://www.mozilla.org/MPL/
  12. *
  13. * Software distributed under the License is distributed on an "AS IS" basis,
  14. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  15. * for the specific language governing rights and limitations under the
  16. * License.
  17. *
  18. * The Original Code is the Netscape security libraries.
  19. *
  20. * The Initial Developer of the Original Code is
  21. * Netscape Communications Corporation.
  22. * Portions created by the Initial Developer are Copyright (C) 1994-2000
  23. * the Initial Developer. All Rights Reserved.
  24. *
  25. * Contributor(s):
  26. *
  27. * Alternatively, the contents of this file may be used under the terms of
  28. * either the GNU General Public License Version 2 or later (the "GPL"), or
  29. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  30. * in which case the provisions of the GPL or the LGPL are applicable instead
  31. * of those above. If you wish to allow use of your version of this file only
  32. * under the terms of either the GPL or the LGPL, and not to allow others to
  33. * use your version of this file under the terms of the MPL, indicate your
  34. * decision by deleting the provisions above and replace them with the notice
  35. * and other provisions required by the GPL or the LGPL. If you do not delete
  36. * the provisions above, a recipient may use your version of this file under
  37. * the terms of any one of the MPL, the GPL or the LGPL.
  38. *
  39. * ***** END LICENSE BLOCK ***** */
  40. /* $Id: sslerr.c,v 1.4 2004/04/27 23:04:39 gerv%gerv.net Exp $ */
  41. #include "prerror.h"
  42. #include "secerr.h"
  43. #include "sslerr.h"
  44. #include "seccomon.h"
  45. /* look at the current value of PR_GetError, and evaluate it to see
  46. * if it is meaningful or meaningless (out of context).
  47. * If it is meaningless, replace it with the hiLevelError.
  48. * Returns the chosen error value.
  49. */
  50. int
  51. ssl_MapLowLevelError(int hiLevelError)
  52. {
  53. int oldErr = PORT_GetError();
  54. switch (oldErr) {
  55. case 0:
  56. case PR_IO_ERROR:
  57. case SEC_ERROR_IO:
  58. case SEC_ERROR_BAD_DATA:
  59. case SEC_ERROR_LIBRARY_FAILURE:
  60. case SEC_ERROR_EXTENSION_NOT_FOUND:
  61. case SSL_ERROR_BAD_CLIENT:
  62. case SSL_ERROR_BAD_SERVER:
  63. case SSL_ERROR_SESSION_NOT_FOUND:
  64. PORT_SetError(hiLevelError);
  65. return hiLevelError;
  66. default: /* leave the majority of error codes alone. */
  67. return oldErr;
  68. }
  69. }