2007-07-16 20:16:00 +00:00
|
|
|
/*
|
2008-03-04 05:20:05 +00:00
|
|
|
* $Id: misc.cpp 117 2008-03-03 11:20:05Z baconevi $
|
2007-09-25 20:25:00 +00:00
|
|
|
*
|
|
|
|
* {License}
|
2007-07-16 20:16:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2007-07-25 18:53:00 +00:00
|
|
|
#include "misc.h"
|
2007-08-26 23:33:00 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <tchar.h>
|
2007-07-16 20:16:00 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
|
|
|
#include <ase/cmn/types.h>
|
|
|
|
#include <ase/cmn/macros.h>
|
|
|
|
|
2007-07-17 20:20:00 +00:00
|
|
|
#pragma warning(disable:4996)
|
|
|
|
#pragma unmanaged
|
|
|
|
|
2007-07-16 20:16:00 +00:00
|
|
|
void ase_assert_abort (void)
|
|
|
|
{
|
|
|
|
::abort ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ase_assert_printf (const ase_char_t* fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
#ifdef _WIN32
|
|
|
|
int n;
|
|
|
|
ase_char_t buf[1024];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
va_start (ap, fmt);
|
|
|
|
|
|
|
|
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
|
|
|
|
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
|
|
|
|
|
|
|
|
//ase_vprintf (fmt, ap);
|
|
|
|
::MessageBox (NULL, buf,
|
|
|
|
ASE_T("ASSERTION FAILURE"), MB_OK|MB_ICONERROR);
|
|
|
|
|
|
|
|
va_end (ap);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-25 18:53:00 +00:00
|
|
|
char* unicode_to_multibyte (const wchar_t* in, int inlen, int* outlen)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
n = WideCharToMultiByte (CP_UTF8, 0, in, inlen, NULL, 0, NULL, 0);
|
|
|
|
|
|
|
|
char* ptr = (char*)::malloc (sizeof(char)*n);
|
|
|
|
if (ptr == NULL) return NULL;
|
|
|
|
|
|
|
|
*outlen = WideCharToMultiByte (CP_UTF8, 0, in, inlen, ptr, n, NULL, 0);
|
|
|
|
return ptr;
|
2007-08-22 22:56:00 +00:00
|
|
|
}
|