Main Page   Compound List   File List   Compound Members   File Members  

error.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2000,2001 Red Hat, Inc.
00003  *
00004  * This is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Library General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 #ifndef libuser_error_h
00020 #define libuser_error_h
00021 
00024 #include <sys/types.h>
00025 #include <errno.h>
00026 #include <glib.h>
00027 
00029 enum lu_error_code {
00030         lu_error_success = 0,           
00031         lu_error_config_disabled,       
00033         lu_error_generic,               
00034         lu_error_privilege,             
00035         lu_error_access_denied,         
00037         lu_error_name_bad,              
00038         lu_error_id_bad,                
00039         lu_error_name_used,             
00040         lu_error_id_used,               
00042         lu_error_terminal,              
00044         lu_error_open,                  
00045         lu_error_lock,                  
00046         lu_error_stat,                  
00047         lu_error_read,                  
00048         lu_error_write,                 
00049         lu_error_search,                
00051         lu_error_init,                  
00052         lu_error_module_load,           
00053         lu_error_module_sym,            
00054         lu_error_version,               
00055 };
00056 
00057 typedef struct lu_error {
00058         enum lu_error_code code;
00059         char **stack;
00060         char *string;
00061 } lu_error_t;
00062 
00065 #define LU_ERROR_CHECK(err_p_p) \
00066 do { \
00067         struct lu_error **__err = (err_p_p); \
00068         if ((__err == NULL) || (*__err != NULL)) { \
00069                 int i; \
00070                 if(__err == NULL) { \
00071                         fprintf(stderr, "libuser fatal error: %s() called with NULL " #err_p_p "\n", __FUNCTION__); \
00072                 } else \
00073                 if(*__err != NULL) { \
00074                         fprintf(stderr, "libuser fatal error: %s() called with non-NULL *" #err_p_p "\nstack:\n", __FUNCTION__); \
00075                         for(i = 0; (*__err)->stack && (*__err)->stack[i]; i++) { \
00076                                 fprintf(stderr, "\t%s\n", (*__err)->stack[i]); \
00077                         } \
00078                 } \
00079                 abort(); \
00080         } \
00081 } while(0)
00082 
00083 void lu_error_new(struct lu_error **error, enum lu_error_code code,
00084                   const char *fmt, ...);
00085 void lu_error_free(struct lu_error **error);
00086 
00087 #endif

Generated at Wed Aug 29 13:14:11 2001 for libuser by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001