2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
8 * Michel Normand <normand at fr.ibm.com>
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.
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.
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
24 #ifndef __LXC_ARGUMENTS_H
25 #define __LXC_ARGUMENTS_H
32 typedef int (*lxc_arguments_parser_t
) (struct lxc_arguments
*, int, char*);
33 typedef int (*lxc_arguments_checker_t
) (const struct lxc_arguments
*);
35 struct lxc_arguments
{
37 void(*helpfn
)(const struct lxc_arguments
*);
39 const struct option
* options
;
40 lxc_arguments_parser_t parser
;
41 lxc_arguments_checker_t checker
;
50 const char *console_log
;
54 /* set to 0 to accept only 1 lxcpath, -1 for unlimited */
55 int lxcpath_additional
;
58 const char *share_ns
[32]; // size must be greater than LXC_NS_MAX
68 /* for lxc-autostart */
81 /* close fds from parent? */
85 char *bdevtype
, *configfile
, *template;
88 char *lvname
, *vgname
, *thinpool
;
89 char *zfsroot
, *lowerdir
, *dir
;
97 /* remaining arguments */
101 /* private arguments */
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'}, \
116 /* option keys for long only options */
117 #define OPT_USAGE 0x1000
118 #define OPT_VERSION OPT_USAGE-1
120 extern int lxc_arguments_parse(struct lxc_arguments
*args
,
121 int argc
, char *const argv
[]);
123 extern int lxc_arguments_str_to_int(struct lxc_arguments
*args
, const char *str
);
125 extern const char *lxc_strerror(int errnum
);
127 #define lxc_error(arg, fmt, args...) if (!(arg)->quiet) \
128 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ## args)