1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*      Copyright (c) 1988 AT&T     */
  23 /*        All Rights Reserved   */
  24 
  25 
  26 /*
  27  * Copyright 1996-2003 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 #ifndef _FMTMSG_H
  32 #define _FMTMSG_H
  33 
  34 #pragma ident   "%Z%%M% %I%     %E% SMI"        /* SVr4.0 1.3   */
  35 
  36 #include <sys/feature_tests.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 /*
  43  * fmtmsg.h
  44  *
  45  *      The <fmtmsg.h> header file contains the definitions needed
  46  *      to use the fmtmsg() function.  This function writes messages
  47  *      in a standard format to the standard error stream (stderr)
  48  *      and to the system console.
  49  */
  50 
  51 /*
  52  * Define the value "NULL" if it hasn't been defined already.
  53  * NULL breaks namespace so we define _NULL
  54  */
  55 #if defined(_LP64)
  56 #define _NULL   0L
  57 #else
  58 #define _NULL   0
  59 #endif
  60 
  61 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
  62 #ifndef NULL
  63 #define NULL    _NULL
  64 #endif
  65 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
  66 
  67 
  68 /*
  69  * Constraint definitions:
  70  *      MM_MXLABELLN    Maximum size of a "label" in a message
  71  *      MM_MXTAGLN      Maximum size of a "tag" in a message
  72  *      MM_MXTXTLN      Maximum size of a text string
  73  *      MM_MXACTLN      Maximum size of an action string
  74  */
  75 
  76 #define MM_MXLABELLN    25
  77 #define MM_MXTAGLN      32
  78 #define MM_MXTXTLN      512
  79 #define MM_MXACTLN      512
  80 
  81 /*
  82  * Environment variable names used by fmtmsg():
  83  *      MSGVERB         Tells fmtmsg() which components it is to write
  84  *                      to the standard error stream
  85  */
  86 
  87 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
  88 #define MSGVERB         "MSGVERB"
  89 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
  90 
  91 /*
  92  * Classification information
  93  *      - Definition of classifications
  94  *      - Definition of recoverability
  95  *      - Definition of source classifications
  96  */
  97 
  98 /*
  99  * Definition of the "null" classification
 100  *      MM_NULL         Indicates that the classification has been omitted
 101  */
 102 
 103 #define MM_NULL         0L
 104 
 105 /*
 106  * Definitions of type classifications:
 107  *      MM_HARD         Hardware
 108  *      MM_SOFT         Software
 109  *      MM_FIRM         Firmware
 110  */
 111 
 112 #define MM_HARD         0x00000001L
 113 #define MM_SOFT         0x00000002L
 114 #define MM_FIRM         0x00000004L
 115 
 116 /*
 117  * Definitions of recoverability subclassification
 118  *      MM_RECOVER      Recoverable
 119  *      MM_NRECOV       Non-recoverable
 120  */
 121 
 122 #define MM_RECOVER      0x00000100L
 123 #define MM_NRECOV       0x00000200L
 124 
 125 /*
 126  * Definitions of source subclassification
 127  *      MM_APPL         Application
 128  *      MM_UTIL         Utility
 129  *      MM_OPSYS        Kernel
 130  */
 131 
 132 #define MM_APPL         0x00000008L
 133 #define MM_UTIL         0x00000010L
 134 #define MM_OPSYS        0x00000020L
 135 
 136 /*
 137  * Definitions for the action to take with the message:
 138  *      MM_PRINT        Write to the standard error stream
 139  *      MM_CONSOLE      Treat the message as a console message
 140  */
 141 
 142 #define MM_PRINT        0x00000040L
 143 #define MM_CONSOLE      0x00000080L
 144 
 145 /*
 146  * Constants for severity values
 147  *
 148  *      SEV_LEVEL       Names the env variable that defines severities
 149  *
 150  *      MM_NOSEV        Message has no severity
 151  *      MM_HALT         Message describes a severe error condition
 152  *      MM_ERROR        Message describes an error condition
 153  *      MM_WARNING      Message tells of probable error condition
 154  *      MM_INFO         Message informs, not in error
 155  */
 156 
 157 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 158 #define SEV_LEVEL       "SEV_LEVEL"
 159 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
 160 
 161 #define MM_NOSEV        0
 162 #define MM_HALT         1
 163 #define MM_ERROR        2
 164 #define MM_WARNING      3
 165 #define MM_INFO         4
 166 
 167 /*
 168  * Null values for message components
 169  *      MM_NULLLBL              Null value for the label-component
 170  *      MM_NULLSEV              Null value for the severity-component
 171  *      MM_NULLMC               Null value for the classification-component
 172  *      MM_NULLTXT              Null value for the text-component
 173  *      MM_NULLACT              Null value for the action-component
 174  *      MM_NULLTAG              Null value for the tag-component
 175  */
 176 
 177 #define MM_NULLLBL      ((char *)_NULL)
 178 #define MM_NULLSEV      MM_NOSEV
 179 #define MM_NULLMC       MM_NULL
 180 #define MM_NULLTXT      ((char *)_NULL)
 181 #define MM_NULLACT      ((char *)_NULL)
 182 #define MM_NULLTAG      ((char *)_NULL)
 183 
 184 /*
 185  * Values returned by fmtmsg()
 186  *
 187  *      MM_NOTOK        None of the requested messages were generated
 188  *      MM_NOMSG        No message was written to stderr
 189  *      MM_NOCON        No console message was generated
 190  */
 191 
 192 #define MM_NOTOK        -1
 193 #define MM_OK           0x00
 194 #define MM_NOMSG        0x01
 195 #define MM_NOCON        0x04
 196 
 197 /* Function definition */
 198 
 199 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 200 #if defined(__STDC__)
 201 int     addseverity(int, const char *);
 202 #else /* __STDC__ */
 203 int     addseverity();
 204 #endif  /* __STDC__ */
 205 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
 206 
 207 #if defined(__STDC__)
 208 int     fmtmsg(long, const char *, int, const char *, const char *,
 209             const char *);
 210 #else /* __STDC__ */
 211 int     fmtmsg();
 212 #endif  /* __STDC__ */
 213 
 214 #ifdef  __cplusplus
 215 }
 216 #endif
 217 
 218 #endif  /* _FMTMSG_H */