示例#1
0
文件: unix-sys.c 项目: mschaef/vcsh
int debug_printf(const _TCHAR * format, ...)
{
     int i;
     va_list args;
     _TCHAR buf[DEBUG_MESSAGE_BUF_SIZE];

     va_start(args, format);
     i = _vsntprintf(buf, DEBUG_MESSAGE_BUF_SIZE, format, args);
     va_end(args);

     sys_output_debug_string(buf);

     return i;
}
示例#2
0
size_t debug_port_write_chars(lref_t port, const _TCHAR *buf, size_t count)
{
     UNREFERENCED(port);
     assert(PORTP(port));

     _TCHAR block[DEBUG_PORT_BLOCK_SIZE + 1];

     size_t buf_loc = 0;
     size_t block_loc = 0;

     size_t len = count;

     /* Filter nulls out of the input string, and ensure that the
      * buffer we pass to OutputDebugString has as terminating
      * null. */
     while (len > 0)
     {
          for (block_loc = 0;
               (block_loc < DEBUG_PORT_BLOCK_SIZE) && (len > 0); block_loc++, buf_loc++, len--)
          {
               if (buf[buf_loc] == '\0')
                    block[block_loc] = '~';
               else
                    block[block_loc] = buf[buf_loc];
          }

          block[block_loc] = '\0';

          if (DEBUG_FLAG(DF_DEBUGGER_TO_ODS))
               sys_output_debug_string(block);
          else
               fputs(block, stderr);
     }

     return len;
}