example_cmdlib.c revision 1.1.1.2
1/* $NetBSD: example_cmdlib.c,v 1.1.1.2 2009/12/02 00:26:03 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 */ 20void test_log_fn(int level, int dm_errno, const char *file, int line, 21 const char *format) 22{ 23 /* Extract and process output here rather than printing it */ 24 25 if (level != 4) 26 return; 27 28 printf("%s\n", format); 29 return; 30} 31 32int main(int argc, char **argv) 33{ 34 void *handle; 35 int r; 36 37 lvm2_log_fn(test_log_fn); 38 39 handle = lvm2_init(); 40 41 lvm2_log_level(handle, 1); 42 r = lvm2_run(handle, "vgs --noheadings vg1"); 43 44 /* More commands here */ 45 46 lvm2_exit(handle); 47 48 return r; 49} 50 51