1*0Sstevel@tonic-gate #ifndef errmsg_h 2*0Sstevel@tonic-gate #define errmsg_h 3*0Sstevel@tonic-gate 4*0Sstevel@tonic-gate /* 5*0Sstevel@tonic-gate * Copyright (c) 2000, 2001, 2002, 2003, 2004 by Martin C. Shepherd. 6*0Sstevel@tonic-gate * 7*0Sstevel@tonic-gate * All rights reserved. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * Permission is hereby granted, free of charge, to any person obtaining a 10*0Sstevel@tonic-gate * copy of this software and associated documentation files (the 11*0Sstevel@tonic-gate * "Software"), to deal in the Software without restriction, including 12*0Sstevel@tonic-gate * without limitation the rights to use, copy, modify, merge, publish, 13*0Sstevel@tonic-gate * distribute, and/or sell copies of the Software, and to permit persons 14*0Sstevel@tonic-gate * to whom the Software is furnished to do so, provided that the above 15*0Sstevel@tonic-gate * copyright notice(s) and this permission notice appear in all copies of 16*0Sstevel@tonic-gate * the Software and that both the above copyright notice(s) and this 17*0Sstevel@tonic-gate * permission notice appear in supporting documentation. 18*0Sstevel@tonic-gate * 19*0Sstevel@tonic-gate * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20*0Sstevel@tonic-gate * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21*0Sstevel@tonic-gate * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 22*0Sstevel@tonic-gate * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23*0Sstevel@tonic-gate * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 24*0Sstevel@tonic-gate * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 25*0Sstevel@tonic-gate * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 26*0Sstevel@tonic-gate * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 27*0Sstevel@tonic-gate * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 28*0Sstevel@tonic-gate * 29*0Sstevel@tonic-gate * Except as contained in this notice, the name of a copyright holder 30*0Sstevel@tonic-gate * shall not be used in advertising or otherwise to promote the sale, use 31*0Sstevel@tonic-gate * or other dealings in this Software without prior written authorization 32*0Sstevel@tonic-gate * of the copyright holder. 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate /* 38*0Sstevel@tonic-gate * Set the longest expected length of an error message (excluding its 39*0Sstevel@tonic-gate * '\0' terminator. Since any message over a nominal terminal width of 40*0Sstevel@tonic-gate * 80 characters is going to look a mess, it makes no sense to support 41*0Sstevel@tonic-gate * huge lengths. Note that many uses of strings declared with this 42*0Sstevel@tonic-gate * macro assume that it will be at least 81, so don't reduce it below 43*0Sstevel@tonic-gate * this limit. 44*0Sstevel@tonic-gate */ 45*0Sstevel@tonic-gate #define ERR_MSG_LEN 128 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate /* 48*0Sstevel@tonic-gate * Provide an opaque typedef to the error-message object. 49*0Sstevel@tonic-gate */ 50*0Sstevel@tonic-gate typedef struct ErrMsg ErrMsg; 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate /* 53*0Sstevel@tonic-gate * The following token is used to terminate the argument lists of calls 54*0Sstevel@tonic-gate * to _err_record_msg(). 55*0Sstevel@tonic-gate */ 56*0Sstevel@tonic-gate #define END_ERR_MSG ((const char *)0) 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate /* 59*0Sstevel@tonic-gate * Allocate a new error-message buffer. 60*0Sstevel@tonic-gate */ 61*0Sstevel@tonic-gate ErrMsg *_new_ErrMsg(void); 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate /* 64*0Sstevel@tonic-gate * Delete an error message buffer. 65*0Sstevel@tonic-gate */ 66*0Sstevel@tonic-gate ErrMsg *_del_ErrMsg(ErrMsg *err); 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * Concatenate a list of string arguments into the specified buffer, buff[], 70*0Sstevel@tonic-gate * which has an allocated size of buffdim characters. 71*0Sstevel@tonic-gate * The last argument must be END_ERR_MSG to terminate the argument list. 72*0Sstevel@tonic-gate */ 73*0Sstevel@tonic-gate void _err_record_msg(ErrMsg *err, ...); 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* 76*0Sstevel@tonic-gate * Replace the current error message with an empty string. 77*0Sstevel@tonic-gate */ 78*0Sstevel@tonic-gate void _err_clear_msg(ErrMsg *err); 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate /* 81*0Sstevel@tonic-gate * Return a pointer to the error message buffer. This is 82*0Sstevel@tonic-gate * a '\0' terminated character array containing ERR_MSG_LEN+1 83*0Sstevel@tonic-gate * elements. 84*0Sstevel@tonic-gate */ 85*0Sstevel@tonic-gate char *_err_get_msg(ErrMsg *err); 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate #endif 88