ReactOS  0.4.13-dev-259-g5ca9c9c
dbgprint.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <tchar.h>
#include <stdio.h>
Include dependency graph for dbgprint.c:

Go to the source code of this file.

Functions

int _tmain (int argc, TCHAR **argv)
 

Function Documentation

◆ _tmain()

int _tmain ( int  argc,
TCHAR **  argv 
)

Definition at line 17 of file dbgprint.c.

18 {
19  TCHAR * buf;
20  size_t bufsize;
21  int i;
22  size_t offset;
23 
24  bufsize = 0;
25  for(i = 1; i < argc; i++)
26  {
27  bufsize += _tcslen(argv[i]) + 1;
28  }
29 
30  if (!bufsize)
31  {
32  return -1;
33  }
34 
35  if (_tcsstr(argv[1], "--winetest") && (argc == 3))
36  {
37  char psBuffer[128];
38  char psBuffer2[128];
39  char *nlptr2;
40  char cmd[255];
41  char test[300];
42  FILE *pPipe;
43  FILE *pPipe2;
44 
45  /* get available tests */
46  strcpy(cmd, argv[2]);
47  strcat(cmd, " --list");
48  pPipe = _tpopen(cmd, "r");
49  if (pPipe != NULL)
50  {
51  while(fgets(psBuffer, 128, pPipe))
52  {
53  if (psBuffer[0] == ' ')
54  {
55  strcpy(cmd, argv[2]);
56  strcat(cmd, " ");
57  strcat(cmd, psBuffer+4);
58  /* run the current test */
59  strcpy(test, "\n\nRunning ");
60  strcat(test, cmd);
62  pPipe2 = _popen(cmd, "r");
63  if (pPipe2 != NULL)
64  {
65  while(fgets(psBuffer2, 128, pPipe2))
66  {
67  nlptr2 = strchr(psBuffer2, '\n');
68  if (nlptr2)
69  *nlptr2 = '\0';
70  puts(psBuffer2);
71  if (nlptr2)
72  *nlptr2 = '\n';
73  OutputDebugStringA(psBuffer2);
74  }
75  _pclose(pPipe2);
76  }
77  }
78  }
79  _pclose(pPipe);
80  }
81  }
82  else if (_tcsstr(argv[1], "--process") && (argc == 3))
83  {
84  char psBuffer[128];
85  FILE *pPipe;
86 
87  pPipe = _tpopen(argv[2], "r");
88  if (pPipe != NULL)
89  {
90  while(fgets(psBuffer, 128, pPipe))
91  {
92  puts(psBuffer);
93  OutputDebugStringA(psBuffer);
94  }
95  _pclose(pPipe);
96  }
97  }
98  else
99  {
100  buf = HeapAlloc(GetProcessHeap(), 0, (bufsize+1) * sizeof(TCHAR));
101  if (!buf)
102  {
103  return -1;
104  }
105 
106  offset = 0;
107  for(i = 1; i < argc; i++)
108  {
109  size_t length = _tcslen(argv[i]);
110  _tcsncpy(&buf[offset], argv[i], length);
111  offset += length;
112  if (i + 1 < argc)
113  {
114  buf[offset] = _T(' ');
115  }
116  else
117  {
118  buf[offset] = _T('\n');
119  buf[offset+1] = _T('\0');
120  }
121  offset++;
122  }
123  _putts(buf);
125  HeapFree(GetProcessHeap(), 0, buf);
126  }
127  return 0;
128 }
static int argc
Definition: ServiceArgs.c:12
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: ftp_var.h:139
_TCHAR * _tcsncpy(_TCHAR *dst, const _TCHAR *src, size_t n)
Definition: tcsncpy.h:9
_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE *_File)
GLintptr offset
Definition: glext.h:5920
_Check_return_ _CRTIMP FILE *__cdecl _popen(_In_z_ const char *_Command, _In_z_ const char *_Mode)
#define test
Definition: rosglue.h:37
#define OutputDebugString
Definition: winbase.h:3704
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
#define argv
Definition: mplay32.c:18
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
#define _tcsstr
Definition: xmlstorage.h:199
#define _putts
Definition: tchar.h:587
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
int puts(const char *string)
Definition: crtsupp.c:23
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
FILE * _tpopen(const _TCHAR *cm, const _TCHAR *md)
Definition: popen.c:38
char * strchr(const char *String, int ch)
Definition: utclib.c:501
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18
#define HeapFree(x, y, z)
Definition: compat.h:394