error.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Eduardo Krell <ekrell@adexus.cl> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* error and message formatter
*
* level is the error level
* level >= error_info.core!=0 dumps core
* level >= ERROR_FATAL calls error_info.exit
* level < 0 is for debug tracing
*
* NOTE: non-sfio version just for 3d
*/
#include "3d.h"
#if DEBUG
static ssize_t
{
}
#define error_info _error_info_
/*
* print a name, converting unprintable chars
*/
static void
{
register char* s = *buf;
register char* e = end;
register int c;
while (c = *name++)
{
if (c & 0200)
{
c &= 0177;
if (s >= e) break;
*s++ = '?';
}
if (c < ' ')
{
c += 'A' - 1;
if (s >= e) break;
*s++ = '^';
}
if (s >= e) break;
*s++ = c;
}
while (*delim)
{
if (s >= e) break;
*s++ = *delim++;
}
*buf = s;
}
void
{
register int n;
int fd;
int flags;
char* b;
char* e;
char* format;
char buf[4096];
int line;
char* file;
static int intercepted;
if (intercepted++)
{
intercepted--;
return;
}
if (level > 0)
{
level &= ERROR_LEVEL;
}
else flags = 0;
if ((fd = fsfd(&state.fs[FS_option])) <= 0 || level < error_info.trace || lib && (error_info.clear & ERROR_LIBRARY) || level < 0 && error_info.mask && !(error_info.mask & (1<<(-level - 1))))
{
intercepted--;
return;
}
if (flags & ERROR_USAGE)
{
}
{
if (flags & ERROR_LIBRARY)
}
{
}
switch (level)
{
case 0:
break;
case ERROR_WARNING:
bprintf(&b, e, "warning: ");
break;
case ERROR_PANIC:
error_info.errors++;
bprintf(&b, e, "panic: ");
break;
default:
if (level < 0)
{
else bprintf(&b, e, "debug: ");
for (n = 0; n < error_info.indent; n++)
{
*b++ = ' ';
*b++ = ' ';
}
}
else error_info.errors++;
break;
}
if (flags & ERROR_SOURCE)
{
/*
* source ([version], file, line) message
*/
}
if (!(flags & ERROR_PROMPT))
{
{
}
*b++ = '\n';
}
*b = 0;
{
pause();
}
intercepted--;
}
void
{
}
int
{
return 0;
}
int
{
errorv(discipline ? *((char**)handle) : (char*)handle, (discipline || level < 0) ? level : (level | ERROR_LIBRARY), ap);
return 0;
}
#else
#endif