]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/arguments.h
use same ifndef/define format for all headers
[mirror_lxc.git] / src / lxc / 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 #ifndef __LXC_ARGUMENTS_H
25 #define __LXC_ARGUMENTS_H
26
27 #include <getopt.h>
28 #include <stdint.h>
29
30 struct lxc_arguments;
31
32 typedef int (*lxc_arguments_parser_t) (struct lxc_arguments *, int, char*);
33 typedef int (*lxc_arguments_checker_t) (const struct lxc_arguments *);
34
35 struct lxc_arguments {
36 const char *help;
37 void(*helpfn)(const struct lxc_arguments *);
38 const char *progname;
39 const struct option* options;
40 lxc_arguments_parser_t parser;
41 lxc_arguments_checker_t checker;
42
43 const char *name;
44 char *log_file;
45 char *log_priority;
46 int quiet;
47 int daemonize;
48 const char *rcfile;
49 const char *console;
50 const char *console_log;
51 const char *pidfile;
52 const char **lxcpath;
53 int lxcpath_cnt;
54 /* set to 0 to accept only 1 lxcpath, -1 for unlimited */
55 int lxcpath_additional;
56
57 /* for lxc-start */
58 const char *share_ns[32]; // size must be greater than LXC_NS_MAX
59
60 /* for lxc-console */
61 int ttynum;
62 char escape;
63
64 /* for lxc-wait */
65 char *states;
66 long timeout;
67
68 /* for lxc-autostart */
69 int shutdown;
70
71 /* for lxc-stop */
72 int hardstop;
73 int nokill;
74 int nolock;
75 int nowait;
76 int reboot;
77
78 /* for lxc-destroy */
79 int force;
80
81 /* close fds from parent? */
82 int close_all_fds;
83
84 /* lxc-create */
85 char *bdevtype, *configfile, *template;
86 char *fstype;
87 uint64_t fssize;
88 char *lvname, *vgname, *thinpool;
89 char *zfsroot, *lowerdir, *dir;
90
91 /* auto-start */
92 int all;
93 int ignore_auto;
94 int list;
95 char *groups;
96
97 /* remaining arguments */
98 char *const *argv;
99 int argc;
100
101 /* private arguments */
102 void *data;
103 };
104
105 #define LXC_COMMON_OPTIONS \
106 {"name", required_argument, 0, 'n'}, \
107 {"help", no_argument, 0, 'h'}, \
108 {"usage", no_argument, 0, OPT_USAGE}, \
109 {"version", no_argument, 0, OPT_VERSION}, \
110 {"quiet", no_argument, 0, 'q'}, \
111 {"logfile", required_argument, 0, 'o'}, \
112 {"logpriority", required_argument, 0, 'l'}, \
113 {"lxcpath", required_argument, 0, 'P'}, \
114 {0, 0, 0, 0}
115
116 /* option keys for long only options */
117 #define OPT_USAGE 0x1000
118 #define OPT_VERSION OPT_USAGE-1
119
120 extern int lxc_arguments_parse(struct lxc_arguments *args,
121 int argc, char *const argv[]);
122
123 extern int lxc_arguments_str_to_int(struct lxc_arguments *args, const char *str);
124
125 extern const char *lxc_strerror(int errnum);
126
127 #define lxc_error(arg, fmt, args...) if (!(arg)->quiet) \
128 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ## args)
129
130 #endif