11 * Declaration of the s_Stream structure,
12 * which represents a file stream.
15 typedef struct s_Stream
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;
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 */
52 * Buffer size used in the getline function.
54 #define DEFAULT_ALLOC_SIZE ((size_t)64)
57 * s_Stream struct connected functions.
61 * Create a new s_Stream struct and return
65 Stream_t Stream_new(void);
68 * Returns true if the current text line is blank.
70 bool Stream_lineIsBlank(Stream_t stream);
73 * Return true if the caracter is space or tab.
75 bool Stream_isBlankChar(char ch);
79 * Return E_SUCCESS if the file is valid.
80 * Otherwise the fuction returns E_INVALID_FILE.
82 errno_t Stream_isValidFile(const char* file_name);
86 * Return E_SUCCESS is the open file operation succeeded.
87 * Otherwise the functions returns E_OPEN_FILE_FAILED.
89 errno_t Stream_openFile(Stream_t ptr,const char* file_name);
92 * This function reads an entire line, storing
93 * the address of the buffer containing the text into
96 ssize_t Stream_getLine(Stream_t ptr);
99 * Return true if the current line is a comment.
100 * Otherwise the functions returns false.
102 bool Stream_lineIsComment(Stream_t stream);
104 /* Return true if the current line contains a invalide token.
105 * Otherwise, the function returns false.
107 bool Stream_lineContainsInvalidToken(Stream_t stream);
110 * Return true if the text line is a meta command.
111 * Otherwise, the functions returns false.
113 bool Stream_lineIsMetaCommand(Stream_t stream);
115 /* Retun true if the text line contains a unknown meta command.
116 * Otherwise the function returns false.
118 bool Stream_lineIsUnknwnMetaCommand(Stream_t stream);
121 * Returns true if the timeout value is invalid.
122 * Otherwise the function returns false.
124 bool Stream_isInvalidTimeout(Stream_t stream);
127 * Returns true if the expected code value is invalid.
128 * Otherwise the function returns false.
130 bool Stream_isInvalidExpectedCode(Stream_t stream);
133 * Returns true if the export is invalid.
134 * Otherwise the function returns false.
136 bool Stream_isInvalidExport(Stream_t stream);
139 * Returns true if the unset is invalid.
140 * Otherwise the function returns false.
142 bool Stream_isInvalidUnset(Stream_t stream);
145 * Return true if the stream line contains a
146 * expected child output. Otherwhise the function
149 bool Stream_lineIsExpectedChildOutput(Stream_t stream);
152 * Return true if the stream line contains a
153 * child input. Otherwhise the function
156 bool Stream_lineIsChildInput(Stream_t stream);
159 * Return true, if the stream line containts a
160 * synchrone test case. otherwise the function
163 bool Stream_lineIsSyncTestCase(Stream_t stream);
165 bool Stream_lineIsAsyncTestCase(Stream_t stream);
168 * Return true if the text line contains a invalid
169 * meta command. Otherwise the function returns false.
171 bool Stream_lineIsInvalidMetaCommand(Stream_t stream);
174 * Print the file line.
176 void Stream_printLine(Stream_t stream,line_type_t line_type);
178 void Stream_lock(Stream_t ptr);
179 void Stream_unlock(Stream_t ptr);
181 bool Stream_lineIsChangeDir(Stream_t stream);
183 extern CRITICAL_SECTION cs;
189 void Stream_free(Stream_t ptr);
192 #endif /* #ifndef __STREAM_H__ */