/*===========================================================================

FILE: errorlib.cpp
===========================================================================*/
#include "iautolog.h"


// --------------------------------------------------------------
//			function prototypes
// --------------------------------------------------------------
static	void	IAutoLog_ErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize );
static	void	IAutoLog_BTErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize );
static	void	IAutoLog_KDDIErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize );
static	void	IAutoLog_FILEErrorCheck( IAutoLog  *p, IFileMgr * pIFileMgr, char *pError, uint32 nSize );
static	void	IAutoLog_AUTOErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize );


//--------------------------------------------------------------
//	IAutoLog_ErrorCheck :: エラーコードの文字列をバッファに格納
//--------------------------------------------------------------
static void IAutoLog_ErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize )
{
	AutoLog		*pAutoLog = (AutoLog*) p ;
	char		pErrorStr[64] = "";


	if( pAutoLog == NULL ){		DBGPRINTF("IAutoLog NULL");		return;	}

	// エラーコードをチェックし、エラーコード文字列をローカルバッファに格納
	switch( nCode )
	{
	// Basic Error Codes
	case SUCCESS:
		SPRINTF(pErrorStr, "SUCCESS");
		break;

	case EFAILED:								// General failure
		SPRINTF(pErrorStr, "EFAILED");
		break;

	case ENOMEMORY:								// Out of memory
		SPRINTF(pErrorStr, "ENOMEMORY");
		break;

	case ECLASSNOTSUPPORT:						// Specified class unsupported
		SPRINTF(pErrorStr, "ECLASSNOTSUPPORT");
		break;

	case EVERSIONNOTSUPPORT:					// Version not supported
		SPRINTF(pErrorStr, "EVERSIONNOTSUPPORT");
		break;

	case EALREADYLOADED:						// Object already loaded
		SPRINTF(pErrorStr, "EALREADYLOADED");
		break;

	case EUNABLETOLOAD:							// Unable to load object/applet
		SPRINTF(pErrorStr, "EUNABLETOLOAD");
		break;

	case EUNABLETOUNLOAD:						// Unable to unload object/applet
		SPRINTF(pErrorStr, "EUNABLETOUNLOAD");
		break;

	case EALARMPENDING:							// Alarm is pending
		SPRINTF(pErrorStr, "EALARMPENDING");
		break;

	case EINVALIDTIME:							// Invalid time
		SPRINTF(pErrorStr, "EINVALIDTIME");
		break;

	case EBADCLASS:								// NULL class object
		SPRINTF(pErrorStr, "EBADCLASS");
		break;

	case EBADMETRIC:							// Invalid metric specified
		SPRINTF(pErrorStr, "EBADMETRIC");
		break;

	case EEXPIRED:								// App/Component Expired
		SPRINTF(pErrorStr, "EEXPIRED");
		break;

	case EBADSTATE:								// Invalid state
		SPRINTF(pErrorStr, "EBADSTATE");
		break;

	case EBADPARM:								// Invalid parameter
		SPRINTF(pErrorStr, "EBADPARAM");
		break;

	case ESCHEMENOTSUPPORTED:					// Invalid URL scheme
		SPRINTF(pErrorStr, "ESCHEMENOTSUPPORTED");
		break;

	case EBADITEM:								// Invalid item
		SPRINTF(pErrorStr, "EBADITEM");
		break;

	case EINVALIDFORMAT:						// Invalid format
		SPRINTF(pErrorStr, "EINVALIDFORMAT");
		break;

	case EINCOMPLETEITEM:						// Incomplete item
		SPRINTF(pErrorStr, "EINCOMPLETEITEM");
		break;

	case ENOPERSISTMEMORY:						// Insufficient flash
		SPRINTF(pErrorStr, "ENOPERSISTMEMORY");
		break;

	case EUNSUPPORTED:							// API is not supported
		SPRINTF(pErrorStr, "EUNSUPPORTED");
		break;

	case EPRIVLEVEL:							// Security violation
		SPRINTF(pErrorStr, "EPRIVLEVEL");
		break;

	case ERESOURCENOTFOUND:
		SPRINTF(pErrorStr, "ERESOURCENOTFOUND");
		break;

	case EREENTERED:
		SPRINTF(pErrorStr, "EREENTERED");
		break;

	case EBADTASK:
		SPRINTF(pErrorStr, "EBADTASK");
		break;

	case EALLOCATED:							// App/Module left memory allocated when released
		SPRINTF(pErrorStr, "EALLOCATED");
		break;

	case EALREADY:								// Operation is already in progress
		SPRINTF(pErrorStr, "EALREADY");
		break;

	case EADSAUTHBAD:							// ADS mutual authorization failed
		SPRINTF(pErrorStr, "EADSAUTHBAD");
		break;

	case ENEEDSERVICEPROG:						// Need service programming
		SPRINTF(pErrorStr, "ENEEDSERVICEPROG");
		break;

	case EMEMPTR:								// bad memory pointer
		SPRINTF(pErrorStr, "EMEMPTR");
		break;

	case EHEAP:									// heap corruption
		SPRINTF(pErrorStr, "EHEAP");
		break;

	case EIDLE:									// Context (system, interface, etc.) is idle
		SPRINTF(pErrorStr, "EIDLE");
		break;

	case EITEMBUSY:								// Context (system, interface, etc.) is busy
		SPRINTF(pErrorStr, "EITEMBUSY");
		break;

	case EBADSID:								// Invalid subscriber ID
		SPRINTF(pErrorStr, "EBADSID");
		break;

	case ENOTYPE:								// No type detected/found
		SPRINTF(pErrorStr, "ENOTYPE");
		break;

	case ENEEDMORE:								// Need more data/info
		SPRINTF(pErrorStr, "ENEEDMORE");
		break;

	case EADSCAPS:								// ADS Capabilities do not match those required for phone
		SPRINTF(pErrorStr, "EADSCAPS");
		break;

	// required for phones
	case EBADSHUTDOWN:							// App failed to close properly
		SPRINTF(pErrorStr, "EBADSHUTDOWN");
		break;

	// File Error Codes
	case EFILEEXISTS:							// File exists
		SPRINTF(pErrorStr, "EFILEEXISTS");
		break;

	case EFILENOEXISTS:							// File does not exist
		SPRINTF(pErrorStr, "EFILENOEXISTS");
		break;

	case EDIRNOTEMPTY:							// Directory not empty
		SPRINTF(pErrorStr, "EDIRNOTEMPTY");
		break;

	case EBADFILENAME:							// Bad file name
		SPRINTF(pErrorStr, "EBADFILENAME");
		break;

	case EBADSEEKPOS:							// Bad seek position
		SPRINTF(pErrorStr, "EBADSEEKPOS");
		break;

	case EFILEEOF:								// End of file
		SPRINTF(pErrorStr, "EFILEEOF");
		break;

	case EFSFULL:								// File system full
		SPRINTF(pErrorStr, "EFSFULL");
		break;

	case EFILEOPEN:								// File already open
		SPRINTF(pErrorStr, "EFILEOPEN");
		break;

	case EOUTOFNODES:							// No INODES (file slots) available
		SPRINTF(pErrorStr, "EOUTOFNODES");
		break;

// add sta 05.07.22 t.morishita #002
	case EDIRNOEXISTS:							// Directory does not exist
		SPRINTF(pErrorStr, "EDIRNOEXISTS");
		break;

	case EINVALIDOPERATION:						// invalid operation
		SPRINTF(pErrorStr, "EINVALIDOPERATION");
		break;
//	change start 05.12.09 BY OHSHIMA #003
/*
	case ENOMEDIA:								// Directory does not exist
		SPRINTF(pErrorStr, "ENOMEDIA");
		break;
*/
//	change end	 05.12.09 BY OHSHIMA 003
// add end 05.07.22 t.morishita #002

	// Network Error Codes except these following error values
	// Please pick these up on your source codes.
	// AEE_NET_SUCCESS
	// AEE_NET_ERROR
	// AEE_NET_WOULDBLOCK
	// AEE_NET_STREAM_ERROR
	// AEE_NET_STREAM_WOULDBLOCK
	case AEE_NET_EEOF:							// end of file
		SPRINTF(pErrorStr, "AEE_NET_EEOF");
		break;

	case AEE_NET_EBADF:							// Invalid socket descriptor
		SPRINTF(pErrorStr, "AEE_NET_EBADF");
		break;

	case AEE_NET_EFAULT:						// Invalid buffer or argument
		SPRINTF(pErrorStr, "AEE_NET_EFAULT");
		break;

	case AEE_NET_EWOULDBLOCK:					// Operation would block
		SPRINTF(pErrorStr, "AEE_NET_EWOULDBLOCK");
		break;

	case AEE_NET_EAFNOSUPPORT:					// Address family not supported
		SPRINTF(pErrorStr, "AEE_NET_EAFNOSUPPORT");
		break;

	case AEE_NET_EPROTOTYPE:					// Wrong protocol for socket type	
		SPRINTF(pErrorStr, "AEE_NET_EPROTOTYPE");
		break;

	case AEE_NET_ESOCKNOSUPPORT:				// Socket parameter not supported
		SPRINTF(pErrorStr, "AEE_NET_ESOCKNOSUPPORT");
		break;

	case AEE_NET_EPROTONOSUPPORT:				// Protocol not supported
		SPRINTF(pErrorStr, "AEE_NET_EPROTONOSUPPORT");
		break;

	case AEE_NET_EMFILE:						// No more sockets available for opening
		SPRINTF(pErrorStr, "AEE_NET_EMFILE");
		break;

	case AEE_NET_EOPNOTSUPP:					// Operation not supported
		SPRINTF(pErrorStr, "AEE_NET_EOPNOTSUPP");
		break;

	case AEE_NET_EADDRINUSE:					// Address already in use
		SPRINTF(pErrorStr, "AEE_NET_EADDRINUSE");
		break;

	case AEE_NET_EADDRREQ:						// Destination address required
		SPRINTF(pErrorStr, "AEE_NET_EADDRREQ");
		break;

	case AEE_NET_EINPROGRESS:					// Connection establishment in progress
		SPRINTF(pErrorStr, "AEE_NET_EINPROGRESS");
		break;

	case AEE_NET_EISCONN:						// Connection already established
		SPRINTF(pErrorStr, "AEE_NET_EISCONN");
		break;

	case AEE_NET_EIPADDRCHANGED:				// IP address changed, causing TCP reset
		SPRINTF(pErrorStr, "AEE_NET_EIPADDRCHANGED");
		break;

	case AEE_NET_ENOTCONN:						// socket not connected
		SPRINTF(pErrorStr, "AEE_NET_ENOTCONN");
		break;

	case AEE_NET_ECONNREFUSED:					// Connection attempt refused
		SPRINTF(pErrorStr, "AEE_NET_ECONNREFUSED");
		break;

	case AEE_NET_ETIMEDOUT:						// Connection attempt timed out
		SPRINTF(pErrorStr, "AEE_NET_ETIMEDOUT");
		break;

	case AEE_NET_ECONNRESET:					// Connection reset
		SPRINTF(pErrorStr, "AEE_NET_ECONNRESET");
		break;

	case AEE_NET_ECONNABORTED:					// Connection aborted
		SPRINTF(pErrorStr, "AEE_NET_ECONNABORTED");
		break;

	case AEE_NET_EPIPE:							// Broken pipe
		SPRINTF(pErrorStr, "AEE_NET_EPIPE");
		break;

	case AEE_NET_ENETDOWN:						// Network subsystem unavailable
		SPRINTF(pErrorStr, "AEE_NET_ENETDOWN");
		break;

	case AEE_NET_EMAPP:							// no more applications available
		SPRINTF(pErrorStr, "AEE_NET_EMAPP");
		break;

	case AEE_NET_EBADAPP:						// Invalid application ID
		SPRINTF(pErrorStr, "AEE_NET_EBADAPP");
		break;

	case AEE_NET_SOCKEXIST:						// there are existing sockets
		SPRINTF(pErrorStr, "AEE_NET_SOCKEXIST");
		break;

	case AEE_NET_EINVAL:						// invalid operation
		SPRINTF(pErrorStr, "AEE_NET_EINVAL");
		break;

	case AEE_NET_EMSGSIZE:						// message too long
		SPRINTF(pErrorStr, "AEE_NET_EMSGSIZE");
		break;

	case AEE_NET_EBADOPTNAME:					// bad option name
		SPRINTF(pErrorStr, "AEE_NET_EBADOPTNAME");
		break;

	case AEE_NET_EBADOPTLEN:					// bad option len
		SPRINTF(pErrorStr, "AEE_NET_EBADOPTLEN");
		break;

	case AEE_NET_EBADOPTVAL:					// bad option val
		SPRINTF(pErrorStr, "AEE_NET_EBADOPTVAL");
		break;

	case AEE_NET_ENOMEM:						// out of memory
		SPRINTF(pErrorStr, "AEE_NET_ENOMEM");
		break;

	case AEE_NET_ESHUTDOWN:						// connection shutdown
		SPRINTF(pErrorStr, "AEE_NET_ESHUTDOWN");
		break;

	// Network Subsystem Errors
	case AEE_NET_ENETISCONN:					// subsystem established and available
		SPRINTF(pErrorStr, "AEE_NET_ENETISCONN");
		break;

	case AEE_NET_ENETINPROGRESS:				// subsystem establishment in progress
		SPRINTF(pErrorStr, "AEE_NET_ENETINPROGRESS");
		break;

	case AEE_NET_ENETNONET:						// network subsystem unavailable
		SPRINTF(pErrorStr, "AEE_NET_ENETNONET");
		break;

	case AEE_NET_ENETCLOSEINPROGRESS:			// PPP is closing
		SPRINTF(pErrorStr, "AEE_NET_ENETCLOSEINPROGRESS");
		break;

	case AEE_NET_ENETEXIST:						// existing net subsystem resources
		SPRINTF(pErrorStr, "AEE_NET_ENETEXIST");
		break;

	case AEE_NET_GENERAL_FAILURE:				// General Failure
		SPRINTF(pErrorStr, "AEE_NET_GENERAL_FAILURE");
		break;

	// DNS (GetHostByName) Errors
	case AEE_NET_BADDOMAIN:						// Improperly formatted domain name
		SPRINTF(pErrorStr, "AEE_NET_BADDOMAIN");
		break;

	case AEE_NET_UNKDOMAIN:						// Unknown domain/no address records
		SPRINTF(pErrorStr, "AEE_NET_UNKDOMAIN");
		break;

	case AEE_NET_BADRESPONSE:					// Could not make sense of response
		SPRINTF(pErrorStr, "AEE_NET_BADRESPONSE");
		break;

	// SSL Error Codes
	case AEE_NET_EBADMAC:						// Incorrect MAC transerring data
		SPRINTF(pErrorStr, "AEE_NET_EBADMAC");
		break;

	case AEE_NET_ESSLCLIENTERR:					// Internal client-side SSL error
		SPRINTF(pErrorStr, "AEE_NET_ESSLCLIENTERR");
		break;

	case AEE_NET_ESSLSERVERERR:						// SSL server error: sent an alert, 
		SPRINTF(pErrorStr, "AEE_NET_ESSLSERVERERR");// too much data, bad padding...
		break;

	// Database and Address Book Errors
	case AEE_DB_EBADREC:
		SPRINTF(pErrorStr, "AEE_DB_EBADREC");
		break;

	case AEE_DB_EBADSTATE:
		SPRINTF(pErrorStr, "AEE_DB_EBADSTATE");
		break;

	case AEE_DB_ENULLREC:
		SPRINTF(pErrorStr, "AEE_DB_ENULLREC");
		break;

	case AEE_DB_ENULLFIELD:
		SPRINTF(pErrorStr, "AEE_DB_ENULLFIELD");
		break;

	case AEE_DB_EBADFIELDNUM:
		SPRINTF(pErrorStr, "AEE_DB_EBADFIELDNUM");
		break;

	// AddrBook Error Codes
	case AEE_ADDR_INVALID_FIELD_ID:				// Invalid or Unsupported Field ID
		SPRINTF(pErrorStr, "AEE_ADDR_INVALID_FIELD_ID");
		break;

	case AEE_ADDR_INVALID_FIELD_VALUE:			// Invalid Data Value for a Field
		SPRINTF(pErrorStr, "AEE_ADDR_INVALID_FIELD_VALUE");
		break;

	case AEE_ADDR_REC_NOT_FOUND:				// Record not found
		SPRINTF(pErrorStr, "AEE_ADDR_REC_NOT_FOUND");
		break;

	case AEE_ADDR_INVALID_REC:					// Invalid Record
		SPRINTF(pErrorStr, "AEE_ADDR_INVALID_REC");
		break;

	case AEE_ADDRBOOK_EBADSTATE:				// Addr Book in Bad State
		SPRINTF(pErrorStr, "AEE_ADDRBOOK_EBADSTATE");
		break;

	case AEE_ADDRBOOK_NOCATSUPPORT:				// No support for categories
		SPRINTF(pErrorStr, "AEE_ADDRBOOK_NOCATSUPPORT");
		break;

	case AEE_ADDR_CAT_NOT_SUPPORTED:			// This category not supported
		SPRINTF(pErrorStr, "AEE_ADDR_CAT_NOT_SUPPORTED");
		break;

	// Digital Signature Errors except the following error value
	// Please pick it up on your source code
	// SIG_ERROR_LAST
	case SIG_INVALID:							// Invalid signature
		SPRINTF(pErrorStr, "SIG_INVALID");
		break;

	case SIG_FILE_MISSING:						// SIG file missing
		SPRINTF(pErrorStr, "SIG_FILE_MISSING");
		break;

	case SIG_FILE_INVALID:						// Invalid SIG file format
		SPRINTF(pErrorStr, "SIG_FILE_INVALID");
		break;

	case SIG_EXPIRED:							// Expired signature
		SPRINTF(pErrorStr, "SIG_EXPIRED");
		break;

	case SIG_NO_PERMISSION:						// No valid permission
		SPRINTF(pErrorStr, "SIG_NO_PERMISSION");
		break;

	case SIG_INVALID_ESN:						// ESN is not valid
		SPRINTF(pErrorStr, "SIG_INVALID_ESN");
		break;

	case SIG_SIGNED_FILE_MISSING:				// signed file missing
		SPRINTF(pErrorStr, "SIG_SIGNED_FILE_MISSING");
		break;

	case SIG_FILE_INVALID_VERSION:				// Invalid SIG file major version
		SPRINTF(pErrorStr, "SIG_FILE_INVALID_VERSION");
		break;

	case SIG_BN_ERROR:							// BN lib error
		SPRINTF(pErrorStr, "SIG_BN_ERROR");
		break;

	case SIG_INVALID_CMS_FORMAT:				// fail to parse CMS
		SPRINTF(pErrorStr, "SIG_INVALID_CMS_FORMAT");
		break;

	case SIG_X509_INVALID_ISSUER:				// invalid issuer in X509 cert chain
		SPRINTF(pErrorStr, "SIG_X509_INVALID_ISSUER");
		break;

	case SIG_X509_INVALID_TIME:					// Invalid time format in X509 cert
		SPRINTF(pErrorStr, "SIG_X509_INVALID_TIME");
		break;

	case SIG_X509_EXPIRED:						// x509 expired
		SPRINTF(pErrorStr, "SIG_X509_EXPIRED");
		break;

	case SIG_X509_INVALID:						// invalid X509
		SPRINTF(pErrorStr, "SIG_X509_INVALID");
		break;

	case SIG_X509_INVALID_PUBKEY:				// invalid public key
		SPRINTF(pErrorStr, "SIG_X509_INVALID_PUBKEY");
		break;

	case SIG_X509_INVALID_SERIAL:				// invalid serial number
		SPRINTF(pErrorStr, "SIG_X509_INVALID_SERIAL");
		break;

	case SIG_CERT_MISSING:						// missing cert
		SPRINTF(pErrorStr, "SIG_CERT_MISSING");
		break;

	case SIG_INVALID_TS_FORMAT:					// invalid TimsStampResp
		SPRINTF(pErrorStr, "SIG_INVALID_TS_FORMAT");
		break;

	case SIG_INVALID_CMS_SIG:					// invalid signature in CMS
		SPRINTF(pErrorStr, "SIG_INVALID_CMS_SIG");
		break;

	case SIG_INVALID_ROOT_TYPE:					// invalid root type
		SPRINTF(pErrorStr, "SIG_INVALID_ROOT_TYPE");
		break;

	case SIG_INVALID_MSG_IMPRINT:				// invalid message imprint in TSRequest
		SPRINTF(pErrorStr, "SIG_INVALID_MSG_IMPRINT");
		break;

	case SIG_CANNOT_OPEN_CERTCACHE:				// cannot create an instance of the cert cache
		SPRINTF(pErrorStr, "SIG_CANNOT_OPEN_CERTCACHE");
		break;

	case SIG_FILE_CANNOT_TRUNCATE:				// cannot truncate the sig file to get rid of the certs
		SPRINTF(pErrorStr, "SIG_FILE_CANNOT_TRUNCATE");
		break;

	case SIG_INVALID_BYTE_RANGE:				// the signed byte range is invalid for the signed files
		SPRINTF(pErrorStr, "SIG_INVALID_BYTE_RANGE");
		break;

	case SIG_INVALID_TYPE:						// invalid signature type
		SPRINTF(pErrorStr, "SIG_INVALID_TYPE");
		break;

	case SIG_CMS_TOO_MANY_CERTS:				// too many certs, just want to protect us from infinite loop
		SPRINTF(pErrorStr, "SIG_CMS_TOO_MANY_CERTS");
		break;

	case SIG_INVALID_CERT_PERMISSION:			// The permission in the cert doesn't match the permission in the signature blob
		SPRINTF(pErrorStr, "SIG_INVALID_CERT_PERMISSION");
		break;

	case SIG_X509_NO_PERMISSION:				// Permission list is empty in X509
		SPRINTF(pErrorStr, "SIG_X509_NO_PERMISSION");
		break;

	case SIG_NO_MEMORY:							// not enough memory for the MD5 hash buffer
		SPRINTF(pErrorStr, "SIG_NO_MEMORY");
		break;

	case SIG_INVALID_HEADER_BYTE_RANGE:			// invalid header signed byte range
		SPRINTF(pErrorStr, "SIG_INVALID_HEADER_BYTE_RANGE");
		break;

	case SIG_INVALID_CMS_ECONTENT:
		SPRINTF(pErrorStr, "SIG_INVALID_CMS_ECONTENT");
		break;

	case SIG_INVALID_CMS_TS:
		SPRINTF(pErrorStr, "SIG_INVALID_CMS_TS");
		break;

	case SIG_MISSINGMODMIF_IN_SIG:
		SPRINTF(pErrorStr, "SIG_MISSINGMODMIF_IN_SIG");
		break;

/*	case SIG_ERROR_LAST:
		SPRINTF(pErrorStr, "SIG_ERROR_LAST");
		break;
*/
	// Web Errors
	case WEB_ERROR_PROTOCOL:					// protocol error, ask response for extended information
		SPRINTF(pErrorStr, "WEB_ERROR_PROTOCOL");
		break;

	case WEB_ERROR_BADURL:						// malformed URL
		SPRINTF(pErrorStr, "WEB_ERROR_BADURL");
		break;

	case WEB_ERROR_BADHOSTNAME:					// malformed hostname in URL
		SPRINTF(pErrorStr, "WEB_ERROR_BADHOSTNAME");
		break;

	case WEB_ERROR_BADPORT:						// malformed port in URL
		SPRINTF(pErrorStr, "WEB_ERROR_BADPORT");
		break;

	case WEB_ERROR_UNSUPSCHEME:					// unsupported scheme, no handler found
		SPRINTF(pErrorStr, "WEB_ERROR_UNSUPSCHEME");
		break;

	case WEB_ERROR_DNSCONFIG:					// no DNS servers configured
		SPRINTF(pErrorStr, "WEB_ERROR_DNSCONFIG");
		break;

	case WEB_ERROR_DNSTIMEOUT:					// no response from server
		SPRINTF(pErrorStr, "WEB_ERROR_DNSTIMEOUT");
		break;

	case WEB_ERROR_ADDRUNKNOWN:					// DNS server responded 'address unknown'
		SPRINTF(pErrorStr, "WEB_ERROR_ADDRUNKNOWN");
		break;

	case WEB_ERROR_CONNECT:						// some kind of connect error
		SPRINTF(pErrorStr, "WEB_ERROR_CONNECT");
		break;

	case WEB_ERROR_SEND:						// error writing to socket
		SPRINTF(pErrorStr, "WEB_ERROR_SEND");
		break;

	case WEB_ERROR_RECV:						// error reading from socket
		SPRINTF(pErrorStr, "WEB_ERROR_RECV");
		break;

	case WEB_ERROR_BADRESPONSE:					// mal-formed headers
		SPRINTF(pErrorStr, "WEB_ERROR_BADRESPONSE");
		break;

	case WEB_ERROR_BODYLENGTH:						// a request body was specified, but no content length was supplied,
		SPRINTF(pErrorStr, "WEB_ERROR_BODYLENGTH");	// or an incorrect body length was supplied
		break;

	case WEB_ERROR_PROXYSPEC:					// invalid proxy spec
		SPRINTF(pErrorStr, "WEB_ERROR_PROXYSPEC");
		break;

	case WEB_ERROR_SSL:							// SSL specific erro, , ask response for extended info
		SPRINTF(pErrorStr, "WEB_ERROR_SSL");
		break;

	// Security Errors
	case AEE_HASH_INVALID_CTX:					// invalid hash algorithm context
		SPRINTF(pErrorStr, "AEE_HASH_INVALID_CTX");
		break;

	case AEE_HASH_MORE_DATA:					// buffer not large enough to hold hashed result
		SPRINTF(pErrorStr, "AEE_HASH_MORE_DATA");
		break;

	case AEE_CRYPT_INVALID_KEY:					// Invalid key for encrypting or decrypting
		SPRINTF(pErrorStr, "AEE_CRYPT_INVALID_KEY");
		break;

	case AEE_CRYPT_INVALID_PADTYPE:				// Invalid pad type for encrypting or decrypting
		SPRINTF(pErrorStr, "AEE_CRYPT_INVALID_PADTYPE");
		break;

	case AEE_CRYPT_PAD_ERROR:					// An error occurred adding padding
		SPRINTF(pErrorStr, "AEE_CRYPT_PAD_ERROR");
		break;
		
	case AEE_CRYPT_ROLLBACKATTACK:				// SSLv23 Rollback Attack detected 
		SPRINTF(pErrorStr, "AEE_CRYPT_ROLLBACKATTACK");
		break;

	case AEE_CRYPT_BUFFER_TOO_SMALL:			// buffer not large enough to hold encrypted result
		SPRINTF(pErrorStr, "AEE_CRYPT_BUFFER_TOO_SMALL");
		break;

	case AEE_CRYPT_INVALID_IV:					// Invalid initialization vector for cipher function
		SPRINTF(pErrorStr, "AEE_CRYPT_INVALID_IV");
		break;

	case AEE_X509_BAD_CERT:						// Certificate couldn't be parsed (maybe it's not an X.509 cert
		SPRINTF(pErrorStr, "AEE_X509_BAD_CERT");
		break;

	case AEE_X509_BAD_VALIDITY:					// The validity dates in the cert can't be parsed
		SPRINTF(pErrorStr, "AEE_X509_BAD_VALIDITY");
		break;

	case AEE_X509_BAD_KEY:						// The public key is understood but can't be parsed
		SPRINTF(pErrorStr, "AEE_X509_BAD_KEY");
		break;

	case AEE_X509_UNKNOWN_KEY:					// Don't understand the type of public key (wrong algorithm)
		SPRINTF(pErrorStr, "AEE_X509_UNKNOWN_KEY");
		break;

	case AEE_X509_UNKNOWN_SIG:					// The signature on the cert is unknown
		SPRINTF(pErrorStr, "AEE_X509_UNKNOWN_SIG");
		break;

	case AEE_X509_NO_LEAF:						// Couldn't check chain - there's no leaf cert
		SPRINTF(pErrorStr, "AEE_X509_NO_LEAF");
		break;

	case AEE_X509_NO_PART:						// Couldn't find cert field part
		SPRINTF(pErrorStr, "AEE_X509_NO_PART");
		break;

	case AEE_X509_NO_CHAIN_YET:					// Chain hasn't been computed (verify hasn't been called)
		SPRINTF(pErrorStr, "AEE_X509_NO_CHAIN_YET");
		break;

	// IVocoder Errors
	case AEE_VOC_ENOT_STARTED:
		SPRINTF(pErrorStr, "AEE_VOC_ENOT_STARTED");
		break;

	case AEE_VOC_ENOT_AVAIL:
		SPRINTF(pErrorStr, "AEE_VOC_ENOT_AVAIL");
		break;

	case AEE_VOC_EIN_USE:
		SPRINTF(pErrorStr, "AEE_VOC_EIN_USE");
		break;

	case AEE_VOC_ENOT_CONFIGED:
		SPRINTF(pErrorStr, "AEE_VOC_ENOT_CONFIGED");
		break;

	case AEE_VOC_ERATE_OUT_OF_RANGE:
		SPRINTF(pErrorStr, "AEE_VOC_ERATE_OUT_OF_RANGE");
		break;

	case AEE_VOC_EBUFFER_EMPTY:
		SPRINTF(pErrorStr, "AEE_VOC_EBUFFER_EMPTY");
		break;

	case AEE_VOC_EBUFFER_FULL:
		SPRINTF(pErrorStr, "AEE_VOC_EBUFFER_FULL");
		break;

	case AEE_VOC_EACTIVE:
		SPRINTF(pErrorStr, "AEE_VOC_EACTIVE");
		break;

	case AEE_VOC_EBAD_TX_REDUCTION:
		SPRINTF(pErrorStr, "AEE_VOC_EBAD_TX_REDUCTION");
		break;

	// Multimedia (IMedia) Errors except these following error values
	// Please pick these up on your source codes
	// MM_ERROR
	// MM_PENDING
	case MM_EBADMEDIADATA:						// Bad media data
		SPRINTF(pErrorStr, "MM_EBADMEDIADATA");
		break;

	case MM_ENOMEDIAMEMORY:						// No memory for IMedia objects
		SPRINTF(pErrorStr, "MM_ENOMEDIAMEMORY");
		break;

	case MM_EMIDIOUTNOTOPEN:					// MIDI Out Device is not open
		SPRINTF(pErrorStr, "MM_EMIDIOUTNOTOPEN");
		break;

	case MM_EPEEK:								// IPeek error occurred
		SPRINTF(pErrorStr, "MM_EPEEK");
		break;

	case MM_ENOTENOUGHTDATA:					// Operation aborted due to insufficient data
		SPRINTF(pErrorStr, "MM_ENOTENOUGHTDATA");
		break;

	// SSL Protocol Errors (also see security errors)
	case SSL_RESULT_SECURED:					// Connection was secured
		SPRINTF(pErrorStr, "SSL_RESULT_SECURED");
		break;

	case SSL_RESULT_ALGS_ERR:					// No algorithms in common, May SSL_RESULT_HANDSHAKE instead
		SPRINTF(pErrorStr, "SSL_RESULT_ALGS_ERR");
		break;

	case SSL_RESULT_TRUST_ERR:					// Overridable trust error, see IX509Chain
		SPRINTF(pErrorStr, "SSL_RESULT_TRUST_ERR");
		break;

	case SSL_RESULT_CERT_ERR:					// Non overridable cert problem
		SPRINTF(pErrorStr, "SSL_RESULT_CERT_ERR");
		break;

	case SSL_RESULT_PROTO_ERR:					// Some fundamental error with the protocol interaction
		SPRINTF(pErrorStr, "SSL_RESULT_PROTO_ERR");
		break;

	case SSL_RESULT_CLIENT_AUTH_ERR:			// Client authentication is required by server
		SPRINTF(pErrorStr, "SSL_RESULT_CLIENT_AUTH_ERR");
		break;

	case SSL_RESULT_CLOSED:						// Session was securely closed
		SPRINTF(pErrorStr, "SSL_RESULT_CLOSED");
		break;

	case SSL_RESULT_HANDSHAKE:					// Something went wrong with the handshake, like a bad mac error
		SPRINTF(pErrorStr, "SSL_RESULT_HANDSHAKE");
		break;

	case SSL_RESULT_UNINITIALIZED:				// You forgot to setup something in ISSL, like the server's socket
		SPRINTF(pErrorStr, "SSL_RESULT_UNINITIALIZED");
		break;

	case SSL_RESULT_ERR:						// Something very wrong
		SPRINTF(pErrorStr, "SSL_RESULT_ERR");
		break;

	case SSL_RESULT_VERS_UNSUP:					// Client doesn't support any of request SSL proto versions
		SPRINTF(pErrorStr, "SSL_RESULT_VERS_UNSUP");
		break;

	case SSL_RESULT_CSUITE_UNSUP:				// Client doesn't support any of requested cipher suites
		SPRINTF(pErrorStr, "SSL_RESULT_CSUITE_UNSUP");
		break;

	case SSL_RESULT_SERV_VERS:
		SPRINTF(pErrorStr, "SSL_RESULT_SERV_VERS");
		break;

	case SSL_RESULT_TRUST_CHECK:				// Suspended pending trust checks by the client
		SPRINTF(pErrorStr, "SSL_RESULT_TRUST_CHECK");
		break;

	case SSL_RESULT_SOCKET_ERROR:				// There is a socket error. Use ISOCKET_GetLastError to get the socket error code
		SPRINTF(pErrorStr, "SSL_RESULT_SOCKET_ERROR");
		break;

	case SSL_RESULT_SECURITY_LEVEL_ERR:			// Security level mismatch when negotiate called on secured ISSL
		SPRINTF(pErrorStr, "SSL_RESULT_SECURITY_LEVEL_ERR");
		break;

	case SSL_RESULT_CLOSE_NOTIFY_SENT:			// Close Notify is sent, but has not received server's close notify
		SPRINTF(pErrorStr, "SSL_RESULT_CLOSE_NOTIFY_SENT");
		break;

	case SSL_RESULT_BAD_SERVER_KEY:				// Server's key is bad (e.g., the key in the server's cert)
		SPRINTF(pErrorStr, "SSL_RESULT_BAD_SERVER_KEY");
		break;

	case SSL_RESULT_BAD_STATE:						// SSL is not in the right state. Most likely a previously call is in progress
		SPRINTF(pErrorStr, "SSL_RESULT_BAD_STATE");	// and needs to be explicitly cancelled
		break;

	// BREW Camera Errors except the following error values
	// Plese pick it up on your sorce codes
	// CAM_PENDING
	case CAM_EPREVIEWFAIL:						// Start preview failed
		SPRINTF(pErrorStr, "CAM_EPREVIEWFAIL");
		break;

	case CAM_ESNAPSHOTFAIL:						// Record snaphot failed
		SPRINTF(pErrorStr, "CAM_ESNAPSHOTFAIL");
		break;

	case CAM_ESAVEFAIL:							// Save snapshot failed
		SPRINTF(pErrorStr, "CAM_ESAVEFAIL");
		break;

	case CAM_EMOVIEFAIL:						// Start movie failed
		SPRINTF(pErrorStr, "CAM_EMOVIEFAIL");
		break;

	case CAM_EPAUSEFAIL:						// Pause operation failed	
		SPRINTF(pErrorStr, "CAM_EPAUSEFAIL");
		break;

	case CAM_ERESUMEFAIL:						// Resume operation failed
		SPRINTF(pErrorStr, "CAM_ERESUMEFAIL");
		break;

	case CAM_ESETPARMFAIL:						// SetParm operation failed
		SPRINTF(pErrorStr, "CAM_ESETPARMFAIL");
		break;

	default:									// Unknown error
		SPRINTF(pErrorStr, "Unknown Error");
		break;
	}

	DBGPRINTF("the length: %d", nSize);
	DBGPRINTF("error code: %d", nCode);
	DBGPRINTF("error string: %s", pErrorStr);
	DBGPRINTF("the length of the error string: %d", STRLEN(pErrorStr));

	// バッファの初期化
	MEMSET(pError, '\0', nSize);
	// バッファにコピー
	if( STRLEN(pErrorStr) > nSize-1 ){
		STRNCPY(pError, pErrorStr, nSize-1);
	}
	else{
		STRNCPY(pError, pErrorStr, STRLEN(pErrorStr));
	}

	DBGPRINTF("the return error string: %s", pError);

	return;
}

//--------------------------------------------------------------
//	IAutoLog_BTErrorCheck :: エラーコードの文字列をバッファに格納
//--------------------------------------------------------------
static void IAutoLog_BTErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize )
{
	AutoLog		*pAutoLog = (AutoLog*) p ;
	char		pErrorStr[64] = "";

#if 0

	if( pAutoLog == NULL ){		DBGPRINTF("IAutoLog NULL");		return;	}

	// エラーコードをチェックし、エラーコード文字列をローカルバッファに格納
	switch( nCode )
	{
	// BLUE TOOTH Error Codes Mostly Redefines of NET WORK ERRORS
	// except the following error value
	// Please pick it up on your source codes
	// AEE_BTSDP_EINPROGRESS
	case AEE_BT_SUCCESS:
		SPRINTF(pErrorStr, "AEE_BT_SUCCESS");
		break;

	case AEE_BT_ERROR:
		SPRINTF(pErrorStr, "AEE_BT_ERROR");
		break;

	case AEE_BT_WOULDBLOCK:
		SPRINTF(pErrorStr, "AEE_BT_WOULDBLOCK");
		break;

	case AEE_BT_EBADF:							// Invalid descriptor
		SPRINTF(pErrorStr, "AEE_BT_EBADF");
		break;

	case AEE_BT_EFAULT:							// Invalid buffer or argument
		SPRINTF(pErrorStr, "AEE_BT_EFAULT");
		break;

	case AEE_BT_EINPROGRESS:					// Connection establishment in progress
		SPRINTF(pErrorStr, "AEE_BT_EINPROGRESS");
		break;

/*	case AEE_BTSDP_EINPROGRESS:					// Discovery in progress
		SPRINTF(pErrorStr, "AEE_BTSDP_EINPROGRESS");
		break;
*/
	case AEE_BT_EINVAL:							// Invalid operation
		SPRINTF(pErrorStr, "AEE_BT_EINVAL");
		break;

	case AEE_BT_ECONNABORTED:
		SPRINTF(pErrorStr, "AEE_BT_ECONNABORTED");
		break;

	default:									// Unknown error
		SPRINTF(pErrorStr, "Unknown Error");
		break;
	}

	DBGPRINTF("the length: %d", nSize);
	DBGPRINTF("error code: %d", nCode);
	DBGPRINTF("error string: %s", pErrorStr);
	DBGPRINTF("the length of the error string: %d", STRLEN(pErrorStr));

	// バッファの初期化
	MEMSET(pError, '\0', nSize);
	// バッファにコピー
	if( STRLEN(pErrorStr) > nSize-1 ){
		STRNCPY(pError, pErrorStr, nSize-1);
	}
	else{
		STRNCPY(pError, pErrorStr, STRLEN(pErrorStr));
	}

	DBGPRINTF("the return error string: %s", pError);

#endif
	return;
}

//--------------------------------------------------------------
//	IAutoLog_KDDIErrorCheck :: エラーコードの文字列をバッファに格納
//--------------------------------------------------------------
static void IAutoLog_KDDIErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize )
{
	AutoLog			*pAutoLog = (AutoLog*) p ;
	char	pErrorStr[64] = "";


	if( pAutoLog == NULL ){		DBGPRINTF("IAutoLog NULL");		return;	}

	// エラーコードをチェックし、エラーコード文字列をローカルバッファに格納
	switch( nCode )
	{
	// KDDI Error Codes
	case KDDI_SUCCESS:							// 成功
		SPRINTF(pErrorStr, "KDDI_SUCCESS");
		break;

	case KDDI_EFAILED:							// 失敗
		SPRINTF(pErrorStr, "KDDI_EFAILED");
		break;

	case KDDI_EBADPARAM:						// 不正なパラメータ
		SPRINTF(pErrorStr, "KDDI_EBADPARAM");
		break;

	case KDDI_EUNSUPPORTED:						// サポートされていない
		SPRINTF(pErrorStr, "KDDI_EUNSUPPORTED");
		break;

	case KDDI_EMOREHITORIES:					// 履歴の数が確保された領域の数より多い
		SPRINTF(pErrorStr, "KDDI_EMOREHITORIES");
		break;

	case KDDI_EBADPROFILE:						// プロフィール情報が不正
		SPRINTF(pErrorStr, "KDDI_EBADPROFILE");
		break;

	case KDDI_EPRIVLEVEL:						// 特権レベルが不正
		SPRINTF(pErrorStr, "KDDI_EPRIVLEVEL");
		break;

	case KDDI_ERESTRICTED:						// アドレス帳アクセスが制限されている
		SPRINTF(pErrorStr, "KDDI_ERESTRICTED");
		break;

	case KDDI_EALREADY:							// 既に登録済み
		SPRINTF(pErrorStr, "KDDI_EALREADY");
		break;

	case KDDI_ESECRET:							// シークレットレコードにアクセス
		SPRINTF(pErrorStr, "KDDI_ESECRET");
		break;

	case KDDI_EFULL:							// 空きメモリ番号がない
		SPRINTF(pErrorStr, "KDDI_EFULL");
		break;

	default:									// Unknown error
		SPRINTF(pErrorStr, "Unknown Error");
		break;
	}

	DBGPRINTF("the length: %d", nSize);
	DBGPRINTF("error code: %d", nCode);
	DBGPRINTF("error string: %s", pErrorStr);
	DBGPRINTF("the length of the error string: %d", STRLEN(pErrorStr));

	// バッファの初期化
	MEMSET(pError, '\0', nSize);
	// バッファにコピー
	if( STRLEN(pErrorStr) > nSize-1 ){
		STRNCPY(pError, pErrorStr, nSize-1);
	}
	else{
		STRNCPY(pError, pErrorStr, STRLEN(pErrorStr));
	}

	DBGPRINTF("the return error string: %s", pError);

	return;
}


//--------------------------------------------------------------
//	IAutoLog_FILEErrorCheck :: エラーコードの文字列をバッファに格納
//--------------------------------------------------------------
static void IAutoLog_FILEErrorCheck( IAutoLog  *p, IFileMgr * pIFileMgr, char *pError, uint32 nSize )
{
	AutoLog		*pAutoLog = (AutoLog*) p ;
	char		pErrorStr[64] = "";
	int			nCode = 0;



	if( pAutoLog == NULL )	{	DBGPRINTF("IAutoLog NULL");		return;	}
	if( pIFileMgr == NULL )	{	DBGPRINTF("IFileMgr NULL");		return;	}

	// IFILE,IFILEMGR のエラーを取得
	nCode = IFILEMGR_GetLastError( pIFileMgr );

	// エラーコードをチェックし、エラーコード文字列をローカルバッファに格納
	switch( nCode )
	{
	// IFILE,IFILEMGR Error Codes
	case SUCCESS:
		SPRINTF(pErrorStr, "SUCCESS");				// 成功
		break;

	case EFILEEXISTS:							// ファイルが存在する
		SPRINTF(pErrorStr, "EFILEEXISTS");
		break;

	case EFILENOEXISTS:							// ファイルが存在しない
		SPRINTF(pErrorStr, "EFILENOEXISTS");
		break;

	case EDIRNOTEMPTY:							// ディレクトリが空でない
		SPRINTF(pErrorStr, "EDIRNOTEMPTY");
		break;

	case EBADFILENAME:							// ファイル名が不良
		SPRINTF(pErrorStr, "EBADFILENAME");
		break;

	case EBADSEEKPOS:							// シーク位置が不良
		SPRINTF(pErrorStr, "EBADSEEKPOS");
		break;

	case EFILEEOF:								// ファイルの終わり
		SPRINTF(pErrorStr, "EFILEEOF");
		break;

	case EFSFULL:								// ファイルシステムに空がない
		SPRINTF(pErrorStr, "EFSFULL");
		break;

	case EFILEOPEN:								// ファイルがすでにオープンしている
		SPRINTF(pErrorStr, "EFILEOPEN");
		break;

	case EBADPARM:								// パラメータが不良
		SPRINTF(pErrorStr, "EBADPARAM");
		break;

	default:									// Unknown error
		SPRINTF(pErrorStr, "Unknown Error");
		break;
	}

	DBGPRINTF("the length: %d", nSize);
	DBGPRINTF("error code: %d", nCode);
	DBGPRINTF("error string: %s", pErrorStr);
	DBGPRINTF("the length of the error string: %d", STRLEN(pErrorStr));

	// バッファの初期化
	MEMSET(pError, '\0', nSize);
	// バッファにコピー
	if( STRLEN(pErrorStr) > nSize-1 ){
		STRNCPY(pError, pErrorStr, nSize-1);
	}
	else{
		STRNCPY(pError, pErrorStr, STRLEN(pErrorStr));
	}

	DBGPRINTF("the return error string: %s", pError);

	return;
}


//--------------------------------------------------------------
//	IAutoLog_AUTOErrorCheck :: エラーコードの文字列をバッファに格納
//--------------------------------------------------------------
static void IAutoLog_AUTOErrorCheck( IAutoLog  *p, int nCode, char *pError, uint32 nSize )
{
	AutoLog		*pAutoLog = (AutoLog*) p ;
	char		pErrorStr[64] = "";

	
	if( pAutoLog == NULL ){		DBGPRINTF("IAutoLog NULL");		return;	}


	// エラーコードをチェックし、エラーコード文字列をローカルバッファに格納
	switch( nCode )
	{
	// IAutoLog Error Codes
	case IAUTOLOG_SUCCESS:							// 成功
		SPRINTF(pErrorStr, "IAUTOLOG_SUCCESS");
		break;

	case IAUTOLOG_EFAILED:							// 失敗
		SPRINTF(pErrorStr, "IAUTOLOG_EFAILED");
		break;

	case IAUTOLOG_EBADPARM:							// パラメータ不良
		SPRINTF(pErrorStr, "IAUTOLOG_EBADPARM");
		break;

	case IAUTOLOG_ENOMEMORY:						// IAUTOLOG_ENOMEMORY
		SPRINTF(pErrorStr, "IAUTOLOG_ENOMEMORY");
		break;

	case IAUTOLOG_ECLASS:							// IAUTOLOGインターフェース内で
		SPRINTF(pErrorStr, "IAUTOLOG_ECLASS");		// 使用しているインスタンスの作成失敗
		break;

	case IAUTOLOG_EDIRECTRY:						// ログ管理ディレクトリに関する処理の失敗
		SPRINTF(pErrorStr, "IAUTOLOG_EDIRECTRY");
		break;

	case IAUTOLOG_EFILE:							// ログファイルに関する処理の失敗
		SPRINTF(pErrorStr, "KDDI_EPRIVLEVEL");
		break;

	default:									// Unknown error
		SPRINTF(pErrorStr, "Unknown Error");
		break;
	}

	DBGPRINTF("the length: %d", nSize);
	DBGPRINTF("error code: %d", nCode);
	DBGPRINTF("error string: %s", pErrorStr);
	DBGPRINTF("the length of the error string: %d", STRLEN(pErrorStr));

	// バッファの初期化
	MEMSET(pError, '\0', nSize);
	// バッファにコピー
	if( STRLEN(pErrorStr) > nSize-1 ){
		STRNCPY(pError, pErrorStr, nSize-1);
	}
	else{
		STRNCPY(pError, pErrorStr, STRLEN(pErrorStr));
	}

	DBGPRINTF("the return error string: %s", pError);

	return;
}
