Tizen 2.1 base
[external/device-mapper.git] / tools / lvm2cmd.h
1 /*
2  * Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.  
3  * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
4  *
5  * This file is part of LVM2.
6  *
7  * This copyrighted material is made available to anyone wishing to use,
8  * modify, copy, or redistribute it subject to the terms and conditions
9  * of the GNU Lesser General Public License v.2.1.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program; if not, write to the Free Software Foundation,
13  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14  */
15
16 #ifndef _LVM_CMDLIB_H
17 #define _LVM_CMDLIB_H
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 #ifndef _LVM_LOG_H
24 typedef void (*lvm2_log_fn_t) (int level, const char *file, int line,
25                                int dm_errno, const char *message);
26
27 #endif
28
29 #define LVM2_LOG_SUPPRESS       0
30
31 /* Logging levels */
32 #define LVM2_LOG_FATAL          2
33 #define LVM2_LOG_ERROR          3
34 #define LVM2_LOG_PRINT          4
35 #define LVM2_LOG_VERBOSE        5
36 #define LVM2_LOG_VERY_VERBOSE   6
37 #define LVM2_LOG_DEBUG          7
38
39 /*
40  * Define external function to replace the built-in logging function.
41  * It receives output line-by-line.
42  *
43  * level is the logging level (see above)
44  * file & line refer to the source code where the message originates.
45  */
46 void lvm2_log_fn(lvm2_log_fn_t log_fn);
47
48 /*
49  * Initialise library.
50  * Returns a handle so repeated use of lvm2_run is more efficient.
51  */ 
52 void *lvm2_init(void);
53
54 /*
55  * Set log level (as above) if using built-in logging function. 
56  * Default is LVM2_LOG_PRINT.  Use LVM2_LOG_SUPPRESS to suppress output.
57  */
58 void lvm2_log_level(void *handle, int level);
59
60 /*
61  * Run an LVM2 command. 
62  * Use NULL handle if the call is a one-off and you don't want to bother 
63  * calling lvm2_init/lvm2_exit.
64  */
65 int lvm2_run(void *handle, const char *cmdline);
66
67 /* Release handle */
68 void lvm2_exit(void *handle);
69
70 #ifdef __cplusplus
71 }
72 #endif
73 #endif