Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix format.
[simgrid.git] / win32_test_app / include / TStream.h
1 #ifndef __Stream_H__
2 #define __STREAM_H__
3
4 #include <TTime.h>
5 #include <TErrno.h>
6 #include <ctype.h>
7 #include <windows.h>
8
9
10 /* 
11  * Declaration of the s_Stream structure,
12  * which represents a file stream.
13  */
14
15 typedef struct s_Stream {
16   FILE *file;                   /* the file stream.                                     */
17   char *line;                   /* the current text line                                */
18   size_t line_number;           /* line number in the testsuite file    */
19   CRITICAL_SECTION cs;          /* std output managment                 */
20 } s_Stream_t, *Stream_t;
21
22 /* Line type. */
23 typedef enum {
24   comment_line_type,            /* the text line is a comment                                                                                   */
25   invalid_token_line_type,      /* the text line contains a invalid token                                                               */
26   unknwn_meta_command_line_type,        /* the text line contains a unknown macro command                                               */
27   invalid_timeout_value_line_type,      /* the text line contains a invalid timeout value                                               */
28   timeout_value_line_type,      /* the text line contains a valid timeout value                                                 */
29   invalid_exit_code_line_type,  /* the text line contains a invalid exit code value                                             */
30   exit_code_line_type,          /* the text line contains a valid exit code value                                               */
31   invalid_export_line_type,     /* the text line contains a invalid export meta command                                 */
32   export_line_type,             /* the text line contains a valid export meta command                                   */
33   invalid_unset_line_type,      /* the text line contains a invalid unset meta command                                  */
34   unset_line_type,              /* the text line contains a valid unset meta command                                    */
35   enable_output_checking_line_type,     /* the text line contains a enable output checking meta command                 */
36   disable_output_checking_line_type,    /* the text line contains a disable output checking meta command                */
37   enable_post_output_checking_line_type,        /* the text line contains a enable post output checking meta command    */
38   disable_post_output_checking_line_type,       /* the text line contains a disable post output checking meta command   */
39   export_failed_line_type,      /* the text line contains a export meta command which failed                    */
40   unset_failed_line_type,       /* the text line contains a unset meta command which failed                             */
41   create_console_line_type,     /* the text line contains a create console meta command                 */
42   create_no_console_line_type,  /* the text line contains a create no console meta command              */
43   enable_exit_code_checking_line_type,  /* the text line contains a enable exit code checking                   */
44   disable_exit_code_checking_line_type, /* the text line contains a disable exit code checking                  */
45   change_directory_line_type,   /* the text line contains a change directory command                   */
46   command_line_line_type        /* the text line contains a command line                                */
47 } line_type_t;
48
49 /* 
50  * Buffer size used in the getline function. 
51  */
52 #define DEFAULT_ALLOC_SIZE      ((size_t)64)
53
54 /* 
55  * s_Stream struct connected functions.
56  */
57
58 /*
59  * Create a new s_Stream struct and return
60  * a pointer to self
61  */
62
63 Stream_t Stream_new(void);
64
65 /*
66  * Returns true if the current text line is blank.
67  */
68 bool Stream_lineIsBlank(Stream_t stream);
69
70 /*
71  * Return true if the caracter is space or tab.
72  */
73 bool Stream_isBlankChar(char ch);
74
75
76 /*
77  * Return E_SUCCESS if the file is valid. 
78  * Otherwise the fuction returns E_INVALID_FILE.
79  */
80 errno_t Stream_isValidFile(const char *file_name);
81
82
83 /* 
84  * Return E_SUCCESS is the open file operation succeeded.
85  * Otherwise the functions returns E_OPEN_FILE_FAILED.
86  */
87 errno_t Stream_openFile(Stream_t ptr, const char *file_name);
88
89 /*
90  * This function reads an entire line, storing 
91  * the address of the buffer containing the  text into  
92  * *dest. 
93  */
94 ssize_t Stream_getLine(Stream_t ptr);
95
96 /*
97  * Return true if the current line is a comment.
98  * Otherwise the functions returns false.
99  */
100 bool Stream_lineIsComment(Stream_t stream);
101
102 /* Return true if the current line contains a invalide token.
103  * Otherwise, the function returns false.
104  */
105 bool Stream_lineContainsInvalidToken(Stream_t stream);
106
107 /*
108  * Return true if the text line is a meta command.
109  * Otherwise, the functions returns false.
110  */
111 bool Stream_lineIsMetaCommand(Stream_t stream);
112
113 /* Retun true if the text line contains a unknown meta command.
114  * Otherwise the function returns false.
115  */
116 bool Stream_lineIsUnknwnMetaCommand(Stream_t stream);
117
118 /*
119  * Returns true if the timeout value is invalid.
120  * Otherwise the function returns false.
121  */
122 bool Stream_isInvalidTimeout(Stream_t stream);
123
124 /*
125  * Returns true if the expected code value is invalid.
126  * Otherwise the function returns false.
127  */
128 bool Stream_isInvalidExpectedCode(Stream_t stream);
129
130 /*
131  * Returns true if the export is invalid.
132  * Otherwise the function returns false.
133  */
134 bool Stream_isInvalidExport(Stream_t stream);
135
136 /*
137  * Returns true if the unset is invalid.
138  * Otherwise the function returns false.
139  */
140 bool Stream_isInvalidUnset(Stream_t stream);
141
142 /* 
143  * Return true if the stream line contains a 
144  * expected child output. Otherwhise the function
145  * returns false.
146  */
147 bool Stream_lineIsExpectedChildOutput(Stream_t stream);
148
149 /* 
150  * Return true if the stream line contains a 
151  * child input. Otherwhise the function
152  * returns false.
153  */
154 bool Stream_lineIsChildInput(Stream_t stream);
155
156 /*
157  * Return true, if the stream line containts a
158  * synchrone test case. otherwise the function
159  * returns false.
160  */
161 bool Stream_lineIsSyncTestCase(Stream_t stream);
162
163 bool Stream_lineIsAsyncTestCase(Stream_t stream);
164
165 /*
166  * Return true if the text line contains a invalid 
167  * meta command. Otherwise the function returns false.
168  */
169 bool Stream_lineIsInvalidMetaCommand(Stream_t stream);
170
171 /*
172  * Print the file line.
173  */
174 void Stream_printLine(Stream_t stream, line_type_t line_type);
175
176 void Stream_lock(Stream_t ptr);
177 void Stream_unlock(Stream_t ptr);
178
179 bool Stream_lineIsChangeDir(Stream_t stream);
180
181 extern CRITICAL_SECTION cs;
182
183 /* 
184  * Free a s_Stream.
185  */
186
187 void Stream_free(Stream_t ptr);
188
189
190 #endif                          /* #ifndef __STREAM_H__ */