Beispiel #1
0
void _debug_vprintf(const char *format, va_list ap)
{
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
   /* EngDebugPrint does not handle float point arguments, so we need to use
    * our own vsnprintf implementation. It is also very slow, so buffer until
    * we find a newline. */
   static char buf[512] = {'\0'};
   size_t len = strlen(buf);
   int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
   if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
      _EngDebugPrint("%s", buf);
      buf[0] = '\0';
   }
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
   /* EngDebugPrint does not handle float point arguments, so we need to use
    * our own vsnprintf implementation. It is also very slow, so buffer until
    * we find a newline. */
   static char buf[512 + 1] = {'\0'};
   size_t len = strlen(buf);
   int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
   if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
      OutputDebugStringA(buf);
      buf[0] = '\0';
   }
#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) 
   /* TODO */
#else /* !PIPE_SUBSYSTEM_WINDOWS */
   vfprintf(stderr, format, ap);
#endif
}
Beispiel #2
0
/*GetElementByPath
tpath - path of element in xml tree (ie. /rootelement/parentelement[1]/childelement)
telement - on success, output is set to point to element specified by tpath
return True if element found
*/
Bool CXMLDocument::GetElementByPath(CXMLElement *telement, char *tpath)
{
	if (!isinited()) return False;
	char *sptr = tpath;
	Bool isroot = False;

	if (!GetRootElement(telement))
		return False;

	if (*sptr == '/') sptr++;
	char *nameend;
	char *nextname = strchr(sptr, '/');
	if (!nextname) 
	{
		if (!*sptr)
			return True;
		nextname = sptr+strlen(sptr);
		isroot = True;
		
	}
	char *numpointer = util_strchr(sptr,'[',nextname-sptr);
	if (numpointer)
			nameend = numpointer;
	else
			nameend = nextname;
	if (!util_strnicmp(telement->GetName(),sptr,nameend-sptr))
		if (isroot)
			return True;
		else
			return telement->GoChildByPath(nextname+1);
	return False;
}
Beispiel #3
0
/*GoChildByPath
tpath - path of child element (ie. /parentelement[1]/childelement)
telement - on success, navigates to element specified by tpath
return True if element found
*/
Bool CXMLElement::GoChildByPath(char *tpath)
{
	if (!isinited()) return False;
	char *sptr = tpath;
	char *childpointer = NULL;
	CXMLElement telement;
	telement.CopyElement(this);
	if (*sptr == '/') sptr++; //skip first slash
	Bool foundmatch = False;
	char *endptr = sptr + strlen(sptr);
	while (sptr < endptr)
	{
		char *namestart,*nameend,*nextname,*numpointer;
		nextname = strchr(sptr, '/' );
		if (!nextname) nextname = endptr;
		namestart = sptr;
		nameend = nextname;

		bool t_is_text;
		t_is_text = (nameend == namestart) || (namestart[0] == '[');

		if (!telement.GoChild(NULL, t_is_text))
			return False;
		
		int whichchild = 1;
		numpointer = util_strchr(sptr,'[',nameend-sptr);
		if (numpointer)
		{
			whichchild = strtol((const char *)++numpointer, NULL, 10);
			nameend = numpointer-1;
		}
		
		Bool foundmatch = False;
		int childcounter = 0;
		do
		{
			if ((!t_is_text && util_strnicmp(telement.GetName(),namestart,nameend-namestart)==0) ||
				(t_is_text && telement.IsTextNode()))
			{
				childcounter++;
				if (childcounter == whichchild)
				{
					sptr = nextname+1;
					foundmatch = True;
				}
			}
		}
		while (!foundmatch && telement.GoNext(NULL, t_is_text));
		if (!foundmatch)
			return False;
	}
	CopyElement(&telement);
	return True;

}
Beispiel #4
0
void _debug_vprintf(const char *format, va_list ap)
{
   /* We buffer until we find a newline. */
   static char buf[4096] = {'\0'};
   size_t len = strlen(buf);
   int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
   if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
      os_log_message(buf);
      buf[0] = '\0';
   }
}
Beispiel #5
0
void _debug_vprintf(const char *format, va_list ap)
{
   static char buf[4096] = {'\0'};
#if defined(PIPE_OS_WINDOWS) || defined(PIPE_SUBSYSTEM_EMBEDDED)
   /* We buffer until we find a newline. */
   size_t len = strlen(buf);
   int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
   if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
      os_log_message(buf);
      buf[0] = '\0';
   }
#else
   util_vsnprintf(buf, sizeof(buf), format, ap);
   os_log_message(buf);
#endif
}