ctdb-common: Be more careful with packet sizes
[vlendec/samba-autobuild/.git] / ctdb / common / event_script.h
1 /*
2    Low level event script handling
3
4    Copyright (C) Amitay Isaacs  2017
5    Copyright (C) Martin Schwenke  2018
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __CTDB_SCRIPT_H__
22 #define __CTDB_SCRIPT_H__
23
24 #include "replace.h"
25 #include "system/filesys.h"
26
27 #include <talloc.h>
28
29 /**
30  * @file script.h
31  *
32  * @brief Script listing and manipulation
33  */
34
35
36 struct event_script {
37         char *name;
38         char *path;
39         bool enabled;
40 };
41
42 struct event_script_list {
43         unsigned int num_scripts;
44         struct event_script **script;
45 };
46
47
48 /**
49  * @brief Retrieve a list of scripts
50  *
51  * @param[in] mem_ctx Talloc memory context
52  * @param[in] script_dir Directory containing scripts
53  * @param[out] out List of scripts
54  * @return 0 on success, errno on failure
55  */
56 int event_script_get_list(TALLOC_CTX *mem_ctx,
57                           const char *script_dir,
58                           struct event_script_list **out);
59
60 /**
61  * @brief Make a script executable or not executable
62  *
63  * @param[in] script_dir Directory containing script
64  * @param[in] script_name Name of the script to enable
65  * @param[in] executable True if script should be made executable
66  * @return 0 on success, errno on failure
67  */
68 int event_script_chmod(const char *script_dir,
69                        const char *script_name,
70                        bool executable);
71
72 #endif /* __CTDB_SCRIPT_H__ */