summaryrefslogtreecommitdiffstats
path: root/lib/commands/toolcontext.h
blob: 08b813edf17354f1d933c3c1658b8835ff8561ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright (C) 2001 Sistina Software (UK) Limited.
 *
 * This file is released under the LGPL.
 *
 */

#ifndef _LVM_TOOLCONTEXT_H
#define _LVM_TOOLCONTEXT_H

#include "dev-cache.h"
#include "config.h"
#include "pool.h"
#include "metadata.h"

#include <stdio.h>
#include <limits.h>

/*
 * Config options that can be changed while commands are processed
 */
struct config_info {
	int debug;
	int verbose;
	int test;
	int syslog;
	int activation;
	int suffix;
	uint64_t unit_factor;
	char unit_type;
	const char *msg_prefix;
	int cmd_name;		/* Show command name? */

	int archive;		/* should we archive ? */
	int backup;		/* should we backup ? */

	struct format_type *fmt;

	mode_t umask;
};

/* FIXME Split into tool & library contexts */
/* command-instance-related variables needed by library */
struct cmd_context {
	/* format handler allocates all objects from here */
	struct pool *mem;

	const struct format_type *fmt;	/* Current format to use by default */
	struct format_type *fmt_backup;	/* Format to use for backups */

	struct list formats;	/* Available formats */

	char *cmd_line;
	struct command *command;
	struct arg *args;
	char **argv;

	struct dev_filter *filter;
	int dump_filter;	/* Dump filter when exiting? */

	struct config_tree *cf;
	struct config_info default_settings;
	struct config_info current_settings;

	char sys_dir[PATH_MAX];
	char dev_dir[PATH_MAX];
	char proc_dir[PATH_MAX];
};

struct cmd_context *create_toolcontext(struct arg *the_args);
void destroy_toolcontext(struct cmd_context *cmd);

#endif