Author: cwittich Date: Thu Sep 4 02:58:28 2008 New Revision: 35920
URL: http://svn.reactos.org/svn/reactos?rev=35920&view=rev Log: add a --process parameter to redirect stdout to dbgout
usage: dbgprint --process version_winetest.exe
Modified: trunk/reactos/base/applications/cmdutils/dbgprint/dbgprint.c
Modified: trunk/reactos/base/applications/cmdutils/dbgprint/dbgprint.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/dbgprint/dbgprint.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/dbgprint/dbgprint.c [iso-8859-1] Thu Sep 4 02:58:28 2008 @@ -5,11 +5,13 @@ * FILE: tools/dbgprint/dbgprint.c * PURPOSE: outputs a text via DbgPrint API * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@student.tugraz.at) + * Christoph von Wittich (Christoph_vW@ReactOS.org) */
#include <windows.h> #include <tchar.h> #include <debug.h> +#include <stdio.h>
int _tmain(int argc, TCHAR ** argv) { @@ -29,30 +31,48 @@ return -1; }
- buf = HeapAlloc(GetProcessHeap(), 0, (bufsize+1) * sizeof(TCHAR)); - if (!buf) + if (_tcsstr(argv[1], "--process") && (argc == 3)) { - return -1; + char psBuffer[128]; + FILE *pPipe; + + pPipe = _tpopen(argv[2], "r"); + if (pPipe != NULL) + { + while(fgets(psBuffer, 128, pPipe)) + { + OutputDebugStringA(psBuffer); + } + _pclose(pPipe); + } } + else + { + buf = HeapAlloc(GetProcessHeap(), 0, (bufsize+1) * sizeof(TCHAR)); + if (!buf) + { + return -1; + }
- offset = 0; - for(i = 1; i < argc; i++) - { - int length = _tcslen(argv[i]); - _tcsncpy(&buf[offset], argv[i], length); - offset += length; - if (i + 1 < argc) + offset = 0; + for(i = 1; i < argc; i++) { - buf[offset] = _T(' '); + int length = _tcslen(argv[i]); + _tcsncpy(&buf[offset], argv[i], length); + offset += length; + if (i + 1 < argc) + { + buf[offset] = _T(' '); + } + else + { + buf[offset] = _T('\n'); + buf[offset+1] = _T('\0'); + } + offset++; } - else - { - buf[offset] = _T('\n'); - buf[offset+1] = _T('\0'); - } - offset++; + OutputDebugString(buf); + HeapFree(GetProcessHeap(), 0, buf); } - OutputDebugString(buf); - HeapFree(GetProcessHeap(), 0, buf); return 0; }