aboutsummaryrefslogtreecommitdiffstats
path: root/lib/os_mon/c_src/nteventlog/elog_pipe_stdin.h
blob: b8f08bb4125b4702b7afffe97234348d9ea0f115 (plain) (blame)
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
/*
 * %CopyrightBegin%
 * 
 * Copyright Ericsson AB 1998-2016. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * %CopyrightEnd%
 */
#ifndef _ELOG_PIPE_STDIN_H
#define _ELOG_PIPE_STDIN_H
/*
 * Module: elog_pipe_stdin
 * Purpouse: Read data from stdin when stdin is a pipe
 * and deliver events only when data is really availabel or 
 * end of file is reached.
 * If we would wait on an ordinary pipe handle, we 
 * would return immediately as it's always "signaled".
 * some kind of asyncronous I/O in the win32 way is 
 * not possible as it's not supported on anonymous pipes
 * (besides we have not opened the file ourselves so we 
 *  cannot specify that we want async I/O...).
 * ToDo: The reading is inneficcient, the buffering 
 * goes on forever, which would be dangerous if to much 
 * data was passed into stdin. The handling of 
 * Console stdin should be transparent instead of
 * forcing the user of the module to check if this is a 
 * console for selecting between ReadFile and 
 * read_pipe_stdin.
 * The handling of the event object is somewhat strange 
 * because I want to know about EOF before I've read
 * to it.
 */

BOOL peek_pipe_stdin_eof(void);
/*
 * Returns TRUE if eof is reached, regardless of 
 * if there still is unread data in the buffer.
 * Should not be called if console_stdin() returns TRUE.
 * Resets the event object if it returns TRUE.
 */

int read_pipe_stdin(char *buff, int max);
/*
 * Reads from stdin, minimum 1 byte and
 * maximum max bytes into buff. If EOF
 * is reached and no bytes were read, 
 * the return value is 0.
 * Should not be called if console_stdin() returns TRUE.
 * The event object for stdin will get unsignaled if
 * end of file is not reached (if peek_pipe_stdin_eof()
 * would return false).
 */

BOOL setup_pipe_stdin(void);
/*
 * Initializes the module, returns TRUE if OK.
 * If stdin is a console, no thread is created
 * and the event objet returned by get_Stdin_event 
 * will be the console handle.
 * Check if stdin was a console with the console_stdin() 
 * function.
 */

BOOL console_stdin(void);
/*
 * Returns true if stdin was a console, in which case
 * normal Win32 console I/O functions have to
 * be used. 
 * get_stdin_event() will return the console handle,
 * which is signalled whenever an event reaches
 * the console window (like mouse events etc).
 */

HANDLE get_stdin_event(void);
/*
 * Returns a event handle that can be waited upon with
 * WaitForSingleObject and friends. It is possibly a console
 * handle, see console_stdin().
 */
#endif /* _ELOG_PIPE_STDIN_H */