~serge-hallyn/ubuntu/natty/lxc/lxc-fix-3bugs

« back to all changes in this revision

Viewing changes to src/lxc/lxc_stop.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2009-07-25 12:24:30 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090725122430-dxv1wb7ds07fc0sk
Tags: 0.6.3-1
* New Upstream Version
* Remove duplicate build-dependency on autotools-dev
* Build depend on linux-libc-dev
* Disable checking of netlink headers from configure
  (currently fails under sid)
* Upgrade standards-version to 3.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <sys/types.h>
27
27
 
28
28
#include <lxc/lxc.h>
29
 
 
30
 
void usage(char *cmd)
31
 
{
32
 
        fprintf(stderr, "%s <command>\n", basename(cmd));
33
 
        fprintf(stderr, "\t -n <name>   : name of the container\n");
34
 
        _exit(1);
35
 
}
 
29
#include "arguments.h"
 
30
 
 
31
static const struct option my_longopts[] = {
 
32
        LXC_COMMON_OPTIONS
 
33
};
 
34
 
 
35
static struct lxc_arguments my_args = {
 
36
        .progname = "lxc-stop",
 
37
        .help     = "\
 
38
--name=NAME\n\
 
39
\n\
 
40
lxc-stop stops a container with the identifier NAME\n\
 
41
\n\
 
42
Options :\n\
 
43
  -n, --name=NAME   NAME for name of the container\n",
 
44
        .options  = my_longopts,
 
45
        .parser   = NULL,
 
46
        .checker  = NULL,
 
47
};
36
48
 
37
49
int main(int argc, char *argv[])
38
50
{
39
 
        char *name = NULL;
40
 
        int opt, err, nbargs = 0;
41
 
 
42
 
        while ((opt = getopt(argc, argv, "n:")) != -1) {
43
 
                switch (opt) {
44
 
                case 'n':
45
 
                        name = optarg;
46
 
                        break;
47
 
                }
48
 
 
49
 
                nbargs++;
50
 
        }
51
 
 
52
 
        if (!name)
53
 
                usage(argv[0]);
54
 
 
55
 
        err = lxc_stop(name);
56
 
        if (err) {
57
 
                fprintf(stderr, "%s\n", lxc_strerror(err));
58
 
                return 1;
59
 
        }
60
 
 
61
 
        return 0;
 
51
        if (lxc_arguments_parse(&my_args, argc, argv))
 
52
                return -1;
 
53
 
 
54
        if (lxc_log_init(my_args.log_file, my_args.log_priority,
 
55
                         my_args.progname, my_args.quiet))
 
56
                return -1;
 
57
 
 
58
        return lxc_stop(my_args.name);
62
59
}