]>
Commit | Line | Data |
---|---|---|
cda02a28 MN |
1 | /* |
2 | * lxc: linux Container library | |
3 | * | |
4 | * (C) Copyright IBM Corp. 2007, 2008 | |
5 | * | |
6 | * Authors: | |
7 | * Daniel Lezcano <dlezcano at fr.ibm.com> | |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 | */ | |
24 | #ifndef __arguments_h | |
25 | #define __arguments_h | |
26 | ||
27 | #include <getopt.h> | |
28 | ||
29 | struct lxc_arguments; | |
30 | ||
31 | typedef int (*lxc_arguments_parser_t) (struct lxc_arguments *, int, char*); | |
32 | typedef int (*lxc_arguments_checker_t) (const struct lxc_arguments *); | |
33 | ||
34 | struct lxc_arguments { | |
35 | const char *help; | |
36 | const char *progname; | |
37 | const struct option* options; | |
38 | lxc_arguments_parser_t parser; | |
39 | lxc_arguments_checker_t checker; | |
40 | ||
41 | const char *name; | |
42 | char *log_file; | |
43 | char *log_priority; | |
44 | int quiet; | |
c36583c3 | 45 | int daemonize; |
cda02a28 | 46 | const char *rcfile; |
6b201d02 | 47 | const char *statefile; |
cda02a28 | 48 | |
41cfbac9 | 49 | /* for lxc-checkpoint */ |
3f739da8 DL |
50 | int kill; |
51 | int pause; | |
41cfbac9 MN |
52 | |
53 | /* for lxc-console */ | |
54 | int ttynum; | |
55 | ||
56 | /* for lxc-wait */ | |
57 | char *states; | |
58 | ||
cda02a28 MN |
59 | /* remaining arguments */ |
60 | char *const *argv; | |
61 | int argc; | |
62 | }; | |
63 | ||
64 | #define LXC_COMMON_OPTIONS \ | |
65 | {"name", required_argument, 0, 'n'}, \ | |
66 | {"help", no_argument, 0, 'h'}, \ | |
67 | {"usage", no_argument, 0, OPT_USAGE}, \ | |
68 | {"quiet", no_argument, 0, 'q'}, \ | |
69 | {"logfile", required_argument, 0, 'o'}, \ | |
70 | {"logpriority", required_argument, 0, 'l'}, \ | |
71 | {0, 0, 0, 0} | |
72 | ||
73 | /* option keys for long only options */ | |
74 | #define OPT_USAGE 0x1000 | |
75 | ||
76 | extern int lxc_arguments_parse(struct lxc_arguments *a_args, | |
77 | int argc, char *const argv[]); | |
78 | extern const char *lxc_strerror(int errnum); | |
79 | ||
80 | #define lxc_error(arg, fmt, args...) if (!(arg)->quiet) \ | |
81 | fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ## args) | |
82 | ||
83 | #endif |