2 * TYPE.C - type internal command.
6 * 07/08/1998 (John P. Price)
10 * Changed error messages
12 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
13 * added config.h include
15 * 07-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
16 * Added support for quoted arguments (type "test file.dat").
19 * 19-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
20 * Unicode and redirection ready!
22 * 19-Jan-1999 (Paolo Pantaleo <paolopan@freemail.it>)
23 * Added multiple file support (copied from y.c)
25 * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
26 * Remove all hardcode string to En.rc
32 #ifdef INCLUDE_CMD_TYPE
35 INT
cmd_type (LPTSTR cmd
, LPTSTR param
)
37 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
39 HANDLE hFile
, hConsoleOut
;
45 BOOL bFirstTime
= TRUE
;
47 hConsoleOut
=GetStdHandle (STD_OUTPUT_HANDLE
);
49 if (!_tcsncmp (param
, _T("/?"), 2))
51 ConOutResPaging(TRUE
,STRING_TYPE_HELP1
);
57 error_req_param_missing ();
61 argv
= split (param
, &argc
, TRUE
);
63 for(i
= 0; i
< argc
; i
++)
65 if(*argv
[i
] == _T('/') && _tcslen(argv
[i
]) >= 2 && _totupper(argv
[i
][1]) == _T('P'))
71 for (i
= 0; i
< argc
; i
++)
73 if (_T('/') == argv
[i
][0] && _totupper(argv
[i
][1]) != _T('P'))
75 LoadString(CMD_ModuleHandle
, STRING_TYPE_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
76 ConErrPrintf(szMsg
, argv
[i
] + 1);
82 hFile
= CreateFile(argv
[i
],
86 FILE_ATTRIBUTE_NORMAL
,NULL
);
88 if(hFile
== INVALID_HANDLE_VALUE
)
90 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
|
91 FORMAT_MESSAGE_IGNORE_INSERTS
|
92 FORMAT_MESSAGE_FROM_SYSTEM
,
95 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
99 ConErrPrintf (_T("%s - %s"), argv
[i
], errmsg
);
107 bRet
= FileGetString (hFile
, buff
, sizeof(buff
) / sizeof(TCHAR
));
112 if (ConOutPrintfPaging(bFirstTime
, buff
) == 1)