/*	XGPostUnixOSError.cpp
 *
 *		This knows how to deal with the MacOS Errors
 */

/*  YAAF - Yet another application framework
 *  Copyright (C) 1997, 1998 William Edward Woody
 *  
 *  This library is free software; you can redistribute it
 *  and/or modify it under the terms of the GNU Library
 *  General Public License as published by the Free Software
 *  Foundation; either version 2 of the License, or any
 *  later version.
 *  
 *  This library is distributed in the hope that it will be
 *  useful, but WITHOUT ANY WARRANTY; without even the implied
 *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE. See the GNU Library General Public License for
 *  more details.
 *  
 *  You should have received a copy of the GNU Library General
 *  Public License along with this library; if not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *  Boston, MA 02111-1307, USA.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#include <XConfig.h>

#if OPT_XWIN == 1

#include <string.h>
#include <XError.h>
#include <XDataUtil.h>

/************************************************************************/
/*																		*/
/*	Construction														*/
/*																		*/
/************************************************************************/

// @G"Constructors/Destructors"

/*	@F"XGPostUnixOSError::XGPostUnixOSError" @I
 *
 *		Create this error, appending the OS Error string to the message
 *	passed to me
 */

XGPostUnixOSError::XGPostUnixOSError(int err, unsigned long msg, ...)
{
	va_list vlist;
	
	va_start(vlist,msg);
	SetMessage(msg,vlist);
	va_end(vlist);
	
	fErrorID = err;
}

/************************************************************************/
/*																		*/
/*	Error Messages														*/
/*																		*/
/************************************************************************/

// @G"Public Methods"

/*	@F"XGPostUnixOSError::GetLongError" @I
 *
 *		Get the message string. This actually looks up the error message
 *	that was passed in the constructor and appends it to the error
 *	description.
 */

void XGPostUnixOSError::GetLongError(char *dest)
{
	char buffer[80];
	char buf2[256];
	
	XGPostError::GetLongError(buffer);
	GetErrorString(fErrorID,buf2);
	yformat(dest,"#S: #S",buf2,buffer);
}	

/************************************************************************/
/*																		*/
/*	Error Formatting													*/
/*																		*/
/************************************************************************/

/*	@F"XGPostUnixOSError::GetErrorString" @I
 *
 *		Get the error string. Looks up the error message associated with
 *	this Microsoft Windows specific OS error.
 */

void XGPostUnixOSError::GetErrorString(int err, char *str)
{
	::strcpy(str,::strerror(err));
}

#endif
