xref: /netbsd-src/external/gpl2/lvm2/dist/doc/example_cmdlib.c (revision 466a16a118933bd295a8a104f095714fadf9cf68)
1 /*	$NetBSD: example_cmdlib.c,v 1.1.1.1 2008/12/22 00:18:48 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
5  *
6  * This file is part of LVM2.
7  *
8  * This copyrighted material is made available to anyone wishing to use,
9  * modify, copy, or redistribute it subject to the terms and conditions
10  * of the GNU General Public License v.2.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16 
17 #include "lvm2cmd.h"
18 
19 /* All output gets passed to this function line-by-line */
20 void test_log_fn(int level, const char *file, int line, const char *format)
21 {
22 	/* Extract and process output here rather than printing it */
23 
24 	if (level != 4)
25 		return;
26 
27 	printf("%s\n", format);
28 	return;
29 }
30 
31 int main(int argc, char **argv)
32 {
33 	void *handle;
34 	int r;
35 
36 	lvm2_log_fn(test_log_fn);
37 
38 	handle = lvm2_init();
39 
40 	lvm2_log_level(handle, 1);
41 	r = lvm2_run(handle, "vgs --noheadings vg1");
42 
43 	/* More commands here */
44 
45 	lvm2_exit(handle);
46 
47 	return r;
48 }
49 
50