xref: /freebsd/usr.sbin/dumpcis/main.c (revision 1de7b4b805ddbf2429da511c053686ac4591ed89)
1*1de7b4b8SPedro F. Giffuni /*-
2*1de7b4b8SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*1de7b4b8SPedro F. Giffuni  *
40738c00eSWarner Losh  * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
50738c00eSWarner Losh  *
60738c00eSWarner Losh  * Redistribution and use in source and binary forms, with or without
70738c00eSWarner Losh  * modification, are permitted provided that the following conditions
80738c00eSWarner Losh  * are met:
90738c00eSWarner Losh  * 1. Redistributions of source code must retain the above copyright
100738c00eSWarner Losh  *    notice, this list of conditions and the following disclaimer.
110738c00eSWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
120738c00eSWarner Losh  *    notice, this list of conditions and the following disclaimer in the
130738c00eSWarner Losh  *    documentation and/or other materials provided with the distribution.
140738c00eSWarner Losh  *
150738c00eSWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
160738c00eSWarner Losh  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
170738c00eSWarner Losh  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
180738c00eSWarner Losh  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
190738c00eSWarner Losh  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
200738c00eSWarner Losh  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
210738c00eSWarner Losh  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
220738c00eSWarner Losh  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
230738c00eSWarner Losh  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
240738c00eSWarner Losh  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
250738c00eSWarner Losh  */
260738c00eSWarner Losh 
270738c00eSWarner Losh #include <sys/cdefs.h>
280738c00eSWarner Losh __FBSDID("$FreeBSD$");
290738c00eSWarner Losh 
302bbc3fd5SWarner Losh #include <fcntl.h>
312bbc3fd5SWarner Losh #include <stdio.h>
322bbc3fd5SWarner Losh #include <unistd.h>
332bbc3fd5SWarner Losh #include "readcis.h"
342bbc3fd5SWarner Losh 
352bbc3fd5SWarner Losh static void
362bbc3fd5SWarner Losh scanfile(char *name)
372bbc3fd5SWarner Losh {
382bbc3fd5SWarner Losh 	int     fd;
392d875dc5SWarner Losh 	struct tuple_list *tl;
402bbc3fd5SWarner Losh 
412bbc3fd5SWarner Losh 	fd = open(name, O_RDONLY);
422bbc3fd5SWarner Losh 	if (fd < 0)
432bbc3fd5SWarner Losh 		return;
442d875dc5SWarner Losh 	tl = readcis(fd);
452d875dc5SWarner Losh 	if (tl) {
462bbc3fd5SWarner Losh 		printf("Configuration data for file %s\n",
472bbc3fd5SWarner Losh 		    name);
482d875dc5SWarner Losh 		dumpcis(tl);
492d875dc5SWarner Losh 		freecis(tl);
502bbc3fd5SWarner Losh 	}
512bbc3fd5SWarner Losh 	close(fd);
522bbc3fd5SWarner Losh }
530738c00eSWarner Losh 
540738c00eSWarner Losh int
550738c00eSWarner Losh main(int argc, char **argv)
560738c00eSWarner Losh {
572bbc3fd5SWarner Losh 	for (argc--, argv++; argc; argc--, argv++)
582bbc3fd5SWarner Losh 		scanfile(*argv);
592bbc3fd5SWarner Losh 	return 0;
600738c00eSWarner Losh }
61