/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-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> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* fmtmsg implementation
*/
#include <ast.h>
#if _lib_fmtmsg
#else
#define MM_TABLES
#include <fmtmsg.h>
#define INIT_VERB 0x1
#define INIT_CONSOLE 0x2
static struct
{
int console;
unsigned int init;
unsigned int mask;
} mm;
const MM_table_t mm_class[] =
{
"null", 0, 0,
"print", 0, MM_PRINT,
"console", 0, MM_CONSOLE,
0, 0, 0
};
static const MM_table_t mm_severity_init[] =
{
"nosev", 0, MM_NOSEV,
0, 0, 0
};
const MM_table_t mm_verb[] =
{
"all", 0, MM_all,
"action", 0, MM_action,
"class", 0, MM_class,
"default", 0, MM_default,
"label", 0, MM_label,
"severity", 0, MM_severity,
"source", 0, MM_source,
"tag", 0, MM_tag,
"text", 0, MM_text,
0, 0, 0
};
const MM_table_t*
_mm_severity(void)
{
static MM_table_t* severity;
if (!severity)
{
register char* s;
register MM_table_t* p;
register int n;
register int c;
char* e;
MM_table_t* q;
n = 0;
if ((s = getenv(MM_SEVERITY_ENV)) && *s)
{
e = s;
c = 0;
for (;;)
{
switch (*s++)
{
case 0:
break;
case ',':
if (++c > 2)
{
n = 0;
break;
}
continue;
case ':':
if (c != 2)
{
n = 0;
break;
}
c = 0;
n++;
continue;
default:
continue;
}
break;
}
if (c == 2)
n++;
else n = 0;
if (n)
{
{
s = (char*)severity + n * sizeof(MM_table_t);
strcpy(s, e);
p = severity;
*p++ = *q;
p->name = s;
c = 0;
for (;;)
{
switch (*s++)
{
case 0:
break;
case ',':
switch (c++)
{
case 0:
*(s - 1) = 0;
break;
case 1:
p->display = s;
break;
}
continue;
case ':':
c = 0;
*(s - 1) = 0;
(++p)->name = s;
continue;
default:
continue;
}
break;
}
}
}
}
if (!severity)
}
return (const MM_table_t*)severity;
}
static char*
{
{
tab++;
}
return 0;
}
int
fmtmsg(long classification, const char* label, int severity, const char* text, const char* action, const char* tag)
{
register int c;
register char* s;
register char* t;
register MM_table_t* p;
int n;
int m;
int r;
int fd;
unsigned int mask;
{
if (!(s = getenv(MM_VERB_ENV)))
else for (;;)
{
if (t = strchr(s, ':'))
*t = 0;
{
if (t)
*t = ':';
break;
}
if (!t)
break;
*t++ = ':';
s = t;
}
}
return 0;
return MM_NOTOK;
r = 0;
if (s = (char*)label)
{
if (t = strchr(s, ':'))
{
if ((n = t - s) > MM_LABEL_1_MAX)
n = MM_LABEL_1_MAX;
s = ++t;
if ((n = strlen(t)) > MM_LABEL_2_MAX)
n = MM_LABEL_2_MAX;
}
else
{
if ((n = strlen(t)) > MM_LABEL_1_MAX)
n = MM_LABEL_1_MAX;
}
{
sfstrclose(sp);
return MM_NOTOK;
}
}
for (;;)
{
if (classification & MM_CONSOLE)
{
classification &= ~MM_CONSOLE;
{
r |= MM_NOCON;
continue;
}
c = MM_NOCON;
}
else if (classification & MM_PRINT)
{
classification &= ~MM_PRINT;
c = MM_NOMSG;
fd = 2;
}
else break;
{
{
if (tag)
}
{
if ((mask & MM_source) && (m = classification & (MM_APPL|MM_UTIL|MM_OPSYS)) && (s = display(mm_class, m, 1)))
if ((mask & MM_class) && (m = classification & (MM_HARD|MM_SOFT|MM_FIRM)) && (s = display(mm_class, m, 1)))
if ((mask & MM_status) && (m = classification & (MM_RECOVER|MM_NRECOV)) && (s = display(mm_class, m, 1)))
}
}
r |= c;
}
sfstrclose(sp);
return r;
}
#endif