xref: /netbsd-src/external/gpl2/lvm2/dist/doc/example_cmdlib.c (revision 7c604eea85b4f330dc75ffe65e947f4d73758aa0)
1*7c604eeaShaad /*	$NetBSD: example_cmdlib.c,v 1.1.1.2 2009/12/02 00:26:03 haad Exp $	*/
256a34939Shaad 
356a34939Shaad /*
456a34939Shaad  * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
556a34939Shaad  *
656a34939Shaad  * This file is part of LVM2.
756a34939Shaad  *
856a34939Shaad  * This copyrighted material is made available to anyone wishing to use,
956a34939Shaad  * modify, copy, or redistribute it subject to the terms and conditions
1056a34939Shaad  * of the GNU General Public License v.2.
1156a34939Shaad  *
1256a34939Shaad  * You should have received a copy of the GNU General Public License
1356a34939Shaad  * along with this program; if not, write to the Free Software Foundation,
1456a34939Shaad  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1556a34939Shaad  */
1656a34939Shaad 
1756a34939Shaad #include "lvm2cmd.h"
1856a34939Shaad 
1956a34939Shaad /* All output gets passed to this function line-by-line */
test_log_fn(int level,int dm_errno,const char * file,int line,const char * format)20*7c604eeaShaad void test_log_fn(int level, int dm_errno, const char *file, int line,
21*7c604eeaShaad 		 const char *format)
2256a34939Shaad {
2356a34939Shaad 	/* Extract and process output here rather than printing it */
2456a34939Shaad 
2556a34939Shaad 	if (level != 4)
2656a34939Shaad 		return;
2756a34939Shaad 
2856a34939Shaad 	printf("%s\n", format);
2956a34939Shaad 	return;
3056a34939Shaad }
3156a34939Shaad 
main(int argc,char ** argv)3256a34939Shaad int main(int argc, char **argv)
3356a34939Shaad {
3456a34939Shaad 	void *handle;
3556a34939Shaad 	int r;
3656a34939Shaad 
3756a34939Shaad 	lvm2_log_fn(test_log_fn);
3856a34939Shaad 
3956a34939Shaad 	handle = lvm2_init();
4056a34939Shaad 
4156a34939Shaad 	lvm2_log_level(handle, 1);
4256a34939Shaad 	r = lvm2_run(handle, "vgs --noheadings vg1");
4356a34939Shaad 
4456a34939Shaad 	/* More commands here */
4556a34939Shaad 
4656a34939Shaad 	lvm2_exit(handle);
4756a34939Shaad 
4856a34939Shaad 	return r;
4956a34939Shaad }
5056a34939Shaad 
51