#include <errno.h>
#include <windows.h>
#include <stdio.h>
Go to the source code of this file.
◆ BUFSIZE
◆ FILE_FLAG_FIRST_PIPE_INSTANCE
#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000 |
◆ PIPEREAD_NOPIPE
#define PIPEREAD_NOPIPE (-101) |
◆ PIPEREAD_VERSION
#define PIPEREAD_VERSION "0.3" |
◆ WIN32_LEAN_AND_MEAN
◆ fileClient()
Definition at line 156 of file piperead.cpp.
157{
161
165 return -1;
166 }
167
170 }
171
174}
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl setvbuf(_Inout_ FILE *_File, _Inout_updates_opt_z_(_Size) char *_Buf, _In_ int _Mode, _In_ size_t _Size)
const char * strerror(int err)
Referenced by main().
◆ main()
Definition at line 184 of file piperead.cpp.
185{
187 const char* pipe_name;
188 const char* clientMode;
190
191 pipe_name = "com_1";
194 case 3:
195 clientMode = *++
argv;
196 if (
strcmp(clientMode,
"-c") != 0) {
200 }
201
202 case 2:
204 if (
strcmp(pipe_name,
"-h") == 0) {
206 }
207 break;
208 default:
210 break;
211 }
215 }
216
217 if ( pipe_name[0] == '\\' ) {
218
220 } else {
222 }
223
224 if ( clientMode ) {
228 }
229 } else {
231 }
232
234}
int strcmp(const char *String1, const char *String2)
#define sprintf(buf, format,...)
static int fileClient(const char *path)
static int pipeServer(char *path)
static int pipeClient(char *path)
◆ pipeClient()
static int pipeClient |
( |
char * |
path | ) |
|
|
static |
Definition at line 77 of file piperead.cpp.
78{
85
87 while (1) {
90 0,
93 0,
95
96
98 break;
99
100
104 {
107 }
108 else
109 {
112 }
113 break;
114 }
115
116
118 fprintf(
stderr,
"Could not open pipe: 20 second wait timed out.");
120 break;
121 }
122 }
123
126 chBuf,
128 &cbRead,
130
131 if ( ! fSuccess ) {
135 } else {
138 break;
139 }
140 }
141
143 } while ( fSuccess);
144
145 if ( ! fSuccess) {
147 }
148
151
153
154}
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
#define ERROR_FILE_NOT_FOUND
DWORD WINAPI GetLastError(void)
Referenced by main().
◆ pipeServer()
static int pipeServer |
( |
char * |
path | ) |
|
|
static |
Definition at line 31 of file piperead.cpp.
32{
34
37 return 1;
38 }
39
40 for(;;) {
43
46
51
53
57 return 1;
58 }
59 } else {
62 break;
63 }
64 }
65
68 }
69
72
73 return 0;
74}
#define FILE_FLAG_FIRST_PIPE_INSTANCE
static void print_error(DWORD win32_error)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
#define PIPE_ACCESS_DUPLEX
#define ERROR_BROKEN_PIPE
#define ERROR_PIPE_LISTENING
Referenced by main().
◆ print_error()
◆ usage()