00001 /* 00002 * $Id: errinfo.c 4597 2008-08-06 11:04:06Z klaus_darilion $ 00003 * 00004 * Copyright (C) 2006 Voice Sistem SRL 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 /*! 00024 * \file errinfo.c 00025 * \brief Kamailio Error info functions 00026 */ 00027 00028 00029 #include <stdlib.h> 00030 #include <string.h> 00031 00032 #include "dprint.h" 00033 #include "errinfo.h" 00034 00035 /*! global error info */ 00036 err_info_t _oser_err_info; 00037 00038 /*! \brief Get global error state 00039 */ 00040 err_info_t* get_err_info(void) { return &_oser_err_info; } 00041 00042 /*! \brief Initialize global error state 00043 */ 00044 void init_err_info(void) 00045 { 00046 memset(&_oser_err_info, 0, sizeof(err_info_t)); 00047 } 00048 00049 /*! \brief Set suggested error info message 00050 */ 00051 void set_err_info(int ec, int el, char *info) 00052 { 00053 LM_DBG("ec: %d, el: %d, ei: '%s'\n", ec, el, 00054 (info)?info:""); 00055 _oser_err_info.eclass = ec; 00056 _oser_err_info.level = el; 00057 if(info) 00058 { 00059 _oser_err_info.info.s = info; 00060 _oser_err_info.info.len = strlen(info); 00061 } 00062 } 00063 00064 /*! \brief Set suggested error reply 00065 */ 00066 void set_err_reply(int rc, char *rr) 00067 { 00068 _oser_err_info.rcode = rc; 00069 if(rr) 00070 { 00071 _oser_err_info.rreason.s = rr; 00072 _oser_err_info.rreason.len = strlen(rr); 00073 } 00074 } 00075
1.5.6