Beispiel #1
0
static const XML_Char *
resolveSystemId(const XML_Char *base, const XML_Char *systemId,
                XML_Char **toFree)
{
  XML_Char *s;
  *toFree = 0;
  if (!base
      || *systemId == T('/')
#if (defined(WIN32) || defined(__WATCOMC__))
      || *systemId == T('\\')
      || (isAsciiLetter(systemId[0]) && systemId[1] == T(':'))
#endif
     )
    return systemId;
  *toFree = (XML_Char *)malloc((tcslen(base) + tcslen(systemId) + 2)
                               * sizeof(XML_Char));
  if (!*toFree)
    return systemId;
  tcscpy(*toFree, base);
  s = *toFree;
  if (tcsrchr(s, T('/')))
    s = tcsrchr(s, T('/')) + 1;
#if (defined(WIN32) || defined(__WATCOMC__))
  if (tcsrchr(s, T('\\')))
    s = tcsrchr(s, T('\\')) + 1;
#endif
  tcscpy(s, systemId);
  return *toFree;
}
Beispiel #2
0
static int wince_mess_vprintf(char *fmt, va_list arg)
{
	int length;
	int old_length;
	LPTSTR new_messages;
	LPCTSTR tbuffer;
	char buffer[256];

	/* get into a buffer */
	length = vsnprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), fmt, arg);
	tbuffer = A2T(buffer);

	/* output to debugger */
	OutputDebugString(tbuffer);

	/* append the buffer to the rest of the messages */
	old_length = messages ? tcslen(messages) : 0;
	new_messages = realloc(messages, (old_length + tcslen(tbuffer) + 1) * sizeof(TCHAR));
	if (new_messages)
	{
		messages = new_messages;
		tcscpy(messages + old_length, tbuffer);
	}
	return length;
}
Beispiel #3
0
	/********************************************************************
	* [函数名]: insertCurrentTime
	* [描述]: 日志当前时间 (eg: YYYY-MM-DD hh:mm:ss)
	*         y: year    M: month    d: day
	*         h: hour    m: minute   s: second
	* [修改记录]:
	*   2015-05-20,littledj: create
	*   2015-05-20,littledj: 增加自定义格式
	********************************************************************/
	void GLogger::insertCurrentTime(tstring format)
	{
		if (format.empty())
			format = TEXT("** yyyy-MM-dd hh:mm:ss **\n");

		time_t tt = time(0);
		struct tm *lt = localtime(&tt);

		tchar* ct = new tchar[format.length() + 4];		
		tchar tmp[5];
		tcscpy(ct, format.c_str());
		for (size_t i = 0; i < format.size(); i++)
		{
			if (tcsncmp(ct + i, TEXT("yyyy"), 4 ) == 0)
			{
				stprintf(tmp, TEXT("%04d"), lt->tm_year + 1900);
				tcsncpy(ct + i, tmp, 4);
				i += 3;
				continue;
			}
			if (tcsncmp(ct + i, TEXT("MM"), 2) == 0)
			{
				stprintf(tmp, TEXT("%02d"), lt->tm_mon + 1);
				tcsncpy(ct + i, tmp, 2);
				i++;
				continue;
			}
			if (tcsncmp(ct + i, TEXT("dd"), 2) == 0)
			{
				stprintf(tmp, TEXT("%02d"), lt->tm_mday);
				tcsncpy(ct + i, tmp, 2);
				i++;
				continue;
			}
			if (tcsncmp(ct + i, TEXT("hh"), 2) == 0 || tcsncmp(ct + i, TEXT("HH"), 2) == 0)
			{
				stprintf(tmp, TEXT("%02d"), lt->tm_hour);
				tcsncpy(ct + i, tmp, 2);
				i++;
				continue;
			}
			if (tcsncmp(ct + i, TEXT("mm"), 2) == 0)
			{
				stprintf(tmp, TEXT("%02d"), lt->tm_min);
				tcsncpy(ct + i, tmp, 2);
				i++;
				continue;
			}
			if (tcsncmp(ct + i, TEXT("ss"), 2) == 0)
			{
				stprintf(tmp, TEXT("%02d"), lt->tm_sec);
				tcsncpy(ct + i, tmp, 2);
				i++;
				continue;
			}
		}

		tstring msg = formatMsg(PRINT_TYPE::RAW, TEXT("%s"), ct);
		delete[] ct;

		if (m_enableColor)
			output(msg, m_defaultColor);
		else
			output(msg);

		// 保存当前消息
		saveToMessagePool(PRINT_TYPE::RAW, msg);
	}