err.c revision b493790cc80fe768151c1d34fd77c2161a0b6087
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <unistd.h>
#include <libintl.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include "err.h"
static const char *Myname;
static int Exitcode;
/*
* err_init -- initialize the error handling routine
*
*/
void
{
char *ptr;
else
}
static const char *File;
static int Line;
/*
*/
void
{
}
/*
* err -- print an error message and return, exit or longjmp based on flags
*
* this routine calls gettext() to translate the fmt string.
*/
/*PRINTFLIKE2*/
void
{
int safe_errno = errno;
int as_is = 0;
int jump = 0;
int warning = 0;
int fileline = 0;
char *prefix = "Error: ";
const char *intlfmt;
warning = 1;
prefix = "Warning: ";
}
fileline = 1;
Exitcode++;
}
jump = 1;
as_is = 1;
/* print a copy to stderr */
if (!as_is) {
if (Errorfile)
}
if (Errorfile)
}
if (Errorfile)
}
if (Errorfile)
if (Errorfile)
}
if (!as_is) {
if (Errorfile)
}
if (Errorfile)
if (jump)
err_done(1);
/*NOTREACHED*/
}
}
/*
* out -- print a message and return
*
* this routine calls gettext() to translate the fmt string.
*/
/*PRINTFLIKE1*/
void
{
}
/*
* err_fromfd -- copy data from fd to stderr
*/
void
err_fromfd(int fd)
{
int count;
if (Errorfile)
}
if (Errorfile)
}
/*
* err_done -- exit the program
*/
void
{
/* send error mail if applicable */
if (exitcode)
else
/*NOTREACHED*/
}
/*
* err_mailto -- arrange for error output to be mailed to someone
*/
void
err_mailto(const char *recipient)
{
static const char *lastrecipient;
char *cmd;
int len;
if (lastrecipient != NULL) {
return; /* keep going, same recipient */
/* stop saving output for lastrecipient and send message */
}
}
/* start saving error output for this recipient */
}
}
/*
* err_malloc -- a malloc() with checks
*
* this routine is typically called via the MALLOC() macro in err.h
*/
void *
{
return (retval);
}
/*
* err_realloc -- a realloc() with checks
*
* this routine is typically called via the REALLOC() macro in err.h
*/
void *
{
return (retval);
}
/*
* err_strdup -- a strdup() with checks
*
* this routine is typically called via the STRDUP() macro in err.h
*/
char *
{
} else
return (retval);
}
/*
* err_free -- a free() with checks
*
* this routine is typically called via the FREE() macro in err.h
*/
/*ARGSUSED1*/
void
{
/* nothing to check in this version */
}
/*
* err_exitcode -- set an error exit code for when done(0) is called
*/
void
err_exitcode(int exitcode)
{
}