lib:cmdline: Parse cmdline options with popt
[kseeger/samba-autobuild/.git] / lib / cmdline / cmdline_private.h
1 /*
2  * Copyright (c) 2020      Andreas Schneider <asn@samba.org>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef _CMDLINE_PRIVATE_H
19 #define _CMDLINE_PRIVATE_H
20
21 #include "lib/cmdline/cmdline.h"
22
23 enum {
24         OPT_OPTION = 0x1000000,
25         OPT_NETBIOS_SCOPE,
26         OPT_LEAK_REPORT,
27         OPT_LEAK_REPORT_FULL,
28         OPT_DEBUG_STDOUT,
29         OPT_CONFIGFILE,
30         OPT_SIMPLE_BIND_DN,
31         OPT_PASSWORD,
32         OPT_NT_HASH,
33         OPT_USE_KERBEROS,
34         OPT_USE_KERBEROS_CCACHE,
35         OPT_USE_WINBIND_CCACHE,
36         OPT_CLIENT_PROTECTION,
37 };
38
39 typedef bool (*samba_cmdline_load_config)(void);
40
41 /**
42  * @internal
43  *
44  * @brief Initialize the commandline interface for parsing options.
45  *
46  * This the common function to initialize the command line interface. This
47  * initializes:
48  *
49  *   - Crash setup
50  *   - logging system sening logs to stdout
51  *   - talloc leak reporting
52  *
53  * @param[in]  mem_ctx  The talloc memory context to use for allocating memory.
54  *                      This should be a long living context till the client
55  *                      exits.
56  *
57  * @return true on success, false if an error occured.
58  */
59 bool samba_cmdline_init_common(TALLOC_CTX *mem_ctx);
60
61 /**
62  * @brief Set the callback for loading the smb.conf file.
63  *
64  * This is needed as sourc3 and source4 have different code for loading the
65  * smb.conf file.
66  *
67  * @param[in]  fn  The callback to load the smb.conf file.
68  *
69  * @return true on success, false if an error occured.
70  */
71 bool samba_cmdline_set_load_config_fn(samba_cmdline_load_config fn);
72
73 /**
74  * @internal
75  *
76  * @brief Set the talloc context for the command line interface.
77  *
78  * This is stored as a static pointer.
79  *
80  * @param[in]  mem_ctx  The talloc memory context.
81  *
82  * @return true on success, false if an error occured.
83  */
84 bool samba_cmdline_set_talloc_ctx(TALLOC_CTX *mem_ctx);
85
86 /**
87  * @internal
88  *
89  * @brief Get the talloc context for the cmdline interface.
90  *
91  * @return A talloc context.
92  */
93 TALLOC_CTX *samba_cmdline_get_talloc_ctx(void);
94
95 /**
96  * @internal
97  *
98  * @brief Set the loadparm context for the command line interface.
99  *
100  * @param[in]  lp_ctx  The loadparm context to use.
101  *
102  * @return true on success, false if an error occured.
103  */
104 bool samba_cmdline_set_lp_ctx(struct loadparm_context *lp_ctx);
105
106 /**
107  * @internal
108  *
109  * @brief Set the client credentials for the commandline interface.
110  *
111  * @param[in]  creds   The client credentials to use.
112  *
113  * @return true on success, false if an error occured.
114  */
115 bool samba_cmdline_set_creds(struct cli_credentials *creds);
116
117 #endif /* _CMDLINE_PRIVATE_H */