11 * Declaration of the s_Stream structure,
12 * which represents a file stream.
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;
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 */
50 * Buffer size used in the getline function.
52 #define DEFAULT_ALLOC_SIZE ((size_t)64)
55 * s_Stream struct connected functions.
59 * Create a new s_Stream struct and return
63 Stream_t Stream_new(void);
66 * Returns true if the current text line is blank.
68 bool Stream_lineIsBlank(Stream_t stream);
71 * Return true if the caracter is space or tab.
73 bool Stream_isBlankChar(char ch);
77 * Return E_SUCCESS if the file is valid.
78 * Otherwise the fuction returns E_INVALID_FILE.
80 errno_t Stream_isValidFile(const char *file_name);
84 * Return E_SUCCESS is the open file operation succeeded.
85 * Otherwise the functions returns E_OPEN_FILE_FAILED.
87 errno_t Stream_openFile(Stream_t ptr, const char *file_name);
90 * This function reads an entire line, storing
91 * the address of the buffer containing the text into
94 ssize_t Stream_getLine(Stream_t ptr);
97 * Return true if the current line is a comment.
98 * Otherwise the functions returns false.
100 bool Stream_lineIsComment(Stream_t stream);
102 /* Return true if the current line contains a invalide token.
103 * Otherwise, the function returns false.
105 bool Stream_lineContainsInvalidToken(Stream_t stream);
108 * Return true if the text line is a meta command.
109 * Otherwise, the functions returns false.
111 bool Stream_lineIsMetaCommand(Stream_t stream);
113 /* Retun true if the text line contains a unknown meta command.
114 * Otherwise the function returns false.
116 bool Stream_lineIsUnknwnMetaCommand(Stream_t stream);
119 * Returns true if the timeout value is invalid.
120 * Otherwise the function returns false.
122 bool Stream_isInvalidTimeout(Stream_t stream);
125 * Returns true if the expected code value is invalid.
126 * Otherwise the function returns false.
128 bool Stream_isInvalidExpectedCode(Stream_t stream);
131 * Returns true if the export is invalid.
132 * Otherwise the function returns false.
134 bool Stream_isInvalidExport(Stream_t stream);
137 * Returns true if the unset is invalid.
138 * Otherwise the function returns false.
140 bool Stream_isInvalidUnset(Stream_t stream);
143 * Return true if the stream line contains a
144 * expected child output. Otherwhise the function
147 bool Stream_lineIsExpectedChildOutput(Stream_t stream);
150 * Return true if the stream line contains a
151 * child input. Otherwhise the function
154 bool Stream_lineIsChildInput(Stream_t stream);
157 * Return true, if the stream line containts a
158 * synchrone test case. otherwise the function
161 bool Stream_lineIsSyncTestCase(Stream_t stream);
163 bool Stream_lineIsAsyncTestCase(Stream_t stream);
166 * Return true if the text line contains a invalid
167 * meta command. Otherwise the function returns false.
169 bool Stream_lineIsInvalidMetaCommand(Stream_t stream);
172 * Print the file line.
174 void Stream_printLine(Stream_t stream, line_type_t line_type);
176 void Stream_lock(Stream_t ptr);
177 void Stream_unlock(Stream_t ptr);
179 bool Stream_lineIsChangeDir(Stream_t stream);
181 extern CRITICAL_SECTION cs;
187 void Stream_free(Stream_t ptr);
190 #endif /* #ifndef __STREAM_H__ */