00001 /* 00002 * kp_error.h - Interface of error handling. 00003 * This file is part of PetrSU KP Library. 00004 * 00005 * Copyright (C) 2009 - Alexandr A. Lomov. 00006 * 00007 * PetrSU KP Library is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * PetrSU KP Library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with PetrSU KP Library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, 00020 * Boston, MA 02110-1301 USA 00021 */ 00022 00023 #include "kp_bool.h" 00024 00025 #ifndef _KP_ERROR_H 00026 #define _KP_ERROR_H 00027 00028 00030 #define ERROR_UNKNOWN_TEXT "Unknown error." 00031 00032 00033 00034 /******************************************************************************/ 00035 /******************************** Enums list **********************************/ 00039 enum kp_errors { 00040 00041 #define KP_ERROR_DECLARATION( enum_code_decl, code_value, error_text) enum_code_decl code_value, 00042 #define KP_ERROR_DECLARATION_LAST( enum_code_decl, code_value, error_text) enum_code_decl code_value 00043 #include "kp_errors_define_decl.txt" 00044 #undef KP_ERROR_DECLARATION 00045 #undef KP_ERROR_DECLARATION_LAST 00046 00047 }; 00048 00049 00050 00051 /******************************************************************************/ 00052 /****************************** Functions list ********************************/ 00053 int set_error(int error_code); 00054 int get_error_code(); 00055 int get_error_code_and_reset(); 00056 00057 const char* get_error_text(); 00058 char* get_error_text_and_reset(); 00059 const char* get_error_text_by_code(int error_code); 00060 00061 int reset_error(); 00062 00063 #endif /* _KP_ERROR_H */