]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/arguments.h
change C/R api
[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 <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;
45 int daemonize;
46 const char *rcfile;
47 const char *statefile;
48
49 /* for lxc-checkpoint */
50 int flags;
51
52 /* for lxc-console */
53 int ttynum;
54
55 /* for lxc-wait */
56 char *states;
57
58 /* remaining arguments */
59 char *const *argv;
60 int argc;
61 };
62
63 #define LXC_COMMON_OPTIONS \
64 {"name", required_argument, 0, 'n'}, \
65 {"help", no_argument, 0, 'h'}, \
66 {"usage", no_argument, 0, OPT_USAGE}, \
67 {"quiet", no_argument, 0, 'q'}, \
68 {"logfile", required_argument, 0, 'o'}, \
69 {"logpriority", required_argument, 0, 'l'}, \
70 {0, 0, 0, 0}
71
72 /* option keys for long only options */
73 #define OPT_USAGE 0x1000
74
75 extern int lxc_arguments_parse(struct lxc_arguments *args,
76 int argc, char *const argv[]);
77
78 extern char **lxc_arguments_dup(const char *file, struct lxc_arguments *args);
79
80 extern const char *lxc_strerror(int errnum);
81
82 #define lxc_error(arg, fmt, args...) if (!(arg)->quiet) \
83 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ## args)
84
85 #endif