-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathheader.h
111 lines (91 loc) · 3.86 KB
/
header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#define _WIN32_WINNT 0x0502
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tlhelp32.h>
#define OP_IN_OUT_SHIFT (16) // out codes are 16 bits from in codes
#define OP_ANSI_IN (0x00000001)
#define OP_UNICODE_IN (0x00000002)
#define OP_ANSI_OUT (0x00010000)
#define OP_UNICODE_OUT (0x00020000)
#define OP_HEX_OUT (0x00040000)
// MTEE Operations
#define OP_ANSI_IN_ANSI_OUT (OP_ANSI_IN | OP_ANSI_OUT)
#define OP_ANSI_IN_UNICODE_OUT (OP_ANSI_IN | OP_UNICODE_OUT)
#define OP_UNICODE_IN_ANSI_OUT (OP_UNICODE_IN | OP_ANSI_OUT)
#define OP_UNICODE_IN_UNICODE_OUT (OP_UNICODE_IN | OP_UNICODE_OUT)
#define OP_ANSI_IN_HEX_OUT (OP_ANSI_IN | OP_HEX_OUT)
#define OP_UNICODE_IN_HEX_OUT (OP_UNICODE_IN | OP_HEX_OUT)
// defines for GetWinVer()
#define VER_PRE_NT4 (0L)
#define VER_NT4 (1L)
#define VER_2000 (2L)
#define VER_XP (3L)
#define VER_2003 (4L)
#define _MERGE_RDATA_
#if !defined (INVALID_SET_FILE_POINTER)
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
#endif
//#include <stdio.h>
#define CTRL_CLEAR_EVENT (0xFFFF)
#define MAX_CONSOLE_PID_LIST (128L)
//
// Stores details of the files to be written to
//
typedef struct _FILEINFO
{
HANDLE hFile; // handle of open file
PWCHAR lpFileName; // pointer to dynamically assigned wide buffer holding filename
BOOL bAppend; // if true, append I/O to file instead of overwrite
BOOL bIsConsole; // true if it is a console device
_FILEINFO *fiNext; // pointer to next FILEINFO structure
} FILEINFO, *PFILEINFO;
//
// Stores the commandline arguments/options
//
typedef struct _ARGS
{
BOOL bAddDate; // if true, prefix each newline with local date
BOOL bAddTime; // if true, prefix each newline with local time
BOOL bContinue; // if true, continue on I/O errors
BOOL bHelp; // if true, show helpscreen
BOOL bUnicode; // if true, output will be unicode (converted if required)
BOOL bFwdExitCode; // if true, exit with exit code of piped process
BOOL bAnsi; // if true, output will be ansi (converted if required)
BOOL bIntermediate; // if true, create intermediate directories if required
BOOL bElapsedTime; // if true, calculate and display elapsed time
FILEINFO fi; // first FILEINFO structure in linked list
DWORD dwBufSize; // max size of buffer for read operations
DWORD dwPeekTimeout; // max ms to peek for input
} ARGS, *LPARGS;
// args.cpp
BOOL CheckFileName(PWCHAR lpToken);
BOOL GetCommandLineTokenW(PWCHAR *tokenPtr); // process ANSI commandline args
BOOL ParseCommandlineW(LPARGS args);
LPWSTR StringAllocW(PWCHAR *dest, LPCWSTR src);
VOID FreeFileInfoStructs(PFILEINFO fi);
PFILEINFO CreateFileInfoStruct(PFILEINFO *fi);
//VOID MsgBox(LPCTSTR);
BOOL WINAPI HandlerRoutine(DWORD);
HWND GetConsoleHandle(VOID);
VOID ShowFileType(HANDLE);
int ShowHelp(VOID);
VOID ShowPipeInfo(HANDLE h);
VOID ConfigStdIn(HANDLE h);
PWSTR CreateFullPathW(PWSTR szPath);
//DWORD GetWinVer(VOID);
DWORD GetFormattedDateTimeA(PCHAR lpBuf, BOOL bDate, BOOL bTime);
DWORD GetFormattedDateTimeW(PWCHAR lpBuf, BOOL bDate, BOOL bTime);
BOOL IsAnOutputConsoleDevice(HANDLE h);
DWORD GetParentProcessId(VOID);
HANDLE GetPipedProcessHandle(VOID);
int FormatElapsedTime( LARGE_INTEGER* elapsedTime, PCHAR outBuf,
const int outBufSize );
// perr.cpp
DWORD Perror(DWORD dwErrNum);
VOID Verbose(LPCTSTR szMsg);
// output.cpp
BOOL WriteBufferToConsoleAndFilesA(LPARGS args, PCHAR lpBuf, DWORD dwCharsRead, BOOL AddDate, BOOL AddTime);
BOOL WriteBufferToConsoleAndFilesW(LPARGS args, PWCHAR lpBuf, DWORD dwCharsRead, BOOL AddDate, BOOL AddTime);
BOOL AnsiToUnicode(PWCHAR *lpDest, PCHAR lpSrc, LPDWORD lpSize);
BOOL UnicodeToAnsi(PCHAR *lpDest, PWCHAR lpSrc, LPDWORD lpSize);
BOOL WriteBom(PFILEINFO fi, BOOL bContinue);