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 */ 227c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 237c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 27*ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 28*ba3594baSGarrett D'Amore * 297c478bd9Sstevel@tonic-gate * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. 307c478bd9Sstevel@tonic-gate * Use is subject to license terms. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifndef _FMTMSG_H 347c478bd9Sstevel@tonic-gate #define _FMTMSG_H 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * fmtmsg.h 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * The <fmtmsg.h> header file contains the definitions needed 467c478bd9Sstevel@tonic-gate * to use the fmtmsg() function. This function writes messages 477c478bd9Sstevel@tonic-gate * in a standard format to the standard error stream (stderr) 487c478bd9Sstevel@tonic-gate * and to the system console. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * Define the value "NULL" if it hasn't been defined already. 537c478bd9Sstevel@tonic-gate * NULL breaks namespace so we define _NULL 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate #if defined(_LP64) 567c478bd9Sstevel@tonic-gate #define _NULL 0L 577c478bd9Sstevel@tonic-gate #else 587c478bd9Sstevel@tonic-gate #define _NULL 0 597c478bd9Sstevel@tonic-gate #endif 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 627c478bd9Sstevel@tonic-gate #ifndef NULL 637c478bd9Sstevel@tonic-gate #define NULL _NULL 647c478bd9Sstevel@tonic-gate #endif 657c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Constraint definitions: 707c478bd9Sstevel@tonic-gate * MM_MXLABELLN Maximum size of a "label" in a message 717c478bd9Sstevel@tonic-gate * MM_MXTAGLN Maximum size of a "tag" in a message 727c478bd9Sstevel@tonic-gate * MM_MXTXTLN Maximum size of a text string 737c478bd9Sstevel@tonic-gate * MM_MXACTLN Maximum size of an action string 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate #define MM_MXLABELLN 25 777c478bd9Sstevel@tonic-gate #define MM_MXTAGLN 32 787c478bd9Sstevel@tonic-gate #define MM_MXTXTLN 512 797c478bd9Sstevel@tonic-gate #define MM_MXACTLN 512 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * Environment variable names used by fmtmsg(): 837c478bd9Sstevel@tonic-gate * MSGVERB Tells fmtmsg() which components it is to write 847c478bd9Sstevel@tonic-gate * to the standard error stream 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 887c478bd9Sstevel@tonic-gate #define MSGVERB "MSGVERB" 897c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * Classification information 937c478bd9Sstevel@tonic-gate * - Definition of classifications 947c478bd9Sstevel@tonic-gate * - Definition of recoverability 957c478bd9Sstevel@tonic-gate * - Definition of source classifications 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * Definition of the "null" classification 1007c478bd9Sstevel@tonic-gate * MM_NULL Indicates that the classification has been omitted 1017c478bd9Sstevel@tonic-gate */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate #define MM_NULL 0L 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate /* 1067c478bd9Sstevel@tonic-gate * Definitions of type classifications: 1077c478bd9Sstevel@tonic-gate * MM_HARD Hardware 1087c478bd9Sstevel@tonic-gate * MM_SOFT Software 1097c478bd9Sstevel@tonic-gate * MM_FIRM Firmware 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #define MM_HARD 0x00000001L 1137c478bd9Sstevel@tonic-gate #define MM_SOFT 0x00000002L 1147c478bd9Sstevel@tonic-gate #define MM_FIRM 0x00000004L 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1177c478bd9Sstevel@tonic-gate * Definitions of recoverability subclassification 1187c478bd9Sstevel@tonic-gate * MM_RECOVER Recoverable 1197c478bd9Sstevel@tonic-gate * MM_NRECOV Non-recoverable 1207c478bd9Sstevel@tonic-gate */ 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate #define MM_RECOVER 0x00000100L 1237c478bd9Sstevel@tonic-gate #define MM_NRECOV 0x00000200L 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * Definitions of source subclassification 1277c478bd9Sstevel@tonic-gate * MM_APPL Application 1287c478bd9Sstevel@tonic-gate * MM_UTIL Utility 1297c478bd9Sstevel@tonic-gate * MM_OPSYS Kernel 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #define MM_APPL 0x00000008L 1337c478bd9Sstevel@tonic-gate #define MM_UTIL 0x00000010L 1347c478bd9Sstevel@tonic-gate #define MM_OPSYS 0x00000020L 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * Definitions for the action to take with the message: 1387c478bd9Sstevel@tonic-gate * MM_PRINT Write to the standard error stream 1397c478bd9Sstevel@tonic-gate * MM_CONSOLE Treat the message as a console message 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #define MM_PRINT 0x00000040L 1437c478bd9Sstevel@tonic-gate #define MM_CONSOLE 0x00000080L 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Constants for severity values 1477c478bd9Sstevel@tonic-gate * 1487c478bd9Sstevel@tonic-gate * SEV_LEVEL Names the env variable that defines severities 1497c478bd9Sstevel@tonic-gate * 1507c478bd9Sstevel@tonic-gate * MM_NOSEV Message has no severity 1517c478bd9Sstevel@tonic-gate * MM_HALT Message describes a severe error condition 1527c478bd9Sstevel@tonic-gate * MM_ERROR Message describes an error condition 1537c478bd9Sstevel@tonic-gate * MM_WARNING Message tells of probable error condition 1547c478bd9Sstevel@tonic-gate * MM_INFO Message informs, not in error 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 1587c478bd9Sstevel@tonic-gate #define SEV_LEVEL "SEV_LEVEL" 1597c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate #define MM_NOSEV 0 1627c478bd9Sstevel@tonic-gate #define MM_HALT 1 1637c478bd9Sstevel@tonic-gate #define MM_ERROR 2 1647c478bd9Sstevel@tonic-gate #define MM_WARNING 3 1657c478bd9Sstevel@tonic-gate #define MM_INFO 4 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * Null values for message components 1697c478bd9Sstevel@tonic-gate * MM_NULLLBL Null value for the label-component 1707c478bd9Sstevel@tonic-gate * MM_NULLSEV Null value for the severity-component 1717c478bd9Sstevel@tonic-gate * MM_NULLMC Null value for the classification-component 1727c478bd9Sstevel@tonic-gate * MM_NULLTXT Null value for the text-component 1737c478bd9Sstevel@tonic-gate * MM_NULLACT Null value for the action-component 1747c478bd9Sstevel@tonic-gate * MM_NULLTAG Null value for the tag-component 1757c478bd9Sstevel@tonic-gate */ 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate #define MM_NULLLBL ((char *)_NULL) 1787c478bd9Sstevel@tonic-gate #define MM_NULLSEV MM_NOSEV 1797c478bd9Sstevel@tonic-gate #define MM_NULLMC MM_NULL 1807c478bd9Sstevel@tonic-gate #define MM_NULLTXT ((char *)_NULL) 1817c478bd9Sstevel@tonic-gate #define MM_NULLACT ((char *)_NULL) 1827c478bd9Sstevel@tonic-gate #define MM_NULLTAG ((char *)_NULL) 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate /* 1857c478bd9Sstevel@tonic-gate * Values returned by fmtmsg() 1867c478bd9Sstevel@tonic-gate * 1877c478bd9Sstevel@tonic-gate * MM_NOTOK None of the requested messages were generated 1887c478bd9Sstevel@tonic-gate * MM_NOMSG No message was written to stderr 1897c478bd9Sstevel@tonic-gate * MM_NOCON No console message was generated 1907c478bd9Sstevel@tonic-gate */ 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate #define MM_NOTOK -1 1937c478bd9Sstevel@tonic-gate #define MM_OK 0x00 1947c478bd9Sstevel@tonic-gate #define MM_NOMSG 0x01 1957c478bd9Sstevel@tonic-gate #define MM_NOCON 0x04 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate /* Function definition */ 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 2007c478bd9Sstevel@tonic-gate int addseverity(int, const char *); 2017c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate int fmtmsg(long, const char *, int, const char *, const char *, 2047c478bd9Sstevel@tonic-gate const char *); 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2077c478bd9Sstevel@tonic-gate } 2087c478bd9Sstevel@tonic-gate #endif 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate #endif /* _FMTMSG_H */ 211