Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics (kill unused var, and kill/improve debug outputs)
[simgrid.git] / tools / tesh2 / include / command.h
1 /*\r
2  * include/command.h - type representing a command.\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 command type.\r
12  *\r
13  */\r
14  \r
15 #ifndef __COMMAND_H\r
16 #define __COMMAND_H\r
17 \r
18 #include <com.h>\r
19 \r
20 #ifdef __cplusplus\r
21 extern "C" {\r
22 #endif\r
23 \r
24 /*! \brief command_new - create a new fstream.\r
25  *\r
26  * \param unit                  The unit contained the command.\r
27  * \param context               The context of the excecution of the command.\r
28  * \param mutex                 A mutex to synchronize the access of the properties of its unit.\r
29  *\r
30  * \return                              If successful the function returns the newly created\r
31  *                                              command. Otherwise the function returns NULL and sets the\r
32  *                                              global variable errno with the appropiate error code.\r
33  * remarks:\r
34  *                                              If the parameter directory is NULL, the parameter name\r
35  *                                              must be `stdin`.\r
36  *\r
37  * errors :\r
38  *                                              [EINVAL] if one of the parameters is invalid.\r
39  *                                              [ENOMEM] if the system has not enough space to allocate\r
40  *                                                               the command.\r
41  */\r
42 command_t\r
43 command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex);\r
44 \r
45 /*! \brief command_free - destroy a command object.\r
46  *\r
47  * \param ptr                   A pointer to the command object to destroy.\r
48  *\r
49  * \return                              If successful the function returns the 0. Otherwise \r
50  *                                              the function returns -1 and sets the global variable \r
51  *                                              errno with the appropiate error code.\r
52  *\r
53  * errors :\r
54  *                                              [EINVAL] if the command object pointed to by the ptr parameter is invalid.\r
55  *                                      \r
56  */\r
57 int\r
58 command_free(command_t* ptr);\r
59 \r
60 /*! \brief command_run - run a command object.\r
61  *\r
62  * \param command               The command to run.\r
63  *\r
64  * \return                              If successful the function returns the 0. Otherwise \r
65  *                                              the function returns -1 and sets the global variable \r
66  *                                              errno with the appropiate error code.\r
67  *\r
68  * errors :\r
69  *                                              [EINVAL] if the parameter is invalid.\r
70  *\r
71  * remarks :\r
72  *                                              The type of running (asynchonus or no) depend of the\r
73  *                                              context of the command.\r
74  *                                      \r
75  */\r
76 int\r
77 command_run(command_t command);\r
78 \r
79 /*! \brief command_exec - execute a command object.\r
80  *\r
81  * \param command               The command object to run.\r
82  * \param command_line  The command line of the process to create.                              \r
83  */\r
84 void\r
85 command_exec(command_t command, const char* command_line);\r
86 \r
87 /*! \brief command_wait - wait for the end of a command.\r
88  *\r
89  * \param command               The command object to wait for.         \r
90  */\r
91 void\r
92 command_wait(command_t command);\r
93 \r
94 /*! \brief command_interrupt - wait for the end of a command.\r
95  *\r
96  * \param command               The command object to interrupt.                \r
97  */\r
98 void\r
99 command_interrupt(command_t command);\r
100 \r
101 /*! \brief command_summarize - print the summary of the execution of a command.\r
102  *\r
103  * \param command               The command object to display the summary.      \r
104  *\r
105  * remark:\r
106  *                                              The summary of the command is displayed only if the user\r
107  *                                              specifies both summary and detail-summary options on the\r
108  *                                              tesh command line.\r
109  */\r
110 void\r
111 command_summarize(command_t command);\r
112 \r
113 /*! \brief command_handle_failure - handle a failure caused by a command.\r
114  *\r
115  * \param command               The command to handle the failure.      \r
116  *\r
117  * remark:\r
118  *                                              The behavior of the command failure handling depends\r
119  *                                              of the specification of the options keep-going and\r
120  *                                              keep-going-unit. If the user has specified the option\r
121  *                                              keep-going on the command line of tesh, only the unit \r
122  *                                              containing the failed command is interrupted and all \r
123  *                                              other units continue.\r
124  */\r
125 void\r
126 command_handle_failure(command_t command, cs_reason_t reason);\r
127 \r
128 void command_kill(command_t command);\r
129 \r
130 void\r
131 command_check(command_t command);\r
132 \r
133 #ifdef __cplusplus\r
134 }\r
135 #endif\r
136 \r
137 #endif /* !_COMMAND_H */\r