ReactOS 0.4.15-dev-8219-ge8b88cf
y.c File Reference
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
Include dependency graph for y.c:

Go to the source code of this file.

Macros

#define BUFF_SIZE   4096
 

Functions

static VOID ConErrPrintf (LPTSTR szFormat,...)
 
static VOID ConOutPuts (LPTSTR szText)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ BUFF_SIZE

#define BUFF_SIZE   4096

Definition at line 12 of file y.c.

Function Documentation

◆ ConErrPrintf()

static VOID ConErrPrintf ( LPTSTR  szFormat,
  ... 
)
static

Definition at line 19 of file y.c.

20{
21 DWORD dwWritten;
22 TCHAR szOut[BUFF_SIZE];
23 va_list arg_ptr;
24
25 va_start (arg_ptr, szFormat);
26 _vstprintf (szOut, szFormat, arg_ptr);
27 va_end (arg_ptr);
28
29 WriteFile (GetStdHandle (STD_ERROR_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL);
30}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define NULL
Definition: types.h:112
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _vstprintf
Definition: tchar.h:540
#define STD_ERROR_HANDLE
Definition: winbase.h:269
char TCHAR
Definition: xmlstorage.h:189
#define _tcslen
Definition: xmlstorage.h:198
#define BUFF_SIZE
Definition: y.c:12

◆ ConOutPuts()

static VOID ConOutPuts ( LPTSTR  szText)
static

Definition at line 34 of file y.c.

35{
36 DWORD dwWritten;
37
38 WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL);
39 WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL);
40}
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 43 of file y.c.

44{
45 INT i;
46 HANDLE hFind;
47 HANDLE hConsoleIn, hConsoleOut, hFile;
48 char buff[BUFF_SIZE];
49 DWORD dwRead,dwWritten;
50 BOOL bRet;
51 WIN32_FIND_DATA FindData;
52
53 hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
54 hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
55
56 if (argc == 2 && _tcsncmp (argv[1], _T("/?"), 2) == 0)
57 {
58 ConOutPuts(_T("copy stdin to stdout and then files to stdout\n"
59 "\n"
60 "Y [files]\n"
61 "\n"
62 "files files to copy to stdout"));
63 return 0;
64 }
65
66 /*stdin to stdout*/
67 do
68 {
69 bRet = ReadFile(hConsoleIn,buff,sizeof(buff),&dwRead,NULL);
70
71 if (dwRead>0 && bRet)
72 WriteFile(hConsoleOut,buff,dwRead,&dwWritten,NULL);
73
74 } while(dwRead>0 && bRet);
75
76
77 /*files to stdout*/
78 Sleep(0);
79
80 for (i = 1; i < argc; i++)
81 {
82 hFind=FindFirstFile(argv[i],&FindData);
83
84 if (hFind==INVALID_HANDLE_VALUE)
85 {
86 ConErrPrintf("File not found - %s\n",argv[i]);
87 continue;
88 }
89
90 do
91 {
92 hFile = CreateFile(FindData.cFileName,
97
99 {
100 ConErrPrintf("File not found - %s\n",FindData.cFileName);
101 continue;
102 }
103
104 do
105 {
106 bRet = ReadFile(hFile,buff,sizeof(buff),&dwRead,NULL);
107
108 if (dwRead>0 && bRet)
109 WriteFile(hConsoleOut,buff,dwRead,&dwWritten,NULL);
110
111 } while(dwRead>0 && bRet);
112
114
115 }
116 while(FindNextFile(hFind,&FindData));
117
118 FindClose(hFind);
119 }
120
121 return 0;
122}
static int argc
Definition: ServiceArgs.c:12
#define ConErrPrintf(szStr,...)
Definition: console.h:44
#define ConOutPuts(szStr)
Definition: console.h:29
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
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
#define _tcsncmp
Definition: tchar.h:1428
#define argv
Definition: mplay32.c:18
_In_ HANDLE hFile
Definition: mswsock.h:90
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
#define STD_INPUT_HANDLE
Definition: winbase.h:267
#define FindNextFile
Definition: winbase.h:3788
#define FindFirstFile
Definition: winbase.h:3782
#define CreateFile
Definition: winbase.h:3749