]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/tools/arguments.h
arguments: move to tools/ subdirectory
[mirror_lxc.git] / src / lxc / tools / arguments.h
1 /*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2008
5 *
6 * Authors:
7 * Daniel Lezcano <daniel.lezcano at free.fr>
8 * Michel Normand <normand at fr.ibm.com>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #ifndef __LXC_ARGUMENTS_H
26 #define __LXC_ARGUMENTS_H
27
28 #include <getopt.h>
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include <sys/types.h>
32
33 struct lxc_arguments;
34
35 typedef int (*lxc_arguments_parser_t)(struct lxc_arguments *, int, char *);
36 typedef int (*lxc_arguments_checker_t)(const struct lxc_arguments *);
37
38 struct lxc_arguments {
39 const char *help;
40 void (*helpfn)(const struct lxc_arguments *);
41 const char *progname;
42 const struct option *options;
43 lxc_arguments_parser_t parser;
44 lxc_arguments_checker_t checker;
45
46 const char *name;
47 char *log_file;
48 char *log_priority;
49 int quiet;
50 int daemonize;
51 const char *rcfile;
52 const char *console;
53 const char *console_log;
54 const char *pidfile;
55 const char **lxcpath;
56 int lxcpath_cnt;
57 /* set to 0 to accept only 1 lxcpath, -1 for unlimited */
58 int lxcpath_additional;
59
60 /* for lxc-start */
61 const char *share_ns[32]; /* size must be greater than LXC_NS_MAX */
62
63 /* for lxc-console */
64 unsigned int ttynum;
65 char escape;
66
67 /* for lxc-wait */
68 char *states;
69 long timeout;
70
71 /* for lxc-autostart */
72 int shutdown;
73
74 /* for lxc-stop */
75 int hardstop;
76 int nokill;
77 int nolock;
78 int nowait;
79 int reboot;
80
81 /* for lxc-destroy */
82 int force;
83
84 /* close fds from parent? */
85 int close_all_fds;
86
87 /* lxc-create */
88 char *bdevtype, *configfile, *template;
89 char *fstype;
90 uint64_t fssize;
91 char *lvname, *vgname, *thinpool;
92 char *rbdname, *rbdpool;
93 char *zfsroot, *lowerdir, *dir;
94
95 /* lxc-execute */
96 uid_t uid;
97 gid_t gid;
98
99 /* auto-start */
100 int all;
101 int ignore_auto;
102 int list;
103 char *groups; /* also used by lxc-ls */
104
105 /* lxc-snapshot and lxc-copy */
106 enum task {
107 CLONE,
108 DESTROY,
109 LIST,
110 RESTORE,
111 SNAP,
112 RENAME,
113 } task;
114 int print_comments;
115 char *commentfile;
116 char *newname;
117 char *newpath;
118 char *snapname;
119 int keepdata;
120 int keepname;
121 int keepmac;
122
123 /* lxc-ls */
124 char *ls_fancy_format;
125 char *ls_filter;
126 unsigned int ls_nesting; /* maximum allowed nesting level */
127 bool ls_active;
128 bool ls_fancy;
129 bool ls_frozen;
130 bool ls_line;
131 bool ls_running;
132 bool ls_stopped;
133 bool ls_defined;
134
135 /* lxc-copy */
136 bool tmpfs;
137
138 /* remaining arguments */
139 char *const *argv;
140 int argc;
141
142 /* private arguments */
143 void *data;
144 };
145
146 #define LXC_COMMON_OPTIONS \
147 { "name", required_argument, 0, 'n' }, \
148 { "help", no_argument, 0, 'h' }, \
149 { "usage", no_argument, 0, OPT_USAGE }, \
150 { "version", no_argument, 0, OPT_VERSION }, \
151 { "quiet", no_argument, 0, 'q' }, \
152 { "logfile", required_argument, 0, 'o' }, \
153 { "logpriority", required_argument, 0, 'l' }, \
154 { "lxcpath", required_argument, 0, 'P' }, \
155 { "rcfile", required_argument, 0, OPT_RCFILE }, \
156 { 0, 0, 0, 0 }
157
158 /* option keys for long only options */
159 #define OPT_USAGE 0x1000
160 #define OPT_VERSION OPT_USAGE - 1
161 #define OPT_RCFILE OPT_USAGE - 2
162
163 extern int lxc_arguments_parse(struct lxc_arguments *args, int argc,
164 char *const argv[]);
165
166 extern int lxc_arguments_str_to_int(struct lxc_arguments *args,
167 const char *str);
168
169 #define lxc_error(arg, fmt, args...) \
170 if (!(arg)->quiet) \
171 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ##args)
172
173 #endif /* __LXC_ARGUMENTS_H */