2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <dlezcano at fr.ibm.com>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 typedef int (*lxc_arguments_parser_t
) (struct lxc_arguments
*, int, char*);
32 typedef int (*lxc_arguments_checker_t
) (const struct lxc_arguments
*);
34 struct lxc_arguments
{
37 const struct option
* options
;
38 lxc_arguments_parser_t parser
;
39 lxc_arguments_checker_t checker
;
49 /* for lxc-checkpoint/restart */
50 const char *statefile
;
61 /* remaining arguments */
65 /* private arguments */
69 #define LXC_COMMON_OPTIONS \
70 {"name", required_argument, 0, 'n'}, \
71 {"help", no_argument, 0, 'h'}, \
72 {"usage", no_argument, 0, OPT_USAGE}, \
73 {"quiet", no_argument, 0, 'q'}, \
74 {"logfile", required_argument, 0, 'o'}, \
75 {"logpriority", required_argument, 0, 'l'}, \
78 /* option keys for long only options */
79 #define OPT_USAGE 0x1000
81 extern int lxc_arguments_parse(struct lxc_arguments
*args
,
82 int argc
, char *const argv
[]);
84 extern int lxc_arguments_str_to_int(struct lxc_arguments
*args
, const char *str
);
86 extern const char *lxc_strerror(int errnum
);
88 #define lxc_error(arg, fmt, args...) if (!(arg)->quiet) \
89 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ## args)