Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
source code to manage the Windows Unix and Mac file formats.
[simgrid.git] / tools / tesh2 / include / fstream.h
1 /*\r
2  * include/fstream.h - type representing the file stream used to manage the tesh files.\r
3  *\r
4  * Copyright 2008,2009 Martin Quinson, Malek Cherier All right reserved. \r
5  *\r
6  * This program is free software; you can redistribute it and/or modify it \r
7  * under the terms of the license (GNU LGPL) which comes with this package.\r
8  *\r
9  * Purpose:\r
10  *              This file contains all the declarations of the functions related with\r
11  *              the tesh fstream type.\r
12  *\r
13  */\r
14 #ifndef __FSTREAM_H\r
15 #define __FSTREAM_H\r
16 \r
17 #include <com.h>\r
18 \r
19 #ifdef __cplusplus\r
20 extern "C" {\r
21 #endif\r
22 \r
23 /*! \brief fstream_new - create a new fstream.\r
24  *\r
25  * \param directory     The directory of the tesh file.\r
26  * \param name          The name of the tesh file.\r
27  *\r
28  * \return                      If successful the function returns the newly created\r
29  *                                      unit. Otherwise the function returns NULL and sets the\r
30  *                                      global variable errno with the appropiate error code.\r
31  * remarks:\r
32  *                                      If the parameter directory is NULL, the parameter name\r
33  *                                      must be `stdin`.\r
34  *\r
35  * errors :\r
36  *                                      [EINVAL] if one of the parameters is invalid.\r
37  *                                      [ENOMEM] if the system has not enough space to allocate\r
38  *                                               the file stream.\r
39  */\r
40 fstream_t\r
41 fstream_new(const char* directory, const char* name);\r
42 \r
43 /*! \brief fstream_open - open a file stream object.\r
44  *\r
45  * \param fstream       The file stream to open.\r
46  *\r
47  * \return                      If successful the function returns the 0. Otherwise \r
48  *                                      the function returns -1 and sets the global variable \r
49  *                                      errno with the appropiate error code.\r
50  *\r
51  * errors :\r
52  *                                      [EINVAL] if the fstream parameter is invalid.\r
53  *                                      [EALREADY] if the file stream is already opened.\r
54  *                                      \r
55  *                                      This function may also fail and set errno for any of \r
56  *                                      the errors specified for the function fopen.                    \r
57  */\r
58 int\r
59 fstream_open(fstream_t fstream);\r
60 \r
61 /*! \brief fstream_close - close a file stream object.\r
62  *\r
63  * \param fstream       The file stream to close.\r
64  *\r
65  * \return                      If successful the function returns the 0. Otherwise \r
66  *                                      the function returns -1 and sets the global variable \r
67  *                                      errno with the appropiate error code.\r
68  *\r
69  * errors :\r
70  *                                      [EINVAL] if the fstream parameter is invalid.\r
71  *                                      [EBADF] if the stream is not opened.\r
72  *                                      \r
73  *                                      \r
74  *                                      This function may also fail and set errno for any of \r
75  *                                      the errors specified for the function fclose.                   \r
76  */\r
77 int\r
78 fstream_close(fstream_t fstream);\r
79 \r
80 /*! \brief fstream_free - destroy a file stream object.\r
81  *\r
82  * \param ptr           A pointer to the file stream object to destroy.\r
83  *\r
84  * \return                      If successful the function returns the 0. Otherwise \r
85  *                                      the function returns -1 and sets the global variable \r
86  *                                      errno with the appropiate error code.\r
87  *\r
88  * errors :\r
89  *                                      [EINVAL] if the fstream object pointed to by the parameter ptr is invalid.\r
90  *                                      \r
91  *                                      \r
92  *                                      This function may also fail and set errno for any of \r
93  *                                      the errors specified for the function fclose.\r
94  *\r
95  * remarks :\r
96  *                                      Il the file stream object is opened the function close it\r
97  *                                      before its destruction.                         \r
98  */\r
99 int\r
100 fstream_free(fstream_t* ptr);\r
101 \r
102 int\r
103 fstream_parse(fstream_t fstream, xbt_os_mutex_t mutex);\r
104 \r
105 void \r
106 fstream_lex_line(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char * filepos, char *line);\r
107 \r
108 void \r
109 fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char* filepos, char token, char *line);\r
110 \r
111 void\r
112 fstream_handle_include(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char* file_name, const char* description);\r
113 \r
114 void\r
115 fstream_handle_suite(fstream_t fstream, const char* description, const char* filepos);\r
116 \r
117 int\r
118 fstream_launch_command(fstream_t fstream, context_t context, xbt_os_mutex_t mutex);\r
119 \r
120 long fstream_getline(fstream_t fstream, char **buf, size_t *n);\r
121 \r
122 #ifdef __cplusplus\r
123 }\r
124 #endif\r
125 \r
126 \r
127 #endif /*! __FSTREAM_H */\r