]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tools: lxc-console: share internal API symbols
author2xsec <dh48.jeong@samsung.com>
Fri, 29 Jun 2018 05:54:07 +0000 (14:54 +0900)
committer2xsec <dh48.jeong@samsung.com>
Sat, 30 Jun 2018 09:45:21 +0000 (18:45 +0900)
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
src/lxc/Makefile.am
src/lxc/tools/lxc_console.c

index f5ee8b17c5512e8bc55d7835640612e3bd8d338a..967bb21383585c803784f354a66b5abf43160ab8 100644 (file)
@@ -269,7 +269,7 @@ lxc_attach_SOURCES = tools/lxc_attach.c tools/arguments.c
 lxc_autostart_SOURCES = tools/lxc_autostart.c tools/arguments.c
 lxc_cgroup_SOURCES = tools/lxc_cgroup.c tools/arguments.c
 lxc_config_SOURCES = tools/lxc_config.c tools/arguments.c
-lxc_console_SOURCES = tools/lxc_console.c tools/arguments.c tools/tool_utils.c
+lxc_console_SOURCES = tools/lxc_console.c tools/arguments.c
 lxc_destroy_SOURCES = tools/lxc_destroy.c tools/arguments.c tools/tool_utils.c
 lxc_device_SOURCES = tools/lxc_device.c tools/arguments.c tools/tool_utils.c
 lxc_execute_SOURCES = tools/lxc_execute.c tools/arguments.c tools/tool_utils.c
index 7c22a7a404aad05602c24a9e6797e0d54e5366f6..11cddd5fea8ef1351c2fc338c5fef2062b46c026 100644 (file)
 #include <lxc/lxccontainer.h>
 
 #include "arguments.h"
-#include "tool_utils.h"
+#include "log.h"
+#include "utils.h"
+
+lxc_log_define(lxc_console, lxc);
 
 static char etoc(const char *expr)
 {
        /* returns "control code" of given expression */
        char c = expr[0] == '^' ? expr[1] : expr[0];
+
        return 1 + ((c > 'Z') ? (c - 'a') : (c - 'Z'));
 }
 
-static int my_parser(struct lxc_arguments* args, int c, char* arg)
+static int my_parser(struct lxc_arguments *args, int c, char *arg)
 {
        switch (c) {
        case 't':
@@ -59,6 +63,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
                args->escape = etoc(arg);
                break;
        }
+
        return 0;
 }
 
@@ -95,7 +100,7 @@ int main(int argc, char *argv[])
 
        ret = lxc_arguments_parse(&my_args, argc, argv);
        if (ret)
-               return EXIT_FAILURE;
+               exit(EXIT_FAILURE);
 
        /* Only create log if explicitly instructed */
        if (my_args.log_file || my_args.log_priority) {
@@ -112,33 +117,35 @@ int main(int argc, char *argv[])
 
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
-               fprintf(stderr, "System error loading container\n");
+               ERROR("System error loading container");
                exit(EXIT_FAILURE);
        }
 
        if (my_args.rcfile) {
                c->clear_config(c);
+
                if (!c->load_config(c, my_args.rcfile)) {
-                       fprintf(stderr, "Failed to load rcfile\n");
+                       ERROR("Failed to load rcfile");
                        lxc_container_put(c);
                        exit(EXIT_FAILURE);
                }
+
                c->configfile = strdup(my_args.rcfile);
                if (!c->configfile) {
-                       fprintf(stderr, "Out of memory setting new config filename\n");
+                       ERROR("Out of memory setting new config filename");
                        lxc_container_put(c);
                        exit(EXIT_FAILURE);
                }
        }
 
        if (!c->may_control(c)) {
-               fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
+               ERROR("Insufficent privileges to control %s", my_args.name);
                lxc_container_put(c);
                exit(EXIT_FAILURE);
        }
 
        if (!c->is_running(c)) {
-               fprintf(stderr, "%s is not running\n", my_args.name);
+               ERROR("%s is not running", my_args.name);
                lxc_container_put(c);
                exit(EXIT_FAILURE);
        }
@@ -148,6 +155,7 @@ int main(int argc, char *argv[])
                lxc_container_put(c);
                exit(EXIT_FAILURE);
        }
+
        lxc_container_put(c);
        exit(EXIT_SUCCESS);
 }