diff options
Diffstat (limited to 'usr.sbin/dumpcis')
-rw-r--r-- | usr.sbin/dumpcis/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/dumpcis/dumpcis.c | 58 | ||||
-rw-r--r-- | usr.sbin/dumpcis/dumpcisfile.c | 71 | ||||
-rw-r--r-- | usr.sbin/dumpcis/main.c | 44 | ||||
-rw-r--r-- | usr.sbin/dumpcis/readcis.h | 2 |
5 files changed, 43 insertions, 134 deletions
diff --git a/usr.sbin/dumpcis/Makefile b/usr.sbin/dumpcis/Makefile index 607c0fb..283de3a 100644 --- a/usr.sbin/dumpcis/Makefile +++ b/usr.sbin/dumpcis/Makefile @@ -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> diff --git a/usr.sbin/dumpcis/dumpcis.c b/usr.sbin/dumpcis/dumpcis.c deleted file mode 100644 index 9b89f2b..0000000 --- a/usr.sbin/dumpcis/dumpcis.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1995 Andrew McRae. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef lint -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - -#include <err.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/ioctl.h> - -#include <pccard/cardinfo.h> -#include <pccard/cis.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; - } -} diff --git a/usr.sbin/dumpcis/dumpcisfile.c b/usr.sbin/dumpcis/dumpcisfile.c deleted file mode 100644 index d8146a8..0000000 --- a/usr.sbin/dumpcis/dumpcisfile.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1995 Andrew McRae. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef lint -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - -#include <err.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/ioctl.h> - -#include <pccard/cardinfo.h> -#include <pccard/cis.h> -#include "readcis.h" - -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 -dumpcisfile_main(int argc, char **argv) -{ - - isdumpcisfile = 1; - for (argc--, argv++; argc; argc--, argv++) - scanfile(*argv); - return 0; -} diff --git a/usr.sbin/dumpcis/main.c b/usr.sbin/dumpcis/main.c index 317195c..d721b0a 100644 --- a/usr.sbin/dumpcis/main.c +++ b/usr.sbin/dumpcis/main.c @@ -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; } diff --git a/usr.sbin/dumpcis/readcis.h b/usr.sbin/dumpcis/readcis.h index 00d12e4..4551c9e 100644 --- a/usr.sbin/dumpcis/readcis.h +++ b/usr.sbin/dumpcis/readcis.h @@ -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; |