Home | History | Annotate | Download | only in Tools
      1 /******************************************************************************
      2 
      3  @File         PVRTError.cpp
      4 
      5  @Title        PVRTError
      6 
      7  @Version
      8 
      9  @Copyright    Copyright (c) Imagination Technologies Limited.
     10 
     11  @Platform     ANSI compatible
     12 
     13  @Description
     14 
     15 ******************************************************************************/
     16 
     17 #include "PVRTError.h"
     18 #include <stdarg.h>
     19 
     20 #include <stdio.h>
     21 #include <stdlib.h>
     22 #include <string.h>
     23 #if defined(_WIN32)
     24 #define vsnprintf _vsnprintf
     25 #endif
     26 
     27 /*!***************************************************************************
     28  @Function			PVRTErrorOutputDebug
     29  @Input				format		printf style format followed by arguments it requires
     30  @Description		Outputs a string to the standard error.
     31 *****************************************************************************/
     32 void PVRTErrorOutputDebug(char const * const format, ...)
     33 {
     34 	va_list arg;
     35 	char	pszString[1024];
     36 
     37 	va_start(arg, format);
     38 	vsnprintf(pszString, 1024, format, arg);
     39 	va_end(arg);
     40 
     41 
     42 #if defined(UNICODE)
     43 	wchar_t *pswzString = (wchar_t *)malloc((strlen(pszString) + 1) * sizeof(wchar_t));
     44 
     45 	int i;
     46 	for(i = 0; pszString[i] != '\0'; i++)
     47 	{
     48 		pswzString[i] = (wchar_t)(pszString[i]);
     49 	}
     50 	pswzString[i] = '\0';
     51 
     52 	#if defined(_WIN32)
     53 		OutputDebugString(pswzString);
     54 	#else
     55 		fprintf(stderr, pswzString);
     56 	#endif
     57 
     58 	free(pswzString);
     59 #else
     60 	#if defined(_WIN32)
     61 		OutputDebugString(pszString);
     62 	#else
     63 		fprintf(stderr, "%s", pszString);
     64 	#endif
     65 #endif
     66 }
     67 
     68 /*****************************************************************************
     69 End of file (PVRTError.cpp)
     70 *****************************************************************************/
     71 
     72