Commit 139d2dbf authored by Adrian Reber's avatar Adrian Reber Committed by Andrei Vagin

config: move getopt out of main()

This moves the whole getopt setup and analysis out of main() into its
own function in config.c.

The main motivation for this change is to be able to call getopt parsing
and configuration file parsing also from the RPC code path.

In one of the discussion emails about configuration files in CLI and RPC
mode the following architecture was proposed:

apply_config(global_conf)
apply_config(user_conf)
apply_config(pre_conf)
parse_command_line()
apply_rpc_options()
apply_config(post_conf)

And especially for the last step the getopt parsing needs to be out of
main() and callable from the RPC code path.
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 5ef03486
This diff is collapsed.
This diff is collapsed.
#ifndef __CR_OPTIONS_H__
#define __CR_OPTIONS_H__
#include <sys/types.h>
#include <stdbool.h>
#include "common/config.h"
#include "common/list.h"
......@@ -121,10 +122,14 @@ struct cr_options {
int weak_sysctls;
int status_fd;
bool orphan_pts_master;
pid_t tree_id;
int log_level;
char *imgs_dir;
};
extern struct cr_options opts;
extern void init_opts(void);
extern int parse_options(int argc, char **argv, bool *usage_error, bool *has_exec_cmd);
extern void init_opts();
#endif /* __CR_OPTIONS_H__ */
......@@ -32,10 +32,6 @@ extern int cr_lazy_pages(bool daemon);
extern int check_add_feature(char *arg);
extern void pr_check_features(const char *offset, const char *sep, int width);
extern int init_config(int argc, char **argv,
int *global_cfg_argc, int *user_cfg_argc,
bool *usage_error);
#define PPREP_HEAD_INACTIVE ((struct pprep_head *)-1)
#define add_post_prepare_cb_once(phead) do { \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment