* PROGRAMMERS:
*/
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#include <tchar.h>
+#define WIN32_NO_STATUS
#include <stdarg.h>
-#include <string.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <winnls.h>
+#include <wincon.h>
+#define _INC_WINDOWS
+#include <ws2tcpip.h>
#include <stdio.h>
+#include <stdlib.h>
+
#include "resource.h"
#define NDEBUG
va_list valist;
WCHAR Buf[1024];
+ CHAR AnsiBuf[1024];
LPWSTR pBuf = Buf;
+ PCHAR pAnsiBuf = AnsiBuf;
LPWSTR Format;
DWORD written;
UINT DataLength;
+ int AnsiLength;
va_start(valist, uID);
return;
}
- WriteConsole(hStdOutput, pBuf, DataLength, &written, NULL);
+ if(GetFileType(hStdOutput) == FILE_TYPE_CHAR)
+ {
+ /* Is a console or a printer */
+ WriteConsole(hStdOutput, pBuf, DataLength, &written, NULL);
+ }
+ else
+ {
+ /* Is a pipe, socket, file or other */
+ AnsiLength = WideCharToMultiByte(CP_ACP, 0, pBuf, DataLength,\
+ NULL, 0, NULL, NULL);
+
+ if(AnsiLength >= sizeof(AnsiBuf))
+ pAnsiBuf = (PCHAR)HeapAlloc(GetProcessHeap(), 0, AnsiLength);
+
+ AnsiLength = WideCharToMultiByte(CP_OEMCP, 0, pBuf, DataLength,\
+ pAnsiBuf, AnsiLength, " ", NULL);
+
+ WriteFile(hStdOutput, pAnsiBuf, AnsiLength, &written, NULL);
+
+ if(pAnsiBuf != AnsiBuf)
+ HeapFree(NULL, 0, pAnsiBuf);
+ }
if(pBuf != Buf)
LocalFree(pBuf);
FormatOutput(IDS_MIN_MAX_AVERAGE, MinTime, MaxTime, AvgTime);
}
}
+ else
+ {
+ return 1;
+ }
return 0;
}