Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

error.C

Go to the documentation of this file.
00001 #include "error.H"
00002 #include "config.H"
00003 
00004 
00005 void
00006 err_(int flags, const char *fmt, va_list ap)
00007 {
00008    static char buf[4096];
00009 
00010    int   errno_save  = errno;
00011    
00012    int   errlev      =    flags & ERR_LEV_MASK;
00013    bool  errnomsg    = !!(flags & ERR_INCL_ERRNO);
00014    
00015    if (errlev <= Config::get_var_int("JOT_WARNING_LEVEL",2,true))
00016    {
00017       vsprintf(buf, fmt, ap);
00018       cerr << buf;
00019 #ifndef WIN32
00020       if (errnomsg) cerr << ": " << strerror(errno_save);
00021       cerr << endl;
00022 #else
00023       //WIN32 only uses errno for certain calls... 
00024       //but this seems to work more widely (always?)
00025       if (errnomsg)
00026       {
00027          {
00028             LPVOID lpMsgBuf;
00029             FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | 
00030                            FORMAT_MESSAGE_FROM_SYSTEM | 
00031                            FORMAT_MESSAGE_IGNORE_INSERTS,
00032                            NULL, GetLastError(), 
00033                            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00034                            (LPTSTR) &lpMsgBuf, 0, NULL  );
00035             cerr << ": " << (LPCTSTR)lpMsgBuf;
00036             LocalFree( lpMsgBuf );
00037          }
00038       }
00039       else 
00040       {
00041          cerr << endl;
00042       }
00043 #endif
00044    }
00045 }
00046 
00047 // end of file error.C

Generated on Mon Sep 18 11:39:29 2006 for jot by  doxygen 1.4.4