Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Nov 2008 03:30:27 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185114 - head/usr.sbin/dumpcis
Message-ID:  <200811200330.mAK3UR95037726@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Thu Nov 20 03:30:27 2008
New Revision: 185114
URL: http://svn.freebsd.org/changeset/base/185114

Log:
  Simplify: move dumpcis.c and dumpcisfile.c into main.

Deleted:
  head/usr.sbin/dumpcis/dumpcis.c
  head/usr.sbin/dumpcis/dumpcisfile.c
Modified:
  head/usr.sbin/dumpcis/Makefile
  head/usr.sbin/dumpcis/main.c
  head/usr.sbin/dumpcis/readcis.h

Modified: head/usr.sbin/dumpcis/Makefile
==============================================================================
--- head/usr.sbin/dumpcis/Makefile	Thu Nov 20 02:06:05 2008	(r185113)
+++ head/usr.sbin/dumpcis/Makefile	Thu Nov 20 03:30:27 2008	(r185114)
@@ -4,7 +4,7 @@
 
 PROG=	dumpcis
 MAN=	dumpcis.8
-SRCS=	main.c dumpcis.c dumpcisfile.c readcis.c printcis.c
+SRCS=	main.c readcis.c printcis.c
 WARNS?=	5
 
 .include <bsd.prog.mk>

Modified: head/usr.sbin/dumpcis/main.c
==============================================================================
--- head/usr.sbin/dumpcis/main.c	Thu Nov 20 02:06:05 2008	(r185113)
+++ head/usr.sbin/dumpcis/main.c	Thu Nov 20 03:30:27 2008	(r185114)
@@ -25,10 +25,50 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-int dumpcisfile_main(int, char **);
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "readcis.h"
+
+void
+dump(unsigned char *p, int sz)
+{
+	int     ad = 0, i;
+
+	while (sz > 0) {
+		printf("%03x: ", ad);
+		for (i = 0; i < ((sz < 16) ? sz : 16); i++)
+			printf(" %02x", p[i]);
+		printf("\n");
+		sz -= 16;
+		p += 16;
+		ad += 16;
+	}
+}
+
+static void
+scanfile(char *name)
+{
+	int     fd;
+	struct cis *cp;
+
+	fd = open(name, O_RDONLY);
+	if (fd < 0)
+		return;
+	cp = readcis(fd);
+	if (cp) {
+		printf("Configuration data for file %s\n",
+		    name);
+		dumpcis(cp);
+		freecis(cp);
+	}
+	close(fd);
+}
 
 int
 main(int argc, char **argv)
 {
-	return dumpcisfile_main(argc, argv);
+	for (argc--, argv++; argc; argc--, argv++)
+		scanfile(*argv);
+	return 0;
 }

Modified: head/usr.sbin/dumpcis/readcis.h
==============================================================================
--- head/usr.sbin/dumpcis/readcis.h	Thu Nov 20 02:06:05 2008	(r185113)
+++ head/usr.sbin/dumpcis/readcis.h	Thu Nov 20 03:30:27 2008	(r185114)
@@ -144,5 +144,3 @@ struct cis *readcis(int);
 
 const char *tuple_name(unsigned char);
 u_int   parse_num(int, u_char *, u_char **, int);
-
-int isdumpcisfile;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811200330.mAK3UR95037726>