xref: /illumos-gate/usr/src/cmd/sgs/tsort/common/errmsg.h (revision 2a8bcb4e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*d6555420Smike_s 
23*d6555420Smike_s /*
24*d6555420Smike_s  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25*d6555420Smike_s  * Use is subject to license terms.
26*d6555420Smike_s  */
27*d6555420Smike_s 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate 
32*d6555420Smike_s #ifndef _ERRMSG_H
33*d6555420Smike_s #define	_ERRMSG_H
34*d6555420Smike_s 
357c478bd9Sstevel@tonic-gate /*
36*d6555420Smike_s  * errmsg.h
37*d6555420Smike_s  *	Include file for error message interface.
38*d6555420Smike_s  *	Command and library version.
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate 
41*d6555420Smike_s #define	errmsg	errtag(__FILE__, __LINE__), errtext
427c478bd9Sstevel@tonic-gate 
43*d6555420Smike_s void erraction(int action);
44*d6555420Smike_s int errafter(int severity, char *format, ...);
45*d6555420Smike_s void errbefore(int severity, char *format, ...);
46*d6555420Smike_s int errexit(int e);
47*d6555420Smike_s void _errmsg(char *tag, int severity, char *format, ...);
48*d6555420Smike_s void errprefix(char *str);
49*d6555420Smike_s void errsource(char *str);
50*d6555420Smike_s void errtag(char *str, int num);
51*d6555420Smike_s void errtext(int severity, char *format, ...);
52*d6555420Smike_s void errtofix(char *str);
53*d6555420Smike_s void errusage(char *format, ...);
54*d6555420Smike_s char *errstrtok(char *string, char *sepset);
55*d6555420Smike_s void errverb(char *s);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* severities  first argument to errbefore(), errafter(), errtext() */
587c478bd9Sstevel@tonic-gate #define	EIGNORE	-1	/* special severity, no message, no action, returns */
597c478bd9Sstevel@tonic-gate #define	EINFO	0
607c478bd9Sstevel@tonic-gate #define	EWARN	1
617c478bd9Sstevel@tonic-gate #define	EERROR	2
627c478bd9Sstevel@tonic-gate #define	EHALT	3
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /* special errtext() argument that prints a standard message based on errno */
657c478bd9Sstevel@tonic-gate #define	EERRNO	1
667c478bd9Sstevel@tonic-gate 
67*d6555420Smike_s /*
68*d6555420Smike_s  * actions : returned by errafter() used as an argument to erraction()
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate #define	EEXIT	100
717c478bd9Sstevel@tonic-gate #define	EABORT  200
72*d6555420Smike_s #define	ERETURN 300
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /* used to set verbosity */
757c478bd9Sstevel@tonic-gate #define	ENO	0
767c478bd9Sstevel@tonic-gate #define	EYES	1
777c478bd9Sstevel@tonic-gate #define	EDEF	2   /* default value -- setting ersyserr */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate struct Err {
807c478bd9Sstevel@tonic-gate 			/* flags to adjust verbosity */
817c478bd9Sstevel@tonic-gate 	char	vbell;	/* ring bell before message */
827c478bd9Sstevel@tonic-gate 	char	vprefix;
837c478bd9Sstevel@tonic-gate 	char	vsource;	/* source information, including prefix */
847c478bd9Sstevel@tonic-gate 	char	vsevmsg;	/* severity message */
857c478bd9Sstevel@tonic-gate 	char	vsyserr;	/* system error message, perror() */
867c478bd9Sstevel@tonic-gate 	char	vfix;	/* to fix msg */
877c478bd9Sstevel@tonic-gate 	char	vtag;
887c478bd9Sstevel@tonic-gate 	char	vtext;
897c478bd9Sstevel@tonic-gate 			/* message content and context */
907c478bd9Sstevel@tonic-gate 	char	*prefix;	/* usually unique per manufacturer */
91*d6555420Smike_s 	char	*envsource;	/* source from ERRSOURCE environment variable */
927c478bd9Sstevel@tonic-gate 	char	*source;	/* usually command name */
937c478bd9Sstevel@tonic-gate 	int	severity;
947c478bd9Sstevel@tonic-gate 	char	**sevmsg;	/* error messages that depend on severity */
957c478bd9Sstevel@tonic-gate 	char	*tofix;  /* set by errtofix()  */
967c478bd9Sstevel@tonic-gate 	int	tagnum;
977c478bd9Sstevel@tonic-gate 	char	*tagstr;
987c478bd9Sstevel@tonic-gate 	int	exit;	/* exit(2) code to use if error causes exit */
997c478bd9Sstevel@tonic-gate };
1007c478bd9Sstevel@tonic-gate 
101*d6555420Smike_s extern struct Err	Err;
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #include	<stdio.h>
1047c478bd9Sstevel@tonic-gate #include	<sys/types.h>
1057c478bd9Sstevel@tonic-gate 
106*d6555420Smike_s extern void *zmalloc(int severity, size_t n);
107*d6555420Smike_s FILE *zfopen(int severity, char *path, char *type);
108*d6555420Smike_s 
109*d6555420Smike_s #endif /* _ERRMSG_H */
110