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