/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Read an errgen status resource file (*.err) from standard input and
* write an SPCS error code C header file (-c), Java resource file (-j),
* libspcs Java exception class file(-e), error text file (-m) or JNI
* exception trinket table to standard output. Lines starting with "#"
* are ignored.
*
* Use "errgen -h" to get usage info including module codes and example
* input and output.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <libgen.h>
#include <limits.h>
/* The public error info header file. */
/* The private error info header file */
/* locals */
static int mod_number;
/*
* Display help info
*/
static void
help()
{
if (h) {
while (! feof(h)) {
if (! feof(h))
}
} else {
exit(1);
}
}
/*
* Put out a message with terse instructions and err out
*/
static void
{
exit(1);
}
/*
* Put out the output file preamble
*/
static void
{
switch (mode) {
case M_MODE:
"static\nchar *SPCS_MSG_%s[] = {\n", modname);
break;
case T_MODE:
"static\nchar *SPCS_TRNK_%s[] = {\n", modname);
break;
}
}
/*
* Put out the output file trailer
*/
static void
{
switch (mode) {
case M_MODE:
"#define\tSPCS_MSGLEN_%s %d\t/* total codes */\n",
break;
case T_MODE:
"#define\tSPCS_TRNKLEN_%s %d\t/* total codes */\n",
break;
}
}
/*
* Process a single input line
*/
static void
do_line()
{
int fc = 0;
int len = 0;
char *p = text;
int tlen;
char havebytestream = 0;
c.i = 0;
while (*p) {
if (*p == '%') {
if (*(p + 1) != 's') {
"ERRGEN: Error in .err file\n");
"%c is an illegal format spec after %%",
*p);
" at line: %d pos: %d\n", count,
/* LINTED possible ptrdiff_t overflow */
(int)(p - text));
fatal("");
}
p++;
fc += 1;
if (fc > SPCS_S_MAXSUPP) {
"ERRGEN: Error in .err file\n");
"SPCS_S_MAXSUPP exceeeded\n");
fatal("Too many %%s specifiers");
}
} else
*pt++ = *p;
p++;
}
/* look for a bytestream indicator */
if (fc)
fatal("ERRGEN: cannot have %%s and @@ ending too");
/* bump the item count and set the bytestream flag */
fc += 1;
havebytestream = 1;
}
*pt = 0;
switch (mode) {
case C_MODE:
c.f.bytestream = havebytestream;
c.f.module = mod_number;
break;
case J_MODE:
break;
case X_MODE:
break;
case T_MODE:
break;
case M_MODE:
break;
case E_MODE:
text);
break;
}
}
int
{
int i;
char *p, *p2;
help();
exit(0);
}
if (argc != 3)
fatal("Bad number of arguments");
p = argv[2];
while (*p)
*p2 = 0;
case 'c':
break;
case 'j':
break;
case 'e':
break;
case 'm':
break;
case 't':
break;
case 'x':
break;
default:
fatal("Unknown option switch");
}
} else {
}
i = 0;
do {
searching = 0;
mod_number = i - 1;
break;
}
} while (module_names[i]);
if (searching) {
if (i != SPCS_M_MAX)
"NULL in module_names before SPCS_M_MAX\n");
fatal("Undefined module name");
}
do_preamble();
if (count == 0)
fatal("errgen file empty");
do_trailer();
exit(0);
}
if (p == NULL) {
"blank separator missing at line: %d\n",
count);
fatal("");
}
*p = 0;
if (strlen(p) > SPCS_S_MAXKEY) {
"message label too long at line: %d\n", count);
fatal("");
}
"leading blank at line: %d\n", count);
fatal("");
}
p++;
if (*p != '=') {
"= separator missing at line: %d\n", count);
fatal("");
}
p++;
if (*p != ' ') {
"blank separator missing at line: %d\n", count);
fatal("");
}
p++;
if (! *p) {
"msg text missing at line:%d\n", count);
fatal("");
}
do_line();
count++;
}
}
return (0);
}