Back to index

lightning-sunbird  0.9+nobinonly
sslerr.c
Go to the documentation of this file.
00001 /*
00002  * Function to set error code only when meaningful error has not already 
00003  * been set.
00004  *
00005  * ***** BEGIN LICENSE BLOCK *****
00006  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00007  *
00008  * The contents of this file are subject to the Mozilla Public License Version
00009  * 1.1 (the "License"); you may not use this file except in compliance with
00010  * the License. You may obtain a copy of the License at
00011  * http://www.mozilla.org/MPL/
00012  *
00013  * Software distributed under the License is distributed on an "AS IS" basis,
00014  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00015  * for the specific language governing rights and limitations under the
00016  * License.
00017  *
00018  * The Original Code is the Netscape security libraries.
00019  *
00020  * The Initial Developer of the Original Code is
00021  * Netscape Communications Corporation.
00022  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00023  * the Initial Developer. All Rights Reserved.
00024  *
00025  * Contributor(s):
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 /* $Id: sslerr.c,v 1.4 2004/04/27 23:04:39 gerv%gerv.net Exp $ */
00041 
00042 #include "prerror.h"
00043 #include "secerr.h"
00044 #include "sslerr.h"
00045 #include "seccomon.h"
00046 
00047 /* look at the current value of PR_GetError, and evaluate it to see
00048  * if it is meaningful or meaningless (out of context). 
00049  * If it is meaningless, replace it with the hiLevelError.
00050  * Returns the chosen error value.
00051  */
00052 int
00053 ssl_MapLowLevelError(int hiLevelError)
00054 {
00055     int oldErr       = PORT_GetError();
00056 
00057     switch (oldErr) {
00058 
00059     case 0:
00060     case PR_IO_ERROR:
00061     case SEC_ERROR_IO:
00062     case SEC_ERROR_BAD_DATA:
00063     case SEC_ERROR_LIBRARY_FAILURE:
00064     case SEC_ERROR_EXTENSION_NOT_FOUND:
00065     case SSL_ERROR_BAD_CLIENT:
00066     case SSL_ERROR_BAD_SERVER:
00067     case SSL_ERROR_SESSION_NOT_FOUND:
00068        PORT_SetError(hiLevelError);
00069        return hiLevelError;
00070 
00071     default:  /* leave the majority of error codes alone. */
00072        return oldErr;
00073     }
00074 }