Logo AND Algorithmique Numérique Distribuée

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