error.c revision 43ec799dbc8971afca055dd7f8fd479b7b72f338
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "cr_environment.h"
#include "cr_error.h"
#include "cr_string.h"
#include "cr_net.h"
#include "cr_process.h"
#ifdef WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <io.h>
#include <fcntl.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>
#ifndef IN_GUEST
#define LOG_GROUP LOG_GROUP_SHARED_CROPENGL
#endif
static char my_hostname[256];
#ifdef WINDOWS
#else
static int my_pid = 0;
#endif
static int canada = 0;
static int swedish_chef = 0;
static int australia = 0;
static int warnings_enabled = 1;
void __getHostInfo( void )
{
char *temp;
{
}
if (temp)
{
*temp = '\0';
}
}
static void __crCheckCanada(void)
{
static int first = 1;
if (first)
{
if (env)
canada = 1;
first = 0;
}
}
static void __crCheckSwedishChef(void)
{
static int first = 1;
if (first)
{
if (env)
swedish_chef = 1;
first = 0;
}
}
static void __crCheckAustralia(void)
{
static int first = 1;
if (first)
{
australia = 1;
first = 0;
}
}
{
);
}
#ifdef WINDOWS
static void crRedirectIOToConsole()
{
int hConHandle;
AllocConsole();
}
#endif
{
static char txt[8092];
int offset;
#ifdef WINDOWS
#endif
if (!my_hostname[0])
#ifdef WINDOWS
{
SetLastError(0);
if ( temp )
{
}
{
*temp = '\0';
temp--;
}
offset = sprintf( txt, "\t-----------------------\n\tWindows ERROR: %s\n\t----------------------\nCR Error(%s:%d): ", buf, my_hostname, my_pid );
}
else
{
}
#else
#endif
#else
#endif
#ifdef WINDOWS
{
}
else
{
#endif
#ifdef WINDOWS
}
#if !defined(DEBUG_leo) && !defined(DEBUG_ll158262)
#endif
{
DebugBreak();
}
#endif
#ifdef IN_GUEST
/* Give chance for things to close down */
exit(1);
#endif
}
void crEnableWarnings(int onOff)
{
}
{
if (warnings_enabled) {
static char txt[8092];
int offset;
if (!my_hostname[0])
#else
#endif
}
}
{
static char txt[8092];
int offset;
if (!my_hostname[0])
#else
#endif
}
{
static char txt[8092];
int offset;
#ifdef WINDOWS
#endif
static int first_time = 1;
static int silent = 0;
if (first_time)
{
first_time = 0;
if (fname)
{
char debugFile[1000], *p;
if (p) {
/* replace %p with process number */
unsigned long n = (unsigned long) crGetPID();
sprintf(p, "%lu", n);
}
if (!output)
{
}
}
else
{
#endif
}
#ifndef DEBUG
/* Release mode: only emit crDebug messages if CR_DEBUG
* or CR_DEBUG_FILE is set.
*/
silent = 1;
#endif
}
if (silent)
return;
if (!my_hostname[0])
#ifdef WINDOWS
{
SetLastError(0);
if ( temp )
{
}
{
*temp = '\0';
temp--;
}
offset = sprintf( txt, "\t-----------------------\n\tWindows ERROR: %s\n\t-----------------\nCR Debug(%s:%d): ", buf, my_hostname, my_pid );
}
else
{
}
#else
#endif
#else
#endif
}