vrq
/usr/src/RPM/BUILD/vrq-1.0.96/src/glue.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 1997-2007, Mark Hummel
00003  * This file is part of Vrq.
00004  *
00005  * Vrq is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * Vrq is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00018  * Boston, MA  02110-1301  USA
00019  *****************************************************************************
00020  */
00021 
00022 #ifndef GLUE_HPP
00023 #define GLUE_HPP
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string>
00028 #include <list>
00029 #include <map>
00030 #include <iostream>
00031 #include <stdarg.h>
00032 
00033 using std::string;
00034 using std::map;
00035 using std::list;
00036 
00037 struct Coord_t;
00038 class  CBackend;
00039 
00043 typedef long               INT32;
00047 typedef unsigned long      UINT32;
00051 typedef signed long long   INT64;
00055 typedef unsigned long long UINT64;
00056 
00061 #ifndef TRUE
00062 #define TRUE 1
00063 #endif
00064 #ifndef FALSE
00065 #define FALSE 0
00066 #endif
00067 
00068 #define PATH_SEPARATOR "/"
00069 
00070 extern int      warningCount;
00071 extern int      errorCount;
00072 extern FILE*    logfile;
00073 
00077 void shell_assert( const char*, int );
00078 void shell_xfree( void*, int );
00079 void* shell_xmalloc( int );
00089 class Message {
00090 public:
00094     enum Action_t {
00095         eIGNORE,        
00096         eERROR,         
00097         eWARNING,       
00098         eINFO           
00099     };
00100 private:
00101     static map<string,Message*> abbrev2Message; 
00102     static list<Message*> messages;             
00103     CBackend* tool;                             
00104     Action_t  action;                           
00105     int       locked;                           
00106     const string abbrev;                        
00107     const string helpText;                      
00108     const string format;                        
00109 public:
00119     static Message* RegisterWarning( CBackend* tool, 
00120                       Action_t   defaultAction,
00121                       const char* abbrev, 
00122                       const char* format, ... );
00131     static Message* RegisterError( CBackend* tool, 
00132                       const char* abbrev, 
00133                       const char* format, ... );
00143     static Message* Find( const char* abbrev );
00148     static list<Message*>& MessageList() { return messages; }
00149     Message( CBackend* tool,
00150              Action_t action,
00151              int    locked,
00152              const char* abbrev,
00153              const char* helpText,
00154              const char* format );
00155     
00156     const char* Format() { return format.c_str(); }
00157     const char* Abbreviation() { return abbrev.c_str(); }
00158     const char* HelpText() { return helpText.c_str(); }
00159     Action_t    Action() { return action; }
00160     void        Action( Action_t a ) { if( !locked ) { action = a; } }
00161     CBackend*   Tool() { return tool; }
00162     int         Locked() { return locked; }
00166 };
00167 
00175 void message( struct Coord_t* location, Message* message, ... );
00182 void vlogprintf( const char* format, va_list args );
00189 void logprintf( const char* format, ... );
00190 
00191 
00196 void warning( struct Coord_t* location, const char* format, ... );
00201 void error( struct Coord_t* location, const char* format, ... );
00206 void info( struct Coord_t* location, const char* format, ... );
00211 void fatal( struct Coord_t* location, const char* format, ... );
00216 void trace( struct Coord_t* location, const char* format, ... );
00217 
00218 
00224 #define MASSERT(c) if(!(c)) { shell_assert( __FILE__, __LINE__ ); abort(); }
00225 
00230 #define MTHROW_NIL(p) MASSERT(p!=NULL);
00231 
00232 #endif // GLUE_HPP
00233