Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

dbgprint.c

Go to the documentation of this file.
00001 /* $Id: dbgprint.c 24720 2006-11-11 16:07:35Z janderwald $
00002  *
00003  * PROJECT:         ReactOS DbgPrint Utility
00004  * LICENSE:         GPL - See COPYING in the top level directory
00005  * FILE:            tools/dbgprint/dbgprint.c
00006  * PURPOSE:         outputs a text via DbgPrint API
00007  * PROGRAMMERS:     Johannes Anderwald (johannes.anderwald@student.tugraz.at)
00008  *                  Christoph von Wittich (Christoph_vW@ReactOS.org)
00009  */
00010 
00011 #include <windows.h>
00012 #include <tchar.h>
00013 #include <debug.h>
00014 #include <stdio.h>
00015 
00016 int _tmain(int argc, TCHAR ** argv)
00017 {
00018     TCHAR * buf;
00019     int bufsize;
00020     int i;
00021     int offset;
00022 
00023     bufsize = 0;
00024     for(i = 1; i < argc; i++)
00025     {
00026         bufsize += _tcslen(argv[i]) + 1;
00027     }
00028 
00029     if (!bufsize)
00030     {
00031         return -1;
00032     }
00033 
00034     if (_tcsstr(argv[1], "--winetest") && (argc == 3))
00035     {
00036         char   psBuffer[128];
00037         char   psBuffer2[128];
00038         char   *nlptr2;
00039         char   cmd[255];
00040         char   test[300];
00041         FILE   *pPipe;
00042         FILE   *pPipe2;
00043 
00044         /* get available tests */
00045         pPipe = _tpopen(argv[2], "r");
00046         if (pPipe != NULL)
00047         {
00048             while(fgets(psBuffer, 128, pPipe))
00049             {
00050                 if (psBuffer[0] == ' ')
00051                 {
00052                     strcpy(cmd, argv[2]);
00053                     strcat(cmd, " ");
00054                     strcat(cmd, psBuffer+4);
00055                     /* run the current test */
00056                     strcpy(test, "\n\nRunning ");
00057                     strcat(test, cmd);
00058                     OutputDebugStringA(test);
00059                     pPipe2 = _popen(cmd, "r");
00060                     if (pPipe2 != NULL)
00061                     {
00062                         while(fgets(psBuffer2, 128, pPipe2))
00063                         {
00064                             nlptr2 = strchr(psBuffer2, '\n');
00065                             if (nlptr2)
00066                                 *nlptr2 = '\0';
00067                             puts(psBuffer2);
00068                             OutputDebugStringA(psBuffer2);
00069                         }
00070                         _pclose(pPipe2);
00071                     }
00072                 }
00073             }
00074             _pclose(pPipe);
00075         }
00076     }
00077     else if (_tcsstr(argv[1], "--process") && (argc == 3))
00078     {
00079         char   psBuffer[128];
00080         FILE   *pPipe;
00081 
00082         pPipe = _tpopen(argv[2], "r");
00083         if (pPipe != NULL)
00084         {
00085             while(fgets(psBuffer, 128, pPipe))
00086             {
00087                 puts(psBuffer);
00088                 OutputDebugStringA(psBuffer);
00089             }
00090             _pclose(pPipe);
00091         }
00092     }
00093     else
00094     {
00095         buf = HeapAlloc(GetProcessHeap(), 0, (bufsize+1) * sizeof(TCHAR));
00096         if (!buf)
00097         {
00098             return -1;
00099         }
00100 
00101         offset = 0;
00102         for(i = 1; i < argc; i++)
00103         {
00104             int length = _tcslen(argv[i]);
00105             _tcsncpy(&buf[offset], argv[i], length);
00106             offset += length;
00107             if (i + 1 < argc)
00108             {
00109                 buf[offset] = _T(' ');
00110             }
00111             else
00112             {
00113                 buf[offset] = _T('\n');
00114                 buf[offset+1] = _T('\0');
00115             }
00116             offset++;
00117         }
00118         _putts(buf);
00119         OutputDebugString(buf);
00120         HeapFree(GetProcessHeap(), 0, buf);
00121     }
00122     return 0;
00123 }

Generated on Thu Feb 9 04:38:59 2012 for ReactOS by doxygen 1.6.3

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.